@@ 113-126 (lines=14) @@ | ||
110 | * @param string $key Key |
|
111 | * @return object Item |
|
112 | */ |
|
113 | public function get($key) |
|
114 | { |
|
115 | $k = $this->hash($key); |
|
116 | if (!isset($this->cache[$k])) { |
|
117 | return null; |
|
118 | } |
|
119 | $item = $this->cache[$k]; |
|
120 | if (isset($item->expire)) { |
|
121 | if (microtime(true) >= $item->expire) { |
|
122 | unset($this->cache[$k]); |
|
123 | return null; |
|
124 | } |
|
125 | } |
|
126 | return $item; |
|
127 | } |
|
128 | ||
129 | /** |
|
@@ 134-147 (lines=14) @@ | ||
131 | * @param string $key Key |
|
132 | * @return mixed |
|
133 | */ |
|
134 | public function getValue($key) |
|
135 | { |
|
136 | $k = $this->hash($key); |
|
137 | if (!isset($this->cache[$k])) { |
|
138 | return null; |
|
139 | } |
|
140 | $item = $this->cache[$k]; |
|
141 | if (isset($item->expire)) { |
|
142 | if (microtime(true) >= $item->expire) { |
|
143 | unset($this->cache[$k]); |
|
144 | return null; |
|
145 | } |
|
146 | } |
|
147 | return $item->getValue(); |
|
148 | } |
|
149 | } |
|
150 |