- Issue created by @mxh
Default memory implementation Drupal\Core\Cache\MemoryBackend
does not invalidate cache tags.
Current implementation of cache invalidation is solely checking for expire time:
<?php
protected function prepareItem($cache, $allow_invalid) {
if (!isset($cache->data)) {
return FALSE;
}
// The object passed into this function is the one stored in $this->cache.
// We must clone it as part of the preparation step so that the actual
// cache object is not affected by the unserialize() call or other
// manipulations of the returned object.
$prepared = clone $cache;
$prepared->data = unserialize($prepared->data);
// Check expire time.
$prepared->valid = $prepared->expire == Cache::PERMANENT || $prepared->expire >= $this->getRequestTime();
if (!$allow_invalid && !$prepared->valid) {
return FALSE;
}
return $prepared;
}
?>
This is very bad for concurrent requests happening, making it possible that the memory cache returns invalid data although not requested when calling get method with $allow_invalid = FALSE
(which is the default).
The problem gets more and more severe for example for processes running a couple of seconds and long running processes (such as cron and batch operations).
TBD
Memory cache needs to make sure it's not returning invalid data by checking whether the cache tags are diffferent.
Active
11.0 🔥