| @@ 143-161 (lines=19) @@ | ||
| 140 | * If stored time is older then modified time, the data is invalid. |
|
| 141 | * @return bool Return true on valid or false on invalid. |
|
| 142 | */ |
|
| 143 | function isValid($key, $modified_time = 0) |
|
| 144 | { |
|
| 145 | $_key = $this->getKey($key); |
|
| 146 | ||
| 147 | $obj = $this->Memcache->get($_key); |
|
| 148 | if(!$obj || !is_array($obj)) |
|
| 149 | { |
|
| 150 | return false; |
|
| 151 | } |
|
| 152 | unset($obj[1]); |
|
| 153 | ||
| 154 | if($modified_time > 0 && $modified_time > $obj[0]) |
|
| 155 | { |
|
| 156 | $this->_delete($_key); |
|
| 157 | return false; |
|
| 158 | } |
|
| 159 | ||
| 160 | return true; |
|
| 161 | } |
|
| 162 | ||
| 163 | /** |
|
| 164 | * Retrieve item from the server |
|
| @@ 173-191 (lines=19) @@ | ||
| 170 | * If stored time is older then modified time, return false. |
|
| 171 | * @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success. |
|
| 172 | */ |
|
| 173 | function get($key, $modified_time = 0) |
|
| 174 | { |
|
| 175 | $_key = $this->getKey($key); |
|
| 176 | $obj = $this->Memcache->get($_key); |
|
| 177 | if(!$obj || !is_array($obj)) |
|
| 178 | { |
|
| 179 | return false; |
|
| 180 | } |
|
| 181 | ||
| 182 | if($modified_time > 0 && $modified_time > $obj[0]) |
|
| 183 | { |
|
| 184 | $this->_delete($_key); |
|
| 185 | return false; |
|
| 186 | } |
|
| 187 | ||
| 188 | unset($obj[0]); |
|
| 189 | ||
| 190 | return $obj[1]; |
|
| 191 | } |
|
| 192 | ||
| 193 | /** |
|
| 194 | * Delete item from the server |
|