[Cache] Fix race condition in TagAwareAdapter
This commit is contained in:
parent
b87a395025
commit
fa24fa8a3c
@ -250,19 +250,12 @@ class TagAwareAdapter implements TagAwareAdapterInterface
|
|||||||
|
|
||||||
$f = $this->getTagsByKey;
|
$f = $this->getTagsByKey;
|
||||||
$tagsByKey = $f($items);
|
$tagsByKey = $f($items);
|
||||||
$deletedTags = $this->deferred = array();
|
$this->deferred = array();
|
||||||
$tagVersions = $this->getTagVersions($tagsByKey);
|
$tagVersions = $this->getTagVersions($tagsByKey);
|
||||||
$f = $this->createCacheItem;
|
$f = $this->createCacheItem;
|
||||||
|
|
||||||
foreach ($tagsByKey as $key => $tags) {
|
foreach ($tagsByKey as $key => $tags) {
|
||||||
if ($tags) {
|
$this->itemsAdapter->saveDeferred($f(static::TAGS_PREFIX.$key, array_intersect_key($tagVersions, $tags), $items[$key]));
|
||||||
$this->itemsAdapter->saveDeferred($f(static::TAGS_PREFIX.$key, array_intersect_key($tagVersions, $tags), $items[$key]));
|
|
||||||
} else {
|
|
||||||
$deletedTags[] = static::TAGS_PREFIX.$key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($deletedTags) {
|
|
||||||
$this->itemsAdapter->deleteItems($deletedTags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user