bug #28561 [Cache] prevent getting older entries when the version key is evicted (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[Cache] prevent getting older entries when the version key is evicted
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #28445
| License | MIT
| Doc PR | -
As described in linked issue, using a strategy described in
https://github.com/memcached/memcached/wiki/ProgrammingTricks#deleting-by-namespace
Commits
-------
00855895a8
[Cache] prevent getting older entries when the version key is evicted
This commit is contained in:
commit
2a605c2ed6
@ -106,14 +106,7 @@ trait AbstractTrait
|
||||
{
|
||||
$this->deferred = array();
|
||||
if ($cleared = $this->versioningIsEnabled) {
|
||||
$namespaceVersion = 2;
|
||||
try {
|
||||
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
|
||||
$namespaceVersion = 1 + (int) $v;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
$namespaceVersion .= ':';
|
||||
$namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5);
|
||||
try {
|
||||
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
|
||||
} catch (\Exception $e) {
|
||||
@ -247,6 +240,10 @@ trait AbstractTrait
|
||||
foreach ($this->doFetch(array('@'.$this->namespace)) as $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) {
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user