class StaticFileCacheBackend in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php \Drupal\Tests\Component\FileCache\StaticFileCacheBackend
Allows to cache data based on file modification dates in a static cache.
Hierarchy
- class \Drupal\Tests\Component\FileCache\StaticFileCacheBackend implements FileCacheBackendInterface
Expanded class hierarchy of StaticFileCacheBackend
File
- core/
tests/ Drupal/ Tests/ Component/ FileCache/ StaticFileCacheBackend.php, line 15 - Contains \Drupal\Tests\Component\FileCache\StaticFileCacheBackend.
Namespace
Drupal\Tests\Component\FileCacheView source
class StaticFileCacheBackend implements FileCacheBackendInterface {
/**
* Internal static cache.
*
* @var array
*/
protected static $cache = [];
/**
* Bin used for storing the data in the static cache.
*
* @var string
*/
protected $bin;
/**
* Constructs a PHP Storage FileCache backend.
*
* @param array $configuration
* (optional) Configuration used to configure this object.
*/
public function __construct($configuration) {
$this->bin = isset($configuration['bin']) ? $configuration['bin'] : 'file_cache';
}
/**
* {@inheritdoc}
*/
public function fetch(array $cids) {
$result = [];
foreach ($cids as $cid) {
if (isset(static::$cache[$this->bin][$cid])) {
$result[$cid] = static::$cache[$this->bin][$cid];
}
}
return $result;
}
/**
* {@inheritdoc}
*/
public function store($cid, $data) {
static::$cache[$this->bin][$cid] = $data;
}
/**
* {@inheritdoc}
*/
public function delete($cid) {
unset(static::$cache[$this->bin][$cid]);
}
/**
* Allows tests to reset the static cache to avoid side effects.
*/
public static function reset() {
static::$cache = [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StaticFileCacheBackend:: |
protected | property | Bin used for storing the data in the static cache. | |
StaticFileCacheBackend:: |
protected static | property | Internal static cache. | |
StaticFileCacheBackend:: |
public | function |
Deletes data from a cache backend. Overrides FileCacheBackendInterface:: |
|
StaticFileCacheBackend:: |
public | function |
Fetches data from the cache backend. Overrides FileCacheBackendInterface:: |
|
StaticFileCacheBackend:: |
public static | function | Allows tests to reset the static cache to avoid side effects. | |
StaticFileCacheBackend:: |
public | function |
Stores data into a cache backend. Overrides FileCacheBackendInterface:: |
|
StaticFileCacheBackend:: |
public | function | Constructs a PHP Storage FileCache backend. |