Skip to content

Commit 4c38efa

Browse files
authored
Merge pull request #120 from jakubenglicky/fix_nette_caching
Fix compatibility with Nette/Caching v3.1.3
2 parents b67ac20 + f2c644c commit 4c38efa

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"php": ">=7.4",
2121
"ext-redis": "*",
2222
"nette/di": "~3.0",
23-
"nette/caching": "~3.0",
23+
"nette/caching": "~3.1",
2424
"nette/http": "~3.0",
2525
"nette/utils": "~3.0"
2626
},

src/Kdyby/Redis/RedisStorage.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class RedisStorage implements \Kdyby\Redis\IMultiReadStorage
2929
* @internal
3030
*/
3131
private const NS_NETTE = 'Nette.Storage';
32+
private const NAMESPACE_SEPARATOR = "\x00";
3233

3334
/**
3435
* cache meta structure: array of
@@ -215,7 +216,7 @@ public function write(string $key, $data, array $dp): void
215216
$meta[self::META_SERIALIZED] = TRUE;
216217
}
217218

218-
$store = \json_encode($meta) . Cache::NAMESPACE_SEPARATOR . $data;
219+
$store = \json_encode($meta) . self::NAMESPACE_SEPARATOR . $data;
219220

220221
try {
221222
if (isset($dp[Cache::EXPIRATION])) {
@@ -275,7 +276,7 @@ public function clean(array $conds): void
275276

276277
protected function formatEntryKey(string $key): string
277278
{
278-
return self::NS_NETTE . ':' . \str_replace(Cache::NAMESPACE_SEPARATOR, ':', $key);
279+
return self::NS_NETTE . ':' . \str_replace(self::NAMESPACE_SEPARATOR, ':', $key);
279280
}
280281

281282
/**
@@ -334,7 +335,7 @@ private function doMultiRead(array $keys): array
334335
*/
335336
private static function processStoredValue(string $key, string $storedValue): array
336337
{
337-
[$meta, $data] = \explode(Cache::NAMESPACE_SEPARATOR, $storedValue, 2) + [NULL, NULL];
338+
[$meta, $data] = \explode(self::NAMESPACE_SEPARATOR, $storedValue, 2) + [NULL, NULL];
338339
return [[self::KEY => $key] + \json_decode($meta, TRUE), $data];
339340
}
340341

0 commit comments

Comments
 (0)