Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00017 final class RuntimeMemory extends CachePeer
00018 {
00019 private $cache = array();
00020
00024 public static function create()
00025 {
00026 return new self;
00027 }
00028
00029 public function isAlive()
00030 {
00031 return true;
00032 }
00033
00034 public function increment($key, $value)
00035 {
00036 if (isset($this->cache[$key]))
00037 return $this->cache[$key] += $value;
00038
00039 return null;
00040 }
00041
00042 public function decrement($key, $value)
00043 {
00044 if (isset($this->cache[$key]))
00045 return $this->cache[$key] -= $value;
00046
00047 return null;
00048 }
00049
00050 public function get($key)
00051 {
00052 if (isset($this->cache[$key]))
00053 return $this->cache[$key];
00054
00055 return null;
00056 }
00057
00058 public function delete($key)
00059 {
00060 if (isset($this->cache[$key])) {
00061 unset($this->cache[$key]);
00062 return true;
00063 }
00064
00065 return false;
00066 }
00067
00071 public function clean()
00072 {
00073 $this->cache = array();
00074
00075 return parent::clean();
00076 }
00077
00078 public function append($key, $data)
00079 {
00080 if (isset($this->cache[$key])) {
00081 $this->cache[$key] .= $data;
00082 return true;
00083 }
00084
00085 return false;
00086 }
00087
00088 protected function store($action, $key, $value, $expires = 0)
00089 {
00090 if ($action == 'add' && isset($this->cache[$key]))
00091 return true;
00092 elseif ($action == 'replace' && !isset($this->cache[$key]))
00093 return false;
00094
00095 if (is_object($value))
00096 $this->cache[$key] = clone $value;
00097 else
00098 $this->cache[$key] = $value;
00099
00100 return true;
00101 }
00102 }
00103 ?>