Skip to content

Commit

Permalink
Merge pull request #8 from ethaizone/patch-1
Browse files Browse the repository at this point in the history
[Critical] Bug when model want to purge multi tags and key lose before send to delete.
  • Loading branch information
spiritix committed Mar 21, 2016
2 parents b988084 + 36cd596 commit 3133700
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Spiritix/LadaCache/Invalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private function getHashes(array $tags)
continue;
}

$hashes += $this->redis->smembers($tag);
$hashes = array_merge($hashes, $this->redis->smembers($tag));
}

return array_unique($hashes);
Expand All @@ -88,4 +88,4 @@ private function deleteItems(array $items)
$this->redis->del($item);
}
}
}
}
12 changes: 11 additions & 1 deletion tests/InvalidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ public function testInvalidate()

$this->assertFalse($this->cache->has('key'));
}
}

public function testInvalidateMultiTags()
{
$this->cache->set('key1', ['tag1'], 'data');
$this->cache->set('key2', ['tag2'], 'data');

$this->invalidator->invalidate(['tag1', 'tag2']);

$this->assertFalse($this->cache->has('key2'));
}
}

0 comments on commit 3133700

Please sign in to comment.