[Cache] prevent getting older entries when the version key is evicted
This commit is contained in:
parent
9bc774ccf2
commit
00855895a8
@ -106,14 +106,7 @@ trait AbstractTrait
|
|||||||
{
|
{
|
||||||
$this->deferred = array();
|
$this->deferred = array();
|
||||||
if ($cleared = $this->versioningIsEnabled) {
|
if ($cleared = $this->versioningIsEnabled) {
|
||||||
$namespaceVersion = 2;
|
$namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5);
|
||||||
try {
|
|
||||||
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
|
|
||||||
$namespaceVersion = 1 + (int) $v;
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
}
|
|
||||||
$namespaceVersion .= ':';
|
|
||||||
try {
|
try {
|
||||||
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
|
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -247,6 +240,10 @@ trait AbstractTrait
|
|||||||
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
|
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
|
||||||
$this->namespaceVersion = $v;
|
$this->namespaceVersion = $v;
|
||||||
}
|
}
|
||||||
|
if ('1:' === $this->namespaceVersion) {
|
||||||
|
$this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5);
|
||||||
|
$this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0);
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user