@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | implode( |
202 | 202 | ', ', |
203 | 203 | array_map( |
204 | - static fn (ExtendedCacheItemPoolInterface $pool) => \get_class($pool), |
|
204 | + static fn(ExtendedCacheItemPoolInterface $pool) => \get_class($pool), |
|
205 | 205 | $this->clusterPools |
206 | 206 | ) |
207 | 207 | ) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $stats->setSize( |
212 | 212 | (int) array_sum( |
213 | 213 | array_map( |
214 | - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->getStats()->getSize(), |
|
214 | + static fn(ExtendedCacheItemPoolInterface $pool) => $pool->getStats()->getSize(), |
|
215 | 215 | $this->clusterPools |
216 | 216 | ) |
217 | 217 | ) |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | implode( |
222 | 222 | ', ', |
223 | 223 | array_map( |
224 | - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->getStats()->getData(), |
|
224 | + static fn(ExtendedCacheItemPoolInterface $pool) => $pool->getStats()->getData(), |
|
225 | 225 | $this->clusterPools |
226 | 226 | ) |
227 | 227 | ) |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | public function getItem(string $key): ExtendedCacheItemInterface |
55 | 55 | { |
56 | 56 | return $this->getStandardizedItem( |
57 | - $this->makeOperation(static fn (ExtendedCacheItemPoolInterface $pool) => $pool->getItem($key)) ?? new Item($this, $key, $this->getEventManager()), |
|
57 | + $this->makeOperation(static fn(ExtendedCacheItemPoolInterface $pool) => $pool->getItem($key)) ?? new Item($this, $key, $this->getEventManager()), |
|
58 | 58 | $this |
59 | 59 | ); |
60 | 60 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function hasItem(string $key): bool |
100 | 100 | { |
101 | 101 | return $this->makeOperation( |
102 | - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->hasItem($key) |
|
102 | + static fn(ExtendedCacheItemPoolInterface $pool) => $pool->hasItem($key) |
|
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | public function clear(): bool |
110 | 110 | { |
111 | 111 | return $this->makeOperation( |
112 | - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->clear() |
|
112 | + static fn(ExtendedCacheItemPoolInterface $pool) => $pool->clear() |
|
113 | 113 | ); |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function deleteItem(string $key): bool |
120 | 120 | { |
121 | 121 | return $this->makeOperation( |
122 | - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->deleteItem($key) |
|
122 | + static fn(ExtendedCacheItemPoolInterface $pool) => $pool->deleteItem($key) |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function save(CacheItemInterface $item): bool |
130 | 130 | { |
131 | 131 | return $this->makeOperation( |
132 | - function (ExtendedCacheItemPoolInterface $pool) use ($item) { |
|
132 | + function(ExtendedCacheItemPoolInterface $pool) use ($item) { |
|
133 | 133 | /* @var ExtendedCacheItemInterface $item */ |
134 | 134 | $item->setHit(true); |
135 | 135 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function commit(): bool |
145 | 145 | { |
146 | 146 | return $this->makeOperation( |
147 | - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->commit() |
|
147 | + static fn(ExtendedCacheItemPoolInterface $pool) => $pool->commit() |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $config = self::validateConfig($config); |
91 | 91 | $driver = self::standardizeDriverName($driver); |
92 | - $instanceId = $instanceId ?: md5($driver . serialize(array_filter($config->toArray(), static fn ($val) => !\is_callable($val)))); |
|
92 | + $instanceId = $instanceId ?: md5($driver . serialize(array_filter($config->toArray(), static fn($val) => !\is_callable($val)))); |
|
93 | 93 | |
94 | 94 | if (!isset(self::$instances[$instanceId])) { |
95 | 95 | $driverClass = self::validateDriverClass(self::getDriverClass($driver)); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $found = false; |
187 | 187 | self::$instances = array_filter( |
188 | 188 | array_map( |
189 | - static function (ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) { |
|
189 | + static function(ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) { |
|
190 | 190 | if (spl_object_hash($cachePool) === spl_object_hash($cachePoolInstance)) { |
191 | 191 | $found = true; |
192 | 192 |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stat = new DriverStatistic(); |
|
48 | - $stat->setInfo('[ZendDisk] A void info string') |
|
49 | - ->setSize(0) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setRawData(false); |
|
52 | - |
|
53 | - return $stat; |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_disk_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_disk_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_disk_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stat = new DriverStatistic(); |
|
48 | - $stat->setInfo('[ZendDisk] A void info string') |
|
49 | - ->setSize(0) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setRawData(false); |
|
52 | - |
|
53 | - return $stat; |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_disk_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_disk_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_disk_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stat = new DriverStatistic(); |
|
48 | - $stat->setInfo('[ZendDisk] A void info string') |
|
49 | - ->setSize(0) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setRawData(false); |
|
52 | - |
|
53 | - return $stat; |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_disk_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_disk_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_disk_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stat = new DriverStatistic(); |
|
48 | - $stat->setInfo('[ZendDisk] A void info string') |
|
49 | - ->setSize(0) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setRawData(false); |
|
52 | - |
|
53 | - return $stat; |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_disk_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_disk_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_disk_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stat = new DriverStatistic(); |
|
48 | - $stat->setInfo('[ZendDisk] A void info string') |
|
49 | - ->setSize(0) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setRawData(false); |
|
52 | - |
|
53 | - return $stat; |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_disk_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_disk_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_disk_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $this->database->selectCollection($collectionName) |
91 | 91 | ->createIndex( |
92 | 92 | [self::DRIVER_EDATE_WRAPPER_INDEX => 1], |
93 | - ['expireAfterSeconds' => 0, 'name' => 'auto_expire_index'] |
|
93 | + ['expireAfterSeconds' => 0, 'name' => 'auto_expire_index'] |
|
94 | 94 | ); |
95 | 95 | } |
96 | 96 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | ) |
214 | 214 | )->toArray()[0]; |
215 | 215 | |
216 | - $arrayFilterRecursive = static function ($array, ?callable $callback = null) use (&$arrayFilterRecursive) { |
|
216 | + $arrayFilterRecursive = static function($array, ?callable $callback = null) use (&$arrayFilterRecursive) { |
|
217 | 217 | $array = $callback($array); |
218 | 218 | |
219 | 219 | if (\is_object($array) || \is_array($array)) { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | return $array; |
226 | 226 | }; |
227 | 227 | |
228 | - $callback = static function ($item) { |
|
228 | + $callback = static function($item) { |
|
229 | 229 | /* |
230 | 230 | * Remove unserializable properties |
231 | 231 | */ |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | if (\count($servers) > 0) { |
282 | 282 | $host = array_reduce( |
283 | 283 | $servers, |
284 | - static fn ($carry, $data) => $carry . ('' === $carry ? '' : ',') . $data['host'] . ':' . $data['port'], |
|
284 | + static fn($carry, $data) => $carry . ('' === $carry ? '' : ',') . $data['host'] . ':' . $data['port'], |
|
285 | 285 | '' |
286 | 286 | ); |
287 | 287 | $port = false; |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stats = (array) zend_shm_cache_info(); |
|
48 | - |
|
49 | - return (new DriverStatistic()) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
52 | - ->setRawData($stats) |
|
53 | - ->setSize($stats['memory_total']); |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_shm_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_shm_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_shm_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stats = (array) zend_shm_cache_info(); |
|
48 | - |
|
49 | - return (new DriverStatistic()) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
52 | - ->setRawData($stats) |
|
53 | - ->setSize($stats['memory_total']); |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_shm_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_shm_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_shm_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stats = (array) zend_shm_cache_info(); |
|
48 | - |
|
49 | - return (new DriverStatistic()) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
52 | - ->setRawData($stats) |
|
53 | - ->setSize($stats['memory_total']); |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_shm_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_shm_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_shm_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stats = (array) zend_shm_cache_info(); |
|
48 | - |
|
49 | - return (new DriverStatistic()) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
52 | - ->setRawData($stats) |
|
53 | - ->setSize($stats['memory_total']); |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_shm_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_shm_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_shm_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -36,69 +36,3 @@ |
||
36 | 36 | public function getHelp(): string |
37 | 37 | { |
38 | 38 | return <<<'HELP' |
39 | - <p> |
|
40 | - This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server |
|
41 | - </p> |
|
42 | - HELP; |
|
43 | - } |
|
44 | - |
|
45 | - public function getStats(): DriverStatistic |
|
46 | - { |
|
47 | - $stats = (array) zend_shm_cache_info(); |
|
48 | - |
|
49 | - return (new DriverStatistic()) |
|
50 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
51 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
52 | - ->setRawData($stats) |
|
53 | - ->setSize($stats['memory_total']); |
|
54 | - } |
|
55 | - |
|
56 | - protected function driverConnect(): bool |
|
57 | - { |
|
58 | - return true; |
|
59 | - } |
|
60 | - |
|
61 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
62 | - { |
|
63 | - $data = zend_shm_cache_fetch($item->getKey()); |
|
64 | - if (false === $data) { |
|
65 | - return null; |
|
66 | - } |
|
67 | - |
|
68 | - return $data; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @throws PhpfastcacheInvalidArgumentException |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
77 | - { |
|
78 | - $this->assertCacheItemType($item, Item::class); |
|
79 | - |
|
80 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
81 | - |
|
82 | - return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @throws PhpfastcacheInvalidArgumentException |
|
87 | - */ |
|
88 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
89 | - { |
|
90 | - $this->assertCacheItemType($item, Item::class); |
|
91 | - |
|
92 | - return (bool) zend_shm_cache_delete($item->getKey()); |
|
93 | - } |
|
94 | - |
|
95 | - protected function driverClear(): bool |
|
96 | - { |
|
97 | - return @zend_shm_cache_clear(); |
|
98 | - } |
|
99 | - |
|
100 | - public function getConfig(): Config |
|
101 | - { |
|
102 | - return $this->config; |
|
103 | - } |
|
104 | -} |
@@ -45,131 +45,3 @@ |
||
45 | 45 | public function getHelp(): string |
46 | 46 | { |
47 | 47 | return <<<'HELP' |
48 | - <p> |
|
49 | - To install the Predis library via Composer: |
|
50 | - <code>composer require "predis/predis" "~1.1.0"</code> |
|
51 | - </p> |
|
52 | - HELP; |
|
53 | - } |
|
54 | - |
|
55 | - public function getStats(): DriverStatistic |
|
56 | - { |
|
57 | - $info = $this->instance->info(); |
|
58 | - $size = ($info['Memory']['used_memory'] ?? 0); |
|
59 | - $version = ($info['Server']['redis_version'] ?? 0); |
|
60 | - $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTimeImmutable())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
61 | - |
|
62 | - return (new DriverStatistic()) |
|
63 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
64 | - ->setRawData($info) |
|
65 | - ->setSize((int) $size) |
|
66 | - ->setInfo( |
|
67 | - sprintf( |
|
68 | - "The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
69 | - $version, |
|
70 | - $date->format(\DATE_RFC2822) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @throws PhpfastcacheDriverException |
|
77 | - * @throws PhpfastcacheLogicException |
|
78 | - */ |
|
79 | - protected function driverConnect(): bool |
|
80 | - { |
|
81 | - /* |
|
82 | - * In case of an user-provided |
|
83 | - * Predis client just return here |
|
84 | - */ |
|
85 | - if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
86 | - $this->instance = $this->getConfig()->getPredisClient(); |
|
87 | - if (!$this->instance->isConnected()) { |
|
88 | - $this->instance->connect(); |
|
89 | - } |
|
90 | - |
|
91 | - return true; |
|
92 | - } |
|
93 | - |
|
94 | - $options = []; |
|
95 | - |
|
96 | - if ($this->getConfig()->getOptPrefix()) { |
|
97 | - $options['prefix'] = $this->getConfig()->getOptPrefix(); |
|
98 | - } |
|
99 | - |
|
100 | - if (!empty($this->getConfig()->getPath())) { |
|
101 | - $this->instance = new PredisClient( |
|
102 | - [ |
|
103 | - 'scheme' => $this->getConfig()->getScheme(), |
|
104 | - 'persistent' => $this->getConfig()->isPersistent(), |
|
105 | - 'timeout' => $this->getConfig()->getTimeout(), |
|
106 | - 'path' => $this->getConfig()->getPath(), |
|
107 | - ], |
|
108 | - $options |
|
109 | - ); |
|
110 | - } else { |
|
111 | - $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options); |
|
112 | - } |
|
113 | - |
|
114 | - try { |
|
115 | - $this->instance->connect(); |
|
116 | - } catch (PredisConnectionException $e) { |
|
117 | - throw new PhpfastcacheDriverException('Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', 0, $e); |
|
118 | - } |
|
119 | - |
|
120 | - return true; |
|
121 | - } |
|
122 | - |
|
123 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
124 | - { |
|
125 | - $val = $this->instance->get($item->getKey()); |
|
126 | - if (false == $val) { |
|
127 | - return null; |
|
128 | - } |
|
129 | - |
|
130 | - return $this->decode($val); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws PhpfastcacheInvalidArgumentException |
|
135 | - * @throws PhpfastcacheLogicException |
|
136 | - * |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
140 | - { |
|
141 | - $this->assertCacheItemType($item, Item::class); |
|
142 | - |
|
143 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
144 | - |
|
145 | - /* |
|
146 | - * @see https://redis.io/commands/setex |
|
147 | - * @see https://redis.io/commands/expire |
|
148 | - */ |
|
149 | - if ($ttl <= 0) { |
|
150 | - return (bool) $this->instance->expire($item->getKey(), 0); |
|
151 | - } |
|
152 | - |
|
153 | - return 'OK' === $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload(); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @throws PhpfastcacheInvalidArgumentException |
|
158 | - */ |
|
159 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
160 | - { |
|
161 | - $this->assertCacheItemType($item, Item::class); |
|
162 | - |
|
163 | - return (bool) $this->instance->del([$item->getKey()]); |
|
164 | - } |
|
165 | - |
|
166 | - protected function driverClear(): bool |
|
167 | - { |
|
168 | - return 'OK' === $this->instance->flushdb()->getPayload(); |
|
169 | - } |
|
170 | - |
|
171 | - public function getConfig(): Config |
|
172 | - { |
|
173 | - return $this->config; |
|
174 | - } |
|
175 | -} |
@@ -45,131 +45,3 @@ |
||
45 | 45 | public function getHelp(): string |
46 | 46 | { |
47 | 47 | return <<<'HELP' |
48 | - <p> |
|
49 | - To install the Predis library via Composer: |
|
50 | - <code>composer require "predis/predis" "~1.1.0"</code> |
|
51 | - </p> |
|
52 | - HELP; |
|
53 | - } |
|
54 | - |
|
55 | - public function getStats(): DriverStatistic |
|
56 | - { |
|
57 | - $info = $this->instance->info(); |
|
58 | - $size = ($info['Memory']['used_memory'] ?? 0); |
|
59 | - $version = ($info['Server']['redis_version'] ?? 0); |
|
60 | - $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTimeImmutable())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
61 | - |
|
62 | - return (new DriverStatistic()) |
|
63 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
64 | - ->setRawData($info) |
|
65 | - ->setSize((int) $size) |
|
66 | - ->setInfo( |
|
67 | - sprintf( |
|
68 | - "The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
69 | - $version, |
|
70 | - $date->format(\DATE_RFC2822) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @throws PhpfastcacheDriverException |
|
77 | - * @throws PhpfastcacheLogicException |
|
78 | - */ |
|
79 | - protected function driverConnect(): bool |
|
80 | - { |
|
81 | - /* |
|
82 | - * In case of an user-provided |
|
83 | - * Predis client just return here |
|
84 | - */ |
|
85 | - if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
86 | - $this->instance = $this->getConfig()->getPredisClient(); |
|
87 | - if (!$this->instance->isConnected()) { |
|
88 | - $this->instance->connect(); |
|
89 | - } |
|
90 | - |
|
91 | - return true; |
|
92 | - } |
|
93 | - |
|
94 | - $options = []; |
|
95 | - |
|
96 | - if ($this->getConfig()->getOptPrefix()) { |
|
97 | - $options['prefix'] = $this->getConfig()->getOptPrefix(); |
|
98 | - } |
|
99 | - |
|
100 | - if (!empty($this->getConfig()->getPath())) { |
|
101 | - $this->instance = new PredisClient( |
|
102 | - [ |
|
103 | - 'scheme' => $this->getConfig()->getScheme(), |
|
104 | - 'persistent' => $this->getConfig()->isPersistent(), |
|
105 | - 'timeout' => $this->getConfig()->getTimeout(), |
|
106 | - 'path' => $this->getConfig()->getPath(), |
|
107 | - ], |
|
108 | - $options |
|
109 | - ); |
|
110 | - } else { |
|
111 | - $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options); |
|
112 | - } |
|
113 | - |
|
114 | - try { |
|
115 | - $this->instance->connect(); |
|
116 | - } catch (PredisConnectionException $e) { |
|
117 | - throw new PhpfastcacheDriverException('Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', 0, $e); |
|
118 | - } |
|
119 | - |
|
120 | - return true; |
|
121 | - } |
|
122 | - |
|
123 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
124 | - { |
|
125 | - $val = $this->instance->get($item->getKey()); |
|
126 | - if (false == $val) { |
|
127 | - return null; |
|
128 | - } |
|
129 | - |
|
130 | - return $this->decode($val); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws PhpfastcacheInvalidArgumentException |
|
135 | - * @throws PhpfastcacheLogicException |
|
136 | - * |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
140 | - { |
|
141 | - $this->assertCacheItemType($item, Item::class); |
|
142 | - |
|
143 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
144 | - |
|
145 | - /* |
|
146 | - * @see https://redis.io/commands/setex |
|
147 | - * @see https://redis.io/commands/expire |
|
148 | - */ |
|
149 | - if ($ttl <= 0) { |
|
150 | - return (bool) $this->instance->expire($item->getKey(), 0); |
|
151 | - } |
|
152 | - |
|
153 | - return 'OK' === $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload(); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @throws PhpfastcacheInvalidArgumentException |
|
158 | - */ |
|
159 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
160 | - { |
|
161 | - $this->assertCacheItemType($item, Item::class); |
|
162 | - |
|
163 | - return (bool) $this->instance->del([$item->getKey()]); |
|
164 | - } |
|
165 | - |
|
166 | - protected function driverClear(): bool |
|
167 | - { |
|
168 | - return 'OK' === $this->instance->flushdb()->getPayload(); |
|
169 | - } |
|
170 | - |
|
171 | - public function getConfig(): Config |
|
172 | - { |
|
173 | - return $this->config; |
|
174 | - } |
|
175 | -} |
@@ -45,131 +45,3 @@ |
||
45 | 45 | public function getHelp(): string |
46 | 46 | { |
47 | 47 | return <<<'HELP' |
48 | - <p> |
|
49 | - To install the Predis library via Composer: |
|
50 | - <code>composer require "predis/predis" "~1.1.0"</code> |
|
51 | - </p> |
|
52 | - HELP; |
|
53 | - } |
|
54 | - |
|
55 | - public function getStats(): DriverStatistic |
|
56 | - { |
|
57 | - $info = $this->instance->info(); |
|
58 | - $size = ($info['Memory']['used_memory'] ?? 0); |
|
59 | - $version = ($info['Server']['redis_version'] ?? 0); |
|
60 | - $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTimeImmutable())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
61 | - |
|
62 | - return (new DriverStatistic()) |
|
63 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
64 | - ->setRawData($info) |
|
65 | - ->setSize((int) $size) |
|
66 | - ->setInfo( |
|
67 | - sprintf( |
|
68 | - "The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
69 | - $version, |
|
70 | - $date->format(\DATE_RFC2822) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @throws PhpfastcacheDriverException |
|
77 | - * @throws PhpfastcacheLogicException |
|
78 | - */ |
|
79 | - protected function driverConnect(): bool |
|
80 | - { |
|
81 | - /* |
|
82 | - * In case of an user-provided |
|
83 | - * Predis client just return here |
|
84 | - */ |
|
85 | - if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
86 | - $this->instance = $this->getConfig()->getPredisClient(); |
|
87 | - if (!$this->instance->isConnected()) { |
|
88 | - $this->instance->connect(); |
|
89 | - } |
|
90 | - |
|
91 | - return true; |
|
92 | - } |
|
93 | - |
|
94 | - $options = []; |
|
95 | - |
|
96 | - if ($this->getConfig()->getOptPrefix()) { |
|
97 | - $options['prefix'] = $this->getConfig()->getOptPrefix(); |
|
98 | - } |
|
99 | - |
|
100 | - if (!empty($this->getConfig()->getPath())) { |
|
101 | - $this->instance = new PredisClient( |
|
102 | - [ |
|
103 | - 'scheme' => $this->getConfig()->getScheme(), |
|
104 | - 'persistent' => $this->getConfig()->isPersistent(), |
|
105 | - 'timeout' => $this->getConfig()->getTimeout(), |
|
106 | - 'path' => $this->getConfig()->getPath(), |
|
107 | - ], |
|
108 | - $options |
|
109 | - ); |
|
110 | - } else { |
|
111 | - $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options); |
|
112 | - } |
|
113 | - |
|
114 | - try { |
|
115 | - $this->instance->connect(); |
|
116 | - } catch (PredisConnectionException $e) { |
|
117 | - throw new PhpfastcacheDriverException('Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', 0, $e); |
|
118 | - } |
|
119 | - |
|
120 | - return true; |
|
121 | - } |
|
122 | - |
|
123 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
124 | - { |
|
125 | - $val = $this->instance->get($item->getKey()); |
|
126 | - if (false == $val) { |
|
127 | - return null; |
|
128 | - } |
|
129 | - |
|
130 | - return $this->decode($val); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws PhpfastcacheInvalidArgumentException |
|
135 | - * @throws PhpfastcacheLogicException |
|
136 | - * |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
140 | - { |
|
141 | - $this->assertCacheItemType($item, Item::class); |
|
142 | - |
|
143 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
144 | - |
|
145 | - /* |
|
146 | - * @see https://redis.io/commands/setex |
|
147 | - * @see https://redis.io/commands/expire |
|
148 | - */ |
|
149 | - if ($ttl <= 0) { |
|
150 | - return (bool) $this->instance->expire($item->getKey(), 0); |
|
151 | - } |
|
152 | - |
|
153 | - return 'OK' === $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload(); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @throws PhpfastcacheInvalidArgumentException |
|
158 | - */ |
|
159 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
160 | - { |
|
161 | - $this->assertCacheItemType($item, Item::class); |
|
162 | - |
|
163 | - return (bool) $this->instance->del([$item->getKey()]); |
|
164 | - } |
|
165 | - |
|
166 | - protected function driverClear(): bool |
|
167 | - { |
|
168 | - return 'OK' === $this->instance->flushdb()->getPayload(); |
|
169 | - } |
|
170 | - |
|
171 | - public function getConfig(): Config |
|
172 | - { |
|
173 | - return $this->config; |
|
174 | - } |
|
175 | -} |
@@ -45,131 +45,3 @@ |
||
45 | 45 | public function getHelp(): string |
46 | 46 | { |
47 | 47 | return <<<'HELP' |
48 | - <p> |
|
49 | - To install the Predis library via Composer: |
|
50 | - <code>composer require "predis/predis" "~1.1.0"</code> |
|
51 | - </p> |
|
52 | - HELP; |
|
53 | - } |
|
54 | - |
|
55 | - public function getStats(): DriverStatistic |
|
56 | - { |
|
57 | - $info = $this->instance->info(); |
|
58 | - $size = ($info['Memory']['used_memory'] ?? 0); |
|
59 | - $version = ($info['Server']['redis_version'] ?? 0); |
|
60 | - $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTimeImmutable())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
61 | - |
|
62 | - return (new DriverStatistic()) |
|
63 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
64 | - ->setRawData($info) |
|
65 | - ->setSize((int) $size) |
|
66 | - ->setInfo( |
|
67 | - sprintf( |
|
68 | - "The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
69 | - $version, |
|
70 | - $date->format(\DATE_RFC2822) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @throws PhpfastcacheDriverException |
|
77 | - * @throws PhpfastcacheLogicException |
|
78 | - */ |
|
79 | - protected function driverConnect(): bool |
|
80 | - { |
|
81 | - /* |
|
82 | - * In case of an user-provided |
|
83 | - * Predis client just return here |
|
84 | - */ |
|
85 | - if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
86 | - $this->instance = $this->getConfig()->getPredisClient(); |
|
87 | - if (!$this->instance->isConnected()) { |
|
88 | - $this->instance->connect(); |
|
89 | - } |
|
90 | - |
|
91 | - return true; |
|
92 | - } |
|
93 | - |
|
94 | - $options = []; |
|
95 | - |
|
96 | - if ($this->getConfig()->getOptPrefix()) { |
|
97 | - $options['prefix'] = $this->getConfig()->getOptPrefix(); |
|
98 | - } |
|
99 | - |
|
100 | - if (!empty($this->getConfig()->getPath())) { |
|
101 | - $this->instance = new PredisClient( |
|
102 | - [ |
|
103 | - 'scheme' => $this->getConfig()->getScheme(), |
|
104 | - 'persistent' => $this->getConfig()->isPersistent(), |
|
105 | - 'timeout' => $this->getConfig()->getTimeout(), |
|
106 | - 'path' => $this->getConfig()->getPath(), |
|
107 | - ], |
|
108 | - $options |
|
109 | - ); |
|
110 | - } else { |
|
111 | - $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options); |
|
112 | - } |
|
113 | - |
|
114 | - try { |
|
115 | - $this->instance->connect(); |
|
116 | - } catch (PredisConnectionException $e) { |
|
117 | - throw new PhpfastcacheDriverException('Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', 0, $e); |
|
118 | - } |
|
119 | - |
|
120 | - return true; |
|
121 | - } |
|
122 | - |
|
123 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
124 | - { |
|
125 | - $val = $this->instance->get($item->getKey()); |
|
126 | - if (false == $val) { |
|
127 | - return null; |
|
128 | - } |
|
129 | - |
|
130 | - return $this->decode($val); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws PhpfastcacheInvalidArgumentException |
|
135 | - * @throws PhpfastcacheLogicException |
|
136 | - * |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
140 | - { |
|
141 | - $this->assertCacheItemType($item, Item::class); |
|
142 | - |
|
143 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
144 | - |
|
145 | - /* |
|
146 | - * @see https://redis.io/commands/setex |
|
147 | - * @see https://redis.io/commands/expire |
|
148 | - */ |
|
149 | - if ($ttl <= 0) { |
|
150 | - return (bool) $this->instance->expire($item->getKey(), 0); |
|
151 | - } |
|
152 | - |
|
153 | - return 'OK' === $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload(); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @throws PhpfastcacheInvalidArgumentException |
|
158 | - */ |
|
159 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
160 | - { |
|
161 | - $this->assertCacheItemType($item, Item::class); |
|
162 | - |
|
163 | - return (bool) $this->instance->del([$item->getKey()]); |
|
164 | - } |
|
165 | - |
|
166 | - protected function driverClear(): bool |
|
167 | - { |
|
168 | - return 'OK' === $this->instance->flushdb()->getPayload(); |
|
169 | - } |
|
170 | - |
|
171 | - public function getConfig(): Config |
|
172 | - { |
|
173 | - return $this->config; |
|
174 | - } |
|
175 | -} |
@@ -45,131 +45,3 @@ |
||
45 | 45 | public function getHelp(): string |
46 | 46 | { |
47 | 47 | return <<<'HELP' |
48 | - <p> |
|
49 | - To install the Predis library via Composer: |
|
50 | - <code>composer require "predis/predis" "~1.1.0"</code> |
|
51 | - </p> |
|
52 | - HELP; |
|
53 | - } |
|
54 | - |
|
55 | - public function getStats(): DriverStatistic |
|
56 | - { |
|
57 | - $info = $this->instance->info(); |
|
58 | - $size = ($info['Memory']['used_memory'] ?? 0); |
|
59 | - $version = ($info['Server']['redis_version'] ?? 0); |
|
60 | - $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTimeImmutable())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
61 | - |
|
62 | - return (new DriverStatistic()) |
|
63 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
64 | - ->setRawData($info) |
|
65 | - ->setSize((int) $size) |
|
66 | - ->setInfo( |
|
67 | - sprintf( |
|
68 | - "The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
69 | - $version, |
|
70 | - $date->format(\DATE_RFC2822) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @throws PhpfastcacheDriverException |
|
77 | - * @throws PhpfastcacheLogicException |
|
78 | - */ |
|
79 | - protected function driverConnect(): bool |
|
80 | - { |
|
81 | - /* |
|
82 | - * In case of an user-provided |
|
83 | - * Predis client just return here |
|
84 | - */ |
|
85 | - if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
86 | - $this->instance = $this->getConfig()->getPredisClient(); |
|
87 | - if (!$this->instance->isConnected()) { |
|
88 | - $this->instance->connect(); |
|
89 | - } |
|
90 | - |
|
91 | - return true; |
|
92 | - } |
|
93 | - |
|
94 | - $options = []; |
|
95 | - |
|
96 | - if ($this->getConfig()->getOptPrefix()) { |
|
97 | - $options['prefix'] = $this->getConfig()->getOptPrefix(); |
|
98 | - } |
|
99 | - |
|
100 | - if (!empty($this->getConfig()->getPath())) { |
|
101 | - $this->instance = new PredisClient( |
|
102 | - [ |
|
103 | - 'scheme' => $this->getConfig()->getScheme(), |
|
104 | - 'persistent' => $this->getConfig()->isPersistent(), |
|
105 | - 'timeout' => $this->getConfig()->getTimeout(), |
|
106 | - 'path' => $this->getConfig()->getPath(), |
|
107 | - ], |
|
108 | - $options |
|
109 | - ); |
|
110 | - } else { |
|
111 | - $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options); |
|
112 | - } |
|
113 | - |
|
114 | - try { |
|
115 | - $this->instance->connect(); |
|
116 | - } catch (PredisConnectionException $e) { |
|
117 | - throw new PhpfastcacheDriverException('Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', 0, $e); |
|
118 | - } |
|
119 | - |
|
120 | - return true; |
|
121 | - } |
|
122 | - |
|
123 | - protected function driverRead(ExtendedCacheItemInterface $item): ?array |
|
124 | - { |
|
125 | - $val = $this->instance->get($item->getKey()); |
|
126 | - if (false == $val) { |
|
127 | - return null; |
|
128 | - } |
|
129 | - |
|
130 | - return $this->decode($val); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws PhpfastcacheInvalidArgumentException |
|
135 | - * @throws PhpfastcacheLogicException |
|
136 | - * |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - protected function driverWrite(ExtendedCacheItemInterface $item): bool |
|
140 | - { |
|
141 | - $this->assertCacheItemType($item, Item::class); |
|
142 | - |
|
143 | - $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
144 | - |
|
145 | - /* |
|
146 | - * @see https://redis.io/commands/setex |
|
147 | - * @see https://redis.io/commands/expire |
|
148 | - */ |
|
149 | - if ($ttl <= 0) { |
|
150 | - return (bool) $this->instance->expire($item->getKey(), 0); |
|
151 | - } |
|
152 | - |
|
153 | - return 'OK' === $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload(); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @throws PhpfastcacheInvalidArgumentException |
|
158 | - */ |
|
159 | - protected function driverDelete(ExtendedCacheItemInterface $item): bool |
|
160 | - { |
|
161 | - $this->assertCacheItemType($item, Item::class); |
|
162 | - |
|
163 | - return (bool) $this->instance->del([$item->getKey()]); |
|
164 | - } |
|
165 | - |
|
166 | - protected function driverClear(): bool |
|
167 | - { |
|
168 | - return 'OK' === $this->instance->flushdb()->getPayload(); |
|
169 | - } |
|
170 | - |
|
171 | - public function getConfig(): Config |
|
172 | - { |
|
173 | - return $this->config; |
|
174 | - } |
|
175 | -} |
@@ -107,7 +107,7 @@ |
||
107 | 107 | $this->instance->setSaslAuthData($server['saslUser'], $server['saslPassword']); |
108 | 108 | } |
109 | 109 | if (!$connected) { |
110 | - throw new PhpfastcacheDriverConnectException(sprintf('Failed to connect to memcache host/path "%s".', $server['host'] ?: $server['path'], )); |
|
110 | + throw new PhpfastcacheDriverConnectException(sprintf('Failed to connect to memcache host/path "%s".', $server['host'] ?: $server['path'],)); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |
@@ -120,7 +120,7 @@ |
||
120 | 120 | |
121 | 121 | protected function decodeFirestoreDocument(array $snapshotData): array |
122 | 122 | { |
123 | - return array_map(static function ($datum) { |
|
123 | + return array_map(static function($datum) { |
|
124 | 124 | if ($datum instanceof GoogleTimestamp) { |
125 | 125 | $date = $datum->get(); |
126 | 126 | if ($date instanceof DateTimeImmutable) { |