00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00020 final class RuntimeMemory extends CachePeer
00021 {
00022 private $cache = array();
00023
00027 public static function create()
00028 {
00029 return new self;
00030 }
00031
00032 public function isAlive()
00033 {
00034 return true;
00035 }
00036
00037 public function get($key)
00038 {
00039 if (isset($this->cache[$key]))
00040 return $this->cache[$key];
00041
00042 return null;
00043 }
00044
00045 public function delete($key)
00046 {
00047 if (isset($this->cache[$key])) {
00048 unset($this->cache[$key]);
00049 return true;
00050 }
00051
00052 return false;
00053 }
00054
00058 public function clean()
00059 {
00060 $this->cache = array();
00061
00062 return parent::clean();
00063 }
00064
00065 protected function store($action, $key, &$value, $expires = 0)
00066 {
00067 if ($action == 'add' && isset($this->cache[$key]))
00068 return true;
00069 elseif ($action == 'replace' && !isset($this->cache[$key]))
00070 return false;
00071
00072 $this->cache[$key] = $value;
00073 return true;
00074 }
00075 }
00076 ?>