File indexing completed on 2024-06-16 05:29:53

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Cache
0017  * @subpackage Zend_Cache_Backend
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Cache_Backend_Interface
0025  */
0026 // require_once 'Zend/Cache/Backend/ExtendedInterface.php';
0027 
0028 /**
0029  * @see Zend_Cache_Backend
0030  */
0031 // require_once 'Zend/Cache/Backend.php';
0032 
0033 /**
0034  * @package    Zend_Cache
0035  * @subpackage Zend_Cache_Backend
0036  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0037  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0038  */
0039 class Zend_Cache_Backend_BlackHole
0040     extends Zend_Cache_Backend
0041     implements Zend_Cache_Backend_ExtendedInterface
0042 {
0043     /**
0044      * Test if a cache is available for the given id and (if yes) return it (false else)
0045      *
0046      * @param  string $id cache id
0047      * @param  boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
0048      * @return string|false cached datas
0049      */
0050     public function load($id, $doNotTestCacheValidity = false)
0051     {
0052         return false;
0053     }
0054 
0055     /**
0056      * Test if a cache is available or not (for the given id)
0057      *
0058      * @param  string $id cache id
0059      * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
0060      */
0061     public function test($id)
0062     {
0063         return false;
0064     }
0065 
0066     /**
0067      * Save some string datas into a cache record
0068      *
0069      * Note : $data is always "string" (serialization is done by the
0070      * core not by the backend)
0071      *
0072      * @param  string $data             Datas to cache
0073      * @param  string $id               Cache id
0074      * @param  array  $tags             Array of strings, the cache record will be tagged by each string entry
0075      * @param  int    $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
0076      * @return boolean true if no problem
0077      */
0078     public function save($data, $id, $tags = array(), $specificLifetime = false)
0079     {
0080         return true;
0081     }
0082 
0083     /**
0084      * Remove a cache record
0085      *
0086      * @param  string $id cache id
0087      * @return boolean true if no problem
0088      */
0089     public function remove($id)
0090     {
0091         return true;
0092     }
0093 
0094     /**
0095      * Clean some cache records
0096      *
0097      * Available modes are :
0098      * 'all' (default)  => remove all cache entries ($tags is not used)
0099      * 'old'            => remove too old cache entries ($tags is not used)
0100      * 'matchingTag'    => remove cache entries matching all given tags
0101      *                     ($tags can be an array of strings or a single string)
0102      * 'notMatchingTag' => remove cache entries not matching one of the given tags
0103      *                     ($tags can be an array of strings or a single string)
0104      * 'matchingAnyTag' => remove cache entries matching any given tags
0105      *                     ($tags can be an array of strings or a single string)
0106      *
0107      * @param  string $mode clean mode
0108      * @param  tags array $tags array of tags
0109      * @return boolean true if no problem
0110      */
0111     public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
0112     {
0113         return true;
0114     }
0115 
0116     /**
0117      * Return an array of stored cache ids
0118      *
0119      * @return array array of stored cache ids (string)
0120      */
0121     public function getIds()
0122     {
0123         return array();
0124     }
0125 
0126     /**
0127      * Return an array of stored tags
0128      *
0129      * @return array array of stored tags (string)
0130      */
0131     public function getTags()
0132     {
0133         return array();
0134     }
0135 
0136     /**
0137      * Return an array of stored cache ids which match given tags
0138      *
0139      * In case of multiple tags, a logical AND is made between tags
0140      *
0141      * @param array $tags array of tags
0142      * @return array array of matching cache ids (string)
0143      */
0144     public function getIdsMatchingTags($tags = array())
0145     {
0146         return array();
0147     }
0148 
0149     /**
0150      * Return an array of stored cache ids which don't match given tags
0151      *
0152      * In case of multiple tags, a logical OR is made between tags
0153      *
0154      * @param array $tags array of tags
0155      * @return array array of not matching cache ids (string)
0156      */
0157     public function getIdsNotMatchingTags($tags = array())
0158     {
0159         return array();
0160     }
0161 
0162     /**
0163      * Return an array of stored cache ids which match any given tags
0164      *
0165      * In case of multiple tags, a logical AND is made between tags
0166      *
0167      * @param  array $tags array of tags
0168      * @return array array of any matching cache ids (string)
0169      */
0170     public function getIdsMatchingAnyTags($tags = array())
0171     {
0172         return array();
0173     }
0174 
0175     /**
0176      * Return the filling percentage of the backend storage
0177      *
0178      * @return int integer between 0 and 100
0179      * @throws Zend_Cache_Exception
0180      */
0181     public function getFillingPercentage()
0182     {
0183         return 0;
0184     }
0185 
0186     /**
0187      * Return an array of metadatas for the given cache id
0188      *
0189      * The array must include these keys :
0190      * - expire : the expire timestamp
0191      * - tags : a string array of tags
0192      * - mtime : timestamp of last modification time
0193      *
0194      * @param  string $id cache id
0195      * @return array array of metadatas (false if the cache id is not found)
0196      */
0197     public function getMetadatas($id)
0198     {
0199         return false;
0200     }
0201 
0202     /**
0203      * Give (if possible) an extra lifetime to the given cache id
0204      *
0205      * @param  string $id cache id
0206      * @param  int $extraLifetime
0207      * @return boolean true if ok
0208      */
0209     public function touch($id, $extraLifetime)
0210     {
0211         return false;
0212     }
0213 
0214     /**
0215      * Return an associative array of capabilities (booleans) of the backend
0216      *
0217      * The array must include these keys :
0218      * - automatic_cleaning (is automating cleaning necessary)
0219      * - tags (are tags supported)
0220      * - expired_read (is it possible to read expired cache records
0221      *                 (for doNotTestCacheValidity option for example))
0222      * - priority does the backend deal with priority when saving
0223      * - infinite_lifetime (is infinite lifetime can work with this backend)
0224      * - get_list (is it possible to get the list of cache ids and the complete list of tags)
0225      *
0226      * @return array associative of with capabilities
0227      */
0228     public function getCapabilities()
0229     {
0230         return array(
0231             'automatic_cleaning' => true,
0232             'tags'               => true,
0233             'expired_read'       => true,
0234             'priority'           => true,
0235             'infinite_lifetime'  => true,
0236             'get_list'           => true,
0237         );
0238     }
0239 
0240     /**
0241      * PUBLIC METHOD FOR UNIT TESTING ONLY !
0242      *
0243      * Force a cache record to expire
0244      *
0245      * @param string $id cache id
0246      */
0247     public function ___expire($id)
0248     {
0249     }
0250 }