Issues

ZF-4681: New cleaning mode CLEANING_MODE_MATCHING_ANY_TAG

Issue Type: New Feature Created: 2008-10-22T11:00:30.000+0000 Last Updated: 2012-03-16T06:49:15.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Krzysztof Szatanik (diabl0) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Cache

Related issues: - ZF-4727

Attachments:

Description

Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG mode for cache clean method that will remove all cache items containing any tag passed to clean method.

For Zend_Cache_Backend_File

<pre class="highlight"> 
Index: Zend/Cache.php
===================================================================
--- Zend/Cache.php  (revision 12080)
+++ Zend/Cache.php  (working copy)
@@ -72,6 +72,7 @@
     const CLEANING_MODE_OLD              = 'old';
     const CLEANING_MODE_MATCHING_TAG     = 'matchingTag';
     const CLEANING_MODE_NOT_MATCHING_TAG = 'notMatchingTag';
+    const CLEANING_MODE_MATCHING_ANY_TAG = 'MatchingAnyTag';
 
     /**
      * Factory
Index: Zend/Cache/Core.php
===================================================================
--- Zend/Cache/Core.php (revision 12080)
+++ Zend/Cache/Core.php (working copy)
@@ -416,7 +416,7 @@
         if (!$this->_options['caching']) {
             return true;
         }
-        if (!in_array($mode, array(Zend_Cache::CLEANING_MODE_ALL, Zend_Cache::CLEANING_MODE_OLD, Zend_Cache::CLEANING_MODE_MATCHING_TAG, Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG))) {
+        if (!in_array($mode, array(Zend_Cache::CLEANING_MODE_ALL, Zend_Cache::CLEANING_MODE_OLD, Zend_Cache::CLEANING_MODE_MATCHING_TAG, Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG, Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG))) {
             Zend_Cache::throwException('Invalid cleaning mode');
         }
         self::_validateTagsArray($tags);
Index: Zend/Cache/Backend/File.php
===================================================================
--- Zend/Cache/Backend/File.php (revision 12080)
+++ Zend/Cache/Backend/File.php (working copy)
@@ -682,6 +682,14 @@
                             $result = ($result) && $this->remove($id);
                         }
                         break;
+                   case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
+                        foreach ($tags as $tag) {
+                            if (in_array($tag, $metadatas['tags'])) {
+                                $result = ($result) && $this->remove($id);
+                                break 2;
+                            }
+                        }
+                        break;                        
                     default:
                         Zend_Cache::throwException('Invalid mode for clean() method');
                         break;

Comments

Posted by Fabien MARTY (fab) on 2008-10-23T01:54:23.000+0000

now, you can do call CLEANING_MODE_MATCHING_TAG each time (tag by tag) in your code

but why not, it sounds as a good idea

Posted by Krzysztof Szatanik (diabl0) on 2008-10-23T03:45:43.000+0000

Suppose you have 3 items with tags:

'item_1', array( 'items', 'item_1' ); 'item_2', array( 'items', 'item_2' ); 'photo_121', array( 'photos', 'item_1', 'photo_121');

With CLEANING_MODE_MATCHING_TAG you can't easy delete all cache items by only 'item_1' tag.

Posted by old of Satoru Yoshida (yoshida@zend.co.jp) on 2008-11-08T00:23:00.000+0000

All of sub task and this issue is solved in SVN r12415

Posted by Fabien MARTY (fab) on 2008-11-08T05:53:33.000+0000

really good work !

Posted by old of Satoru Yoshida (yoshida@zend.co.jp) on 2008-11-09T19:34:22.000+0000

Thank you ;-)

Posted by Wil Sinclair (wil) on 2008-11-13T14:10:12.000+0000

Changing issues in preparation for the 1.7.0 release.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts