StaticFileCacheBackend.php in Drupal 9
File
core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php
View source
<?php
namespace Drupal\Tests\Component\FileCache;
use Drupal\Component\FileCache\FileCacheBackendInterface;
class StaticFileCacheBackend implements FileCacheBackendInterface {
protected static $cache = [];
protected $bin;
public function __construct($configuration) {
$this->bin = isset($configuration['bin']) ? $configuration['bin'] : 'file_cache';
}
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;
}
public function store($cid, $data) {
static::$cache[$this->bin][$cid] = $data;
}
public function delete($cid) {
unset(static::$cache[$this->bin][$cid]);
}
public static function reset() {
static::$cache = [];
}
}