@@ -106,7 +106,7 @@ public function clear()
106
106
{
107
107
$ this ->deferred = [];
108
108
if ($ cleared = $ this ->versioningIsEnabled ) {
109
- $ namespaceVersion = substr_replace (base64_encode (pack ('V ' , mt_rand ())), ' : ' , 5 );
109
+ $ namespaceVersion = substr_replace (base64_encode (pack ('V ' , mt_rand ())), static :: getNsSeparator () , 5 );
110
110
try {
111
111
$ cleared = $ this ->doSave (['@ ' .$ this ->namespace => $ namespaceVersion ], 0 );
112
112
} catch (\Exception $ e ) {
@@ -235,13 +235,13 @@ private function getId($key)
235
235
CacheItem::validateKey ($ key );
236
236
237
237
if ($ this ->versioningIsEnabled && '' === $ this ->namespaceVersion ) {
238
- $ this ->namespaceVersion = '1: ' ;
238
+ $ this ->namespaceVersion = '1 ' . static :: getNsSeparator () ;
239
239
try {
240
240
foreach ($ this ->doFetch (['@ ' .$ this ->namespace ]) as $ v ) {
241
241
$ this ->namespaceVersion = $ v ;
242
242
}
243
- if ('1: ' === $ this ->namespaceVersion ) {
244
- $ this ->namespaceVersion = substr_replace (base64_encode (pack ('V ' , time ())), ' : ' , 5 );
243
+ if ('1 ' . static :: getNsSeparator () === $ this ->namespaceVersion ) {
244
+ $ this ->namespaceVersion = substr_replace (base64_encode (pack ('V ' , time ())), static :: getNsSeparator () , 5 );
245
245
$ this ->doSave (['@ ' .$ this ->namespace => $ this ->namespaceVersion ], 0 );
246
246
}
247
247
} catch (\Exception $ e ) {
@@ -252,7 +252,7 @@ private function getId($key)
252
252
return $ this ->namespace .$ this ->namespaceVersion .$ key ;
253
253
}
254
254
if (\strlen ($ id = $ this ->namespace .$ this ->namespaceVersion .$ key ) > $ this ->maxIdLength ) {
255
- $ id = $ this ->namespace .$ this ->namespaceVersion .substr_replace (base64_encode (hash ('sha256 ' , $ key , true )), ' : ' , -(\strlen ($ this ->namespaceVersion ) + 22 ));
255
+ $ id = $ this ->namespace .$ this ->namespaceVersion .substr_replace (base64_encode (hash ('sha256 ' , $ key , true )), static :: getNsSeparator () , -(\strlen ($ this ->namespaceVersion ) + 22 ));
256
256
}
257
257
258
258
return $ id ;
@@ -265,4 +265,12 @@ public static function handleUnserializeCallback($class)
265
265
{
266
266
throw new \DomainException ('Class not found: ' .$ class );
267
267
}
268
+
269
+ /**
270
+ * @return string the namespace separator for cache keys
271
+ */
272
+ protected static function getNsSeparator ()
273
+ {
274
+ return ': ' ;
275
+ }
268
276
}
0 commit comments