6use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
7use Phpfastcache\CacheManager;
29 parent::__construct ( $root,
$postfix );
30 $cacheType = $cacheParams [
'type'] ??
'Files';
31 $configClass =
'\\Phpfastcache\\Drivers\\' . \ucfirst ( $cacheType ) .
'\\Config';
32 unset ( $cacheParams [
'type'] );
33 $defaultParams = [
'defaultTtl' => 86400,
'itemDetailedDate' => true ];
34 $cacheParams = \array_merge ( $defaultParams, $cacheParams );
35 $this->cacheInstance = CacheManager::getInstance ( $cacheType,
new $configClass ( $cacheParams ) );
45 return $this->cacheInstance->hasItem ( $this->
getRealKey ( $key ) );
48 public function store($key, $content, $tag =
null) {
50 $item = $this->cacheInstance->getItem ( $key );
51 $item->set ( $content );
53 $item->addTag ( $tag );
55 $this->cacheInstance->save ( $item );
59 return \str_replace ( [
'\\',
'/' ],
'-', $key );
69 return $this->cacheInstance->getItem ( $this->
getRealKey ( $key ) )->get ();
79 return $this->cacheInstance->getItem ( $this->
getRealKey ( $key ) )->get ();
89 return $this->cacheInstance->getItem ( $this->
getRealKey ( $key ) )->getModificationDate ()->getTimestamp ();
92 public function remove($key) {
93 $this->cacheInstance->deleteItem ( $this->
getRealKey ( $key ) );
97 $this->cacheInstance->clear ();
101 return $this->cacheInstance->getItemsByTag ( $type );
108 foreach ( $entries as $entry ) {
109 $key = $entry->getKey ();
110 $result [] =
new CacheFile ( \ucfirst ( $type ), $key, $entry->getCreationDate ()->getTimestamp (),
"", $key );
112 if (\count ( $result ) === 0)
113 $result [] =
new CacheFile ( \ucfirst ( $type ),
"",
"",
"" );
118 $this->cacheInstance->deleteItemsByTag ( $type );
122 return parent::getCacheInfo () .
"<br>Driver name : <b>" . $this->cacheInstance->getDriverName () .
"</b>";
126 return $this->cacheInstance->getItem ( $this->
getRealKey ( $key ) )->getKey ();
This class is responsible for storing Arrays in PHP files.
This class is responsible for storing values with PhpFastCache.
file_get_contents($key)
return data stored for the given key.
fetch($key)
Fetches data stored for the given key.
clear()
Clears all cache entries.
__construct($root, $postfix="", $cacheParams=[])
Initializes the cache-provider.
exists($key)
Check if annotation-data for the key has been stored.
store($key, $content, $tag=null)
Caches the given data with the given key.
getTimestamp($key)
Returns the timestamp of the last cache update for the given key.