1<?php 2namespace DALMP\Cache; 3 4/** 5 * APC 6 * 7 * @author Nicolas Embriz <nbari@dalmp.com> 8 * @package DALMP 9 * @license BSD License 10 * @version 3.0.3 11 */ 12class APC implements CacheInterface 13{ 14 protected $cache; 15 16 /** 17 * Constructor 18 * 19 * @param string $host 20 * @param int $port 21 * @param int $timeout 22 * @param int $compress 23 */ 24 public function __construct() 25 { 26 if (!extension_loaded('apc') && !ini_get('apc.enabled')) { 27 throw new \Exception(__CLASS__ . ': APC PECL extension not loaded or enabled!'); 28 } 29 } 30 31 /** 32 * Store data at the server 33 * 34 * @param string $key 35 * @param string $value 36 * @param int $expire time in seconds(default is 0 meaning unlimited) 37 */ 38 public function set($key, $value, $expire = 0) 39 { 40 return apc_store($key, $value, $expire); 41 } 42 43 /** 44 * Retrieve item from the server 45 * 46 * @param string $key 47 */ 48 public function Get($key) 49 { 50 return apc_fetch($key); 51 } 52 53 /** 54 * Delete item from the server 55 * 56 * @param string $key 57 */ 58 public function Delete($key) 59 { 60 return apc_delete($key); 61 } 62 63 /** 64 * Flush cache 65 */ 66 public function Flush() 67 { 68 return apc_clear_cache('user'); 69 } 70 71 /** 72 * Get cache stats 73 */ 74 public function Stats() 75 { 76 return apc_cache_info(); 77 } 78 79 /** 80 * X execute/call custom methods 81 * 82 * @return cache object 83 */ 84 public function X() 85 { 86 return $this; 87 } 88 89} 90