Skip to content
Snippets Groups Projects
Unverified Commit 1e5444e1 authored by Alex Pott's avatar Alex Pott
Browse files

Minor optimisation

parent 6514d9fb
No related branches found
No related tags found
No related merge requests found
......@@ -88,12 +88,14 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []):
* {@inheritdoc}
*/
public function invalidate($cid): void {
parent::invalidate($cid);
// Move the item to the least recently used position if it's not already
// there. This cannot use array_unshift() because it would reindex an array
// with numeric cache IDs.
if (isset($this->cache[$cid]) && $cid !== array_key_first($this->cache)) {
$this->cache = [$cid => $this->cache[$cid]] + $this->cache;
if (isset($this->cache[$cid])) {
parent::invalidate($cid);
// Move the item to the least recently used position if it's not already
// there. This cannot use array_unshift() because it would reindex an array
// with numeric cache IDs.
if ($cid !== array_key_first($this->cache)) {
$this->cache = [$cid => $this->cache[$cid]] + $this->cache;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment