Skip to content

Commit acfe92d

Browse files
committed
MC-33275: Stale cache implementation
1 parent cd88da9 commit acfe92d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/Magento/Framework/Cache/Backend/RemoteSynchronizedCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public function load($id, $doNotTestCacheValidity = false)
185185
{
186186
$localData = $this->local->load($id);
187187
$remoteData = false;
188+
$versionCheckFailed = false;
188189

189190
if (false === $localData) {
190191
$remoteData = $this->remote->load($id);
@@ -193,7 +194,7 @@ public function load($id, $doNotTestCacheValidity = false)
193194
return false;
194195
}
195196
} else {
196-
if ($this->getDataVersion($localData) !== $this->loadRemoteDataVersion($id)) {
197+
if ($versionCheckFailed = $this->getDataVersion($localData) !== $this->loadRemoteDataVersion($id)) {
197198
$remoteData = $this->remote->load($id);
198199

199200
if (!$this->_options['use_stale_cache']) {
@@ -205,7 +206,7 @@ public function load($id, $doNotTestCacheValidity = false)
205206
if ($remoteData !== false) {
206207
$this->local->save($remoteData, $id);
207208
$localData = $remoteData;
208-
} elseif ($this->_options['use_stale_cache'] && $localData !== false) {
209+
} elseif ($this->_options['use_stale_cache'] && $localData !== false && $versionCheckFailed) {
209210
if ($this->lock($id)) {
210211
return false;
211212
}

0 commit comments

Comments
 (0)