Skip to content

Commit

Permalink
Fix compatibility with Nette/Caching v3.1.3 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubenglicky authored May 18, 2022
1 parent 4b7efd5 commit f784f8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"require-dev": {
"mockery/mockery": "^1.3.3",
"nette/caching": "^2.5.0 || ^3.1.0",
"nette/caching": "^2.5.0 || ^3.1.3",
"nette/http": "^2.4.0 || ^3.0.1",
"ninjify/nunjuck": "^0.4",
"ninjify/qa": "^0.12",
Expand Down
7 changes: 4 additions & 3 deletions src/Caching/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class RedisStorage implements Storage
{

private const NS_NETTE = 'Contributte.Storage';
private const NS_SEPARATOR = "\x00";

private const META_TIME = 'time'; // timestamp
private const META_EXPIRE = 'expire'; // expiration timestamp
Expand Down Expand Up @@ -159,7 +160,7 @@ public function write($key, $data, array $dependencies): void
}

$data = $this->serializer->serialize($data, $meta);
$store = json_encode($meta) . Cache::NAMESPACE_SEPARATOR . $data;
$store = json_encode($meta) . self::NS_SEPARATOR . $data;

try {
if (isset($dependencies[Cache::EXPIRATION])) {
Expand Down Expand Up @@ -209,7 +210,7 @@ public function clean(array $conditions): void

private function formatEntryKey(string $key): string
{
return self::NS_NETTE . ':' . str_replace(Cache::NAMESPACE_SEPARATOR, ':', $key);
return self::NS_NETTE . ':' . str_replace(self::NS_SEPARATOR, ':', $key);
}


Expand Down Expand Up @@ -312,7 +313,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::NS_SEPARATOR, $storedValue, 2) + [null, null];
return [[self::KEY => $key] + json_decode((string) $meta, true), $data];
}

Expand Down

0 comments on commit f784f8c

Please sign in to comment.