Skip to content

Commit 02a6f24

Browse files
[Cache] fix versioning with SimpleCacheAdapter
1 parent cfc8ac0 commit 02a6f24

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ protected function doSave(array $values, $lifetime)
7878

7979
/**
8080
* @return string the namespace separator for cache keys
81+
*
82+
* @internal
8183
*/
8284
protected static function getNsSeparator()
8385
{

src/Symfony/Component/Cache/Traits/AbstractTrait.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function clear()
108108
if ($cleared = $this->versioningIsEnabled) {
109109
$namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), static::getNsSeparator(), 5);
110110
try {
111-
$cleared = $this->doSave(['@'.$this->namespace => $namespaceVersion], 0);
111+
$cleared = $this->doSave([static::getNsSeparator().$this->namespace => $namespaceVersion], 0);
112112
} catch (\Exception $e) {
113113
$cleared = false;
114114
}
@@ -237,12 +237,12 @@ private function getId($key)
237237
if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
238238
$this->namespaceVersion = '1'.static::getNsSeparator();
239239
try {
240-
foreach ($this->doFetch(['@'.$this->namespace]) as $v) {
240+
foreach ($this->doFetch([static::getNsSeparator().$this->namespace]) as $v) {
241241
$this->namespaceVersion = $v;
242242
}
243243
if ('1'.static::getNsSeparator() === $this->namespaceVersion) {
244244
$this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), static::getNsSeparator(), 5);
245-
$this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0);
245+
$this->doSave([static::getNsSeparator().$this->namespace => $this->namespaceVersion], 0);
246246
}
247247
} catch (\Exception $e) {
248248
}
@@ -268,6 +268,8 @@ public static function handleUnserializeCallback($class)
268268

269269
/**
270270
* @return string the namespace separator for cache keys
271+
*
272+
* @internal
271273
*/
272274
protected static function getNsSeparator()
273275
{

0 commit comments

Comments
 (0)