BlackHole.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Cache
  17. * @subpackage Zend_Cache_Backend
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Cache_Backend_Interface
  24. */
  25. #require_once 'Zend/Cache/Backend/ExtendedInterface.php';
  26. /**
  27. * @see Zend_Cache_Backend
  28. */
  29. #require_once 'Zend/Cache/Backend.php';
  30. /**
  31. * @package Zend_Cache
  32. * @subpackage Zend_Cache_Backend
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Cache_Backend_BlackHole
  37. extends Zend_Cache_Backend
  38. implements Zend_Cache_Backend_ExtendedInterface
  39. {
  40. /**
  41. * Test if a cache is available for the given id and (if yes) return it (false else)
  42. *
  43. * @param string $id cache id
  44. * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
  45. * @return string|false cached datas
  46. */
  47. public function load($id, $doNotTestCacheValidity = false)
  48. {
  49. return false;
  50. }
  51. /**
  52. * Test if a cache is available or not (for the given id)
  53. *
  54. * @param string $id cache id
  55. * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
  56. */
  57. public function test($id)
  58. {
  59. return false;
  60. }
  61. /**
  62. * Save some string datas into a cache record
  63. *
  64. * Note : $data is always "string" (serialization is done by the
  65. * core not by the backend)
  66. *
  67. * @param string $data Datas to cache
  68. * @param string $id Cache id
  69. * @param array $tags Array of strings, the cache record will be tagged by each string entry
  70. * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  71. * @return boolean true if no problem
  72. */
  73. public function save($data, $id, $tags = array(), $specificLifetime = false)
  74. {
  75. return true;
  76. }
  77. /**
  78. * Remove a cache record
  79. *
  80. * @param string $id cache id
  81. * @return boolean true if no problem
  82. */
  83. public function remove($id)
  84. {
  85. return true;
  86. }
  87. /**
  88. * Clean some cache records
  89. *
  90. * Available modes are :
  91. * 'all' (default) => remove all cache entries ($tags is not used)
  92. * 'old' => remove too old cache entries ($tags is not used)
  93. * 'matchingTag' => remove cache entries matching all given tags
  94. * ($tags can be an array of strings or a single string)
  95. * 'notMatchingTag' => remove cache entries not matching one of the given tags
  96. * ($tags can be an array of strings or a single string)
  97. * 'matchingAnyTag' => remove cache entries matching any given tags
  98. * ($tags can be an array of strings or a single string)
  99. *
  100. * @param string $mode clean mode
  101. * @param tags array $tags array of tags
  102. * @return boolean true if no problem
  103. */
  104. public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
  105. {
  106. return true;
  107. }
  108. /**
  109. * Return an array of stored cache ids
  110. *
  111. * @return array array of stored cache ids (string)
  112. */
  113. public function getIds()
  114. {
  115. return array();
  116. }
  117. /**
  118. * Return an array of stored tags
  119. *
  120. * @return array array of stored tags (string)
  121. */
  122. public function getTags()
  123. {
  124. return array();
  125. }
  126. /**
  127. * Return an array of stored cache ids which match given tags
  128. *
  129. * In case of multiple tags, a logical AND is made between tags
  130. *
  131. * @param array $tags array of tags
  132. * @return array array of matching cache ids (string)
  133. */
  134. public function getIdsMatchingTags($tags = array())
  135. {
  136. return array();
  137. }
  138. /**
  139. * Return an array of stored cache ids which don't match given tags
  140. *
  141. * In case of multiple tags, a logical OR is made between tags
  142. *
  143. * @param array $tags array of tags
  144. * @return array array of not matching cache ids (string)
  145. */
  146. public function getIdsNotMatchingTags($tags = array())
  147. {
  148. return array();
  149. }
  150. /**
  151. * Return an array of stored cache ids which match any given tags
  152. *
  153. * In case of multiple tags, a logical AND is made between tags
  154. *
  155. * @param array $tags array of tags
  156. * @return array array of any matching cache ids (string)
  157. */
  158. public function getIdsMatchingAnyTags($tags = array())
  159. {
  160. return array();
  161. }
  162. /**
  163. * Return the filling percentage of the backend storage
  164. *
  165. * @return int integer between 0 and 100
  166. * @throws Zend_Cache_Exception
  167. */
  168. public function getFillingPercentage()
  169. {
  170. return 0;
  171. }
  172. /**
  173. * Return an array of metadatas for the given cache id
  174. *
  175. * The array must include these keys :
  176. * - expire : the expire timestamp
  177. * - tags : a string array of tags
  178. * - mtime : timestamp of last modification time
  179. *
  180. * @param string $id cache id
  181. * @return array array of metadatas (false if the cache id is not found)
  182. */
  183. public function getMetadatas($id)
  184. {
  185. return false;
  186. }
  187. /**
  188. * Give (if possible) an extra lifetime to the given cache id
  189. *
  190. * @param string $id cache id
  191. * @param int $extraLifetime
  192. * @return boolean true if ok
  193. */
  194. public function touch($id, $extraLifetime)
  195. {
  196. return false;
  197. }
  198. /**
  199. * Return an associative array of capabilities (booleans) of the backend
  200. *
  201. * The array must include these keys :
  202. * - automatic_cleaning (is automating cleaning necessary)
  203. * - tags (are tags supported)
  204. * - expired_read (is it possible to read expired cache records
  205. * (for doNotTestCacheValidity option for example))
  206. * - priority does the backend deal with priority when saving
  207. * - infinite_lifetime (is infinite lifetime can work with this backend)
  208. * - get_list (is it possible to get the list of cache ids and the complete list of tags)
  209. *
  210. * @return array associative of with capabilities
  211. */
  212. public function getCapabilities()
  213. {
  214. return array(
  215. 'automatic_cleaning' => true,
  216. 'tags' => true,
  217. 'expired_read' => true,
  218. 'priority' => true,
  219. 'infinite_lifetime' => true,
  220. 'get_list' => true,
  221. );
  222. }
  223. /**
  224. * PUBLIC METHOD FOR UNIT TESTING ONLY !
  225. *
  226. * Force a cache record to expire
  227. *
  228. * @param string $id cache id
  229. */
  230. public function ___expire($id)
  231. {
  232. }
  233. }