12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php namespace System\Cache\Driver;
- class File implements \System\Cache\Driver {
-
- public $items = array();
-
- public function has($key)
- {
- return ( ! is_null($this->get($key)));
- }
-
-
- public function get($key)
- {
- if ( ! file_exists(APP_PATH.'storage/cache/'.$key))
- {
- return null;
- }
- $cache = file_get_contents(APP_PATH.'storage/cache/'.$key);
- if (time() >= substr($cache, 0, 10))
- {
- $this->forget($key);
- return null;
- }
- return $this->items[$key] = unserialize(substr($cache, 10));
- }
-
- public function put($key, $value, $minutes)
- {
- file_put_contents(APP_PATH.'storage/cache/'.$key, (time() + ($minutes * 60)).serialize($value), LOCK_EX);
- }
-
- public function forget($key)
- {
- @unlink(APP_PATH.'storage/cache/'.$key);
- }
- }
|