Array.php

Go to the documentation of this file.
00001 <?php
00002 
00034 class Robo47_Cache_Backend_Array extends Zend_Cache_Backend
00035 implements Zend_Cache_Backend_ExtendedInterface
00036 {
00037 
00043     public $data = array();
00044 
00057     public function load($id, $doNotTestCacheValidity = false)
00058     {
00059         if (isset($this->data[$id])) {
00060             return $this->data[$id];
00061         } else {
00062             return false;
00063         }
00064     }
00065 
00073     public function test($id)
00074     {
00075         if (isset($this->data[$id])) {
00076             return true;
00077         } else {
00078             return false;
00079         }
00080     }
00081 
00097     public function save($data, $id, $tags = array(), $specificLifetime = false)
00098     {
00099         $this->data[$id] = $data;
00100         return true;
00101     }
00102 
00109     public function remove($id)
00110     {
00111         if (isset($this->data[$id])) {
00112             unset($this->data[$id]);
00113             return true;
00114         } else {
00115             return false;
00116         }
00117     }
00118 
00126     public function clean($mode = Zend_Cache::CLEANING_MODE_ALL,
00127         $tags = array())
00128     {
00129         switch ($mode) {
00130             case Zend_Cache::CLEANING_MODE_ALL:
00131                 $this->data = array();
00132                 break;
00133             case Zend_Cache::CLEANING_MODE_OLD:
00134             case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
00135             case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
00136             case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
00137                 $message = 'Mode ' . $mode . ' not supported';
00138                 throw new Robo47_Cache_Backend_Exception($message);
00139                 break;
00140             default:
00141                 $message = 'Unknown mode ' . $mode;
00142                 throw new Robo47_Cache_Backend_Exception($message);
00143                 break;
00144         }
00145         return true;
00146     }
00147 
00153     public function getIds()
00154     {
00155         return array_keys($this->data);
00156     }
00157 
00163     public function getTags()
00164     {
00165         return array();
00166     }
00167 
00176     public function getIdsMatchingTags($tags = array())
00177     {
00178         return array();
00179     }
00180 
00189     public function getIdsNotMatchingTags($tags = array())
00190     {
00191         return array();
00192     }
00193 
00202     public function getIdsMatchingAnyTags($tags = array())
00203     {
00204         return array();
00205     }
00206 
00212     public function getFillingPercentage()
00213     {
00214         return 0;
00215     }
00216 
00228     public function getMetadatas($id)
00229     {
00230         return false;
00231     }
00232 
00240     public function touch($id, $extraLifetime)
00241     {
00242         return false;
00243     }
00244 
00259     public function getCapabilities()
00260     {
00261         return array(
00262             'automatic_cleaning' => false,
00263             'tags' => false,
00264             'expired_read' => false,
00265             'priority' => false,
00266             'infinite_lifetime' => false,
00267             'get_list' => false
00268         );
00269     }
00270 }