Skip to content

Commit

Permalink
Merge pull request #120 from jakubenglicky/fix_nette_caching
Browse files Browse the repository at this point in the history
Fix compatibility with Nette/Caching v3.1.3
  • Loading branch information
Spamercz authored Jun 13, 2022
2 parents b67ac20 + f2c644c commit 4c38efa
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 @@ -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"
},
Expand Down
7 changes: 4 additions & 3 deletions src/Kdyby/Redis/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])) {
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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];
}

Expand Down

0 comments on commit 4c38efa

Please sign in to comment.