27 parent::__construct ( $root,
$postfix );
28 $defaultParams = [
'server' =>
'0.0.0.0',
'port' => 6379,
'persistent' =>
true,
'serializer' => \Redis::SERIALIZER_PHP ];
29 $cacheParams = \array_merge ( $defaultParams, $cacheParams );
30 $this->cacheInstance = new \Redis ();
32 if ($cacheParams [
'persistent'] ??
true) {
33 $connect =
'pconnect';
35 $this->cacheInstance->{$connect} ( $cacheParams [
'server'], $cacheParams [
'port'] );
36 if (isset ( $cacheParams [
'serializer'] )) {
37 $this->cacheInstance->setOption ( \Redis::OPT_SERIALIZER, $cacheParams [
'serializer'] );
42 $this->cacheInstance->setOption ( \Redis::OPT_SERIALIZER, $serializer );
52 return $this->cacheInstance->exists ( $this->getRealKey ( $key ) );
55 public function store($key, $content, $tag =
null) {
56 $this->cacheInstance->set ( $this->getRealKey ( $key ), $content );
60 return \str_replace ( [
'/',
'\\' ],
"-", $key );
70 return $this->cacheInstance->get ( $this->getRealKey ( $key ) );
80 return $this->cacheInstance->get ( $this->getRealKey ( $key ) );
90 return $this->cacheInstance->ttl ( $this->getRealKey ( $key ) );
93 public function remove($key) {
94 $this->cacheInstance->delete ( $this->getRealKey ( $key ) );
98 $this->cacheInstance->flushAll ();
103 $keys = $this->cacheInstance->keys ( $type );
105 foreach ( $keys as $key ) {
106 $ttl = $this->cacheInstance->ttl ( $key );
107 $result [] =
new CacheFile ( \ucfirst ( $type ), $key, $ttl,
"", $key );
109 if (\count ( $result ) === 0)
110 $result [] =
new CacheFile ( \ucfirst ( $type ),
"",
"",
"" );
115 $keys = $this->cacheInstance->keys ( $type );
116 foreach ( $keys as $key ) {
117 $this->cacheInstance->delete ( $key );
122 return parent::getCacheInfo () .
"<br>Driver name : <b>" . \Redis::class .
"</b>";
126 return $this->getRealKey ( $key );
This class is responsible for storing Arrays in PHP files.
This class is responsible for storing values with Redis.
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.
setSerializer($serializer)
__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.