apc.php (796B)
1 <?php 2 namespace Cache; 3 class APC { 4 private $expire; 5 private $active = false; 6 7 public function __construct($expire) { 8 $this->expire = $expire; 9 $this->active = function_exists('apc_cache_info') && ini_get('apc.enabled'); 10 } 11 12 public function get($key) { 13 return $this->active ? apc_fetch(CACHE_PREFIX . $key) : false; 14 } 15 16 public function set($key, $value) { 17 return $this->active ? apc_store(CACHE_PREFIX . $key, $value, $this->expire) : false; 18 } 19 20 public function delete($key) { 21 if (!$this->active) { 22 return false; 23 } 24 25 $cache_info = apc_cache_info('user'); 26 $cache_list = $cache_info['cache_list']; 27 foreach ($cache_list as $entry) { 28 if (strpos($entry['info'], CACHE_PREFIX . $key) === 0) { 29 apcu_delete($entry['info']); 30 } 31 } 32 } 33 }