* @author Mark Samman (Talaturen) * @copyright 2017 MyAAC * @version 0.2.2 * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); class Cache_XCache { private $prefix = ''; private $enabled; public function __construct($prefix = '') { $this->prefix = $prefix; $this->enabled = function_exists('xcache_get') && ini_get('xcache.var_size'); } public function set($key, $var, $ttl = 0) { $key = $this->prefix . $key; xcache_unset($key); xcache_set($key, $var, $ttl); } public function get($key) { $tmp = ''; if($this->fetch($key, $tmp)) return $tmp; return ''; } public function fetch($key, &$var) { $key = $this->prefix . $key; if(!xcache_isset($key)) return false; $var = xcache_get($key); return true; } public function delete($key) { xcache_unset($key); } public function enabled() { return $this->enabled; } } ?>