Permalink
Browse files

* Erasing the tags file after clearing by tag

  • Loading branch information...
1 parent f572d1b commit 7ef6313313775e6ab287806b94f184b76cd4cc2d @cpojer committed Aug 5, 2010
Showing with 8 additions and 0 deletions.
  1. +8 −0 Source/Cache.php
View
8 Source/Cache.php
@@ -13,6 +13,7 @@ function write($file, $content = '', $flags = 0){
$directory = dirname($file);
if (!is_dir($directory)){
$mask = umask(0);
+
mkdir($directory, 0777, true);
umask($mask);
}
@@ -134,6 +135,7 @@ public function erase($keys){
public function eraseByTag($tag){
$keys = $this->getKeysByTag($tag);
if (count($keys)) $this->erase($keys);
+ $this->eraseTag($tag);
return $this;
}
@@ -143,6 +145,8 @@ public function eraseByTags($tags){
foreach($tags as $tag){
$list = $this->getKeysByTag($tag);
$keys = empty($keys) ? $list : array_intersect($keys, $list);
+
+ $this->eraseTag($tag);
}
return $this->erase($keys);
@@ -181,6 +185,10 @@ protected function addKeyToTags($key, $tags){
foreach ($tags as $tag)
$this->addKeyToTag($key, $tag);
}
+
+ protected function eraseTag($tag){
+ unlink($this->getTagFolder() . $tag);
+ }
// Static
public static function register($engine){

0 comments on commit 7ef6313

Please sign in to comment.