Skip to content

Commit 69cb030

Browse files
committed
Merge branch 'MCP-103' into mcp-123
2 parents 8f95889 + a800f8c commit 69cb030

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,23 @@ public function save($data, $id, $tags = [], $specificLifetime = false)
248248
$this->unlock($id);
249249
}
250250

251+
if (!mt_rand(0, 100) && $this->checkIfLocalCacheSpaceExceeded()) {
252+
$this->local->clean();
253+
}
254+
251255
return $this->local->save($dataToSave, $id, [], $specificLifetime);
252256
}
253257

258+
/**
259+
* Check if local cache space bigger that configure amount
260+
*
261+
* @return bool
262+
*/
263+
private function checkIfLocalCacheSpaceExceeded()
264+
{
265+
return $this->getFillingPercentage() >= 95;
266+
}
267+
254268
/**
255269
* @inheritdoc
256270
*/
@@ -266,7 +280,8 @@ public function remove($id)
266280
*/
267281
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = [])
268282
{
269-
return $this->remote->clean($mode, $tags);
283+
return $this->remote->clean($mode, $tags) &&
284+
$this->local->clean($mode, $tags);
270285
}
271286

272287
/**

0 commit comments

Comments
 (0)