class AwsCacheAdapter in Flysystem - S3 8
Same name and namespace in other branches
- 2.0.x src/AwsCacheAdapter.php \Drupal\flysystem_s3\AwsCacheAdapter
A Drupal cache adapter for use with the AWS PHP SDK.
Hierarchy
- class \Drupal\flysystem_s3\AwsCacheAdapter implements \Aws\CacheInterface
Expanded class hierarchy of AwsCacheAdapter
2 files declare their use of AwsCacheAdapter
- AwsCacheAdapterTest.php in tests/
src/ Unit/ AwsCacheAdapterTest.php - S3.php in src/
Flysystem/ S3.php
File
- src/
AwsCacheAdapter.php, line 11
Namespace
Drupal\flysystem_s3View source
class AwsCacheAdapter implements CacheInterface {
/**
* The cache backend.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
private $cache;
/**
* The cache prefix.
*
* @var string
*/
private $prefix;
/**
* Constructs an AwsCacheAdapter object.
*
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The Drupal cache backend.
* @param string $prefix
* (Optional) The prefix to use for cache items. Defaults to an empty
* string.
*/
public function __construct(CacheBackendInterface $cache, $prefix = '') {
$this->cache = $cache;
$this->prefix = $prefix;
}
/**
* {@inheritdoc}
*/
public function get($key) {
if ($item = $this->cache
->get($this->prefix . $key)) {
return $item->data;
}
}
/**
* {@inheritdoc}
*/
public function set($key, $value, $ttl = 0) {
$ttl = (int) $ttl;
$ttl = $ttl === 0 ? CacheBackendInterface::CACHE_PERMANENT : time() + $ttl;
$this->cache
->set($this->prefix . $key, $value, $ttl);
}
/**
* {@inheritdoc}
*/
public function remove($key) {
$this->cache
->delete($this->prefix . $key);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AwsCacheAdapter:: |
private | property | The cache backend. | |
AwsCacheAdapter:: |
private | property | The cache prefix. | |
AwsCacheAdapter:: |
public | function | ||
AwsCacheAdapter:: |
public | function | ||
AwsCacheAdapter:: |
public | function | ||
AwsCacheAdapter:: |
public | function | Constructs an AwsCacheAdapter object. |