Skip to content

Commit

Permalink
[Cache] Improve resiliency when calling doFetch() in AbstractTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 20, 2018
1 parent bef15ce commit b7ccf10
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Symfony/Component/Cache/Traits/AbstractTrait.php
Expand Up @@ -108,8 +108,11 @@ public function clear()
try {
if ($cleared = $this->versioningIsEnabled) {
$namespaceVersion = 2;
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
$namespaceVersion = 1 + (int) $v;
try {
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
$namespaceVersion = 1 + (int) $v;
}
} catch (\Exception $e) {
}
$namespaceVersion .= ':';
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
Expand Down Expand Up @@ -236,8 +239,11 @@ private function getId($key)

if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
$this->namespaceVersion = '1:';
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
$this->namespaceVersion = $v;
try {
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
$this->namespaceVersion = $v;
}
} catch (\Exception $e) {
}
}

Expand Down

0 comments on commit b7ccf10

Please sign in to comment.