Skip to content

Commit f784f8c

Browse files
Fix compatibility with Nette/Caching v3.1.3 (#39)
1 parent 4b7efd5 commit f784f8c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"require-dev": {
2929
"mockery/mockery": "^1.3.3",
30-
"nette/caching": "^2.5.0 || ^3.1.0",
30+
"nette/caching": "^2.5.0 || ^3.1.3",
3131
"nette/http": "^2.4.0 || ^3.0.1",
3232
"ninjify/nunjuck": "^0.4",
3333
"ninjify/qa": "^0.12",

src/Caching/RedisStorage.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ final class RedisStorage implements Storage
1818
{
1919

2020
private const NS_NETTE = 'Contributte.Storage';
21+
private const NS_SEPARATOR = "\x00";
2122

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

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

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

210211
private function formatEntryKey(string $key): string
211212
{
212-
return self::NS_NETTE . ':' . str_replace(Cache::NAMESPACE_SEPARATOR, ':', $key);
213+
return self::NS_NETTE . ':' . str_replace(self::NS_SEPARATOR, ':', $key);
213214
}
214215

215216

@@ -312,7 +313,7 @@ private function doMultiRead(array $keys): array
312313
*/
313314
private static function processStoredValue(string $key, string $storedValue): array
314315
{
315-
[$meta, $data] = explode(Cache::NAMESPACE_SEPARATOR, $storedValue, 2) + [null, null];
316+
[$meta, $data] = explode(self::NS_SEPARATOR, $storedValue, 2) + [null, null];
316317
return [[self::KEY => $key] + json_decode((string) $meta, true), $data];
317318
}
318319

0 commit comments

Comments
 (0)