ZF-10507: Add cancel function for Zend_Cache_Frontend_Capture

Description

A cancel function like in Zend_Cache_Frontend_Page is very usefull. I have done one in my extended ZF library. I propose here the patch :



Index: Capture.php
===================================================================
--- Capture.php (revision 23007)
+++ Capture.php (working copy)
@@ -49,6 +49,13 @@
     protected $_extension = null;
 
     /**
+     * If true, the page won't be cached
+     *
+     * @var boolean
+     */
+    protected $_cancel = false;
+    
+    /**
      * Start the cache
      *
      * @param  string  $id Cache id
@@ -65,6 +72,14 @@
     }
 
     /**
+     * Cancel the current caching process
+     */
+    public function cancel()
+    {
+        $this->_cancel = true;
+    }
+    
+    /**
      * callback for output buffering
      * (shouldn't really be called manually)
      *
@@ -73,6 +88,10 @@
      */
     public function _flush($data)
     {
+        if ($this->_cancel) {
+            return $data;
+        }
+        
         $id = array_pop($this->_idStack);
         if (is_null($id)) {
             Zend_Cache::throwException('use of _flush() without a start()');

Comments

assigned to pádraic