diff --git a/composer.json b/composer.json index 872ef30..eec85a8 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "php": ">=7.4", "ext-redis": "*", "nette/di": "~3.0", - "nette/caching": "~3.0", + "nette/caching": "~3.1", "nette/http": "~3.0", "nette/utils": "~3.0" }, diff --git a/src/Kdyby/Redis/RedisStorage.php b/src/Kdyby/Redis/RedisStorage.php index 73bedbd..32d6eef 100644 --- a/src/Kdyby/Redis/RedisStorage.php +++ b/src/Kdyby/Redis/RedisStorage.php @@ -29,6 +29,7 @@ class RedisStorage implements \Kdyby\Redis\IMultiReadStorage * @internal */ private const NS_NETTE = 'Nette.Storage'; + private const NAMESPACE_SEPARATOR = "\x00"; /** * cache meta structure: array of @@ -215,7 +216,7 @@ public function write(string $key, $data, array $dp): void $meta[self::META_SERIALIZED] = TRUE; } - $store = \json_encode($meta) . Cache::NAMESPACE_SEPARATOR . $data; + $store = \json_encode($meta) . self::NAMESPACE_SEPARATOR . $data; try { if (isset($dp[Cache::EXPIRATION])) { @@ -275,7 +276,7 @@ public function clean(array $conds): void protected function formatEntryKey(string $key): string { - return self::NS_NETTE . ':' . \str_replace(Cache::NAMESPACE_SEPARATOR, ':', $key); + return self::NS_NETTE . ':' . \str_replace(self::NAMESPACE_SEPARATOR, ':', $key); } /** @@ -334,7 +335,7 @@ private function doMultiRead(array $keys): array */ private static function processStoredValue(string $key, string $storedValue): array { - [$meta, $data] = \explode(Cache::NAMESPACE_SEPARATOR, $storedValue, 2) + [NULL, NULL]; + [$meta, $data] = \explode(self::NAMESPACE_SEPARATOR, $storedValue, 2) + [NULL, NULL]; return [[self::KEY => $key] + \json_decode($meta, TRUE), $data]; }