/** * Sets a data cache * * @param string the key to the data * @param variable the data to be cached * @param int MemCache flag * @param int expire * @return bool */ public function set($key, $data, $flag = NULL, $expire = NULL) { //argument test Eden_Memcache_Error::i()->argument(1, 'string')->argument(3, 'int', 'null')->argument(4, 'int', 'null'); //Argument 4 must be an integer or null $this->_memcache->set($key, $data, $flag, $expire); return $this; }
if(!class_exists('Eden_Memcache')){class Eden_Memcache extends Eden_Class{protected $_memcache=NULL;public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($host='localhost',$port=11211,$timeout=1){$error=Eden_Memcache_Error::i()->argument(1,'string')->argument(2,'int')->argument(3,'int');if(!class_exists('Memcached')){$error->setMessage(Eden_Memcache_Error::NOT_INSTALLED)->trigger();}try{$this->_memcache=new Memcached;}catch(Exception $e){$error->setMessage(Eden_Memcache_Error::NOT_INSTALLED)->trigger();}$this->_memcache->connect($host,$port,$timeout);return $this;}public function __destruct(){if(!is_null($this->_memcache)){$this->_memcache->close();$this->_memcache=NULL;}}public function addServer($host='localhost',$port=11211,$persistent=true,$weight=NULL,$timeout=1){Eden_Memcache_Error::i()->argument(1,'string')->argument(2,'int')->argument(3,'bool')->argument(4,'int','null')->argument(5,'int');$this->_memcache->addServer($host,$port,$persistent,$weight,$timeout);return $this;}public function clear(){$this->_memcache->flush();return $this;}public function get($key,$flag=NULL){Eden_Memcache_Error::i()->argument(1,'string','array')->argument(2,'int','null');return $this->_memcache->get($key,$flag);}public function remove($key){Eden_Memcache_Error::i()->argument(1,'string','array');$this->_memcache->delete($key);return $this;}public function set($key,$data,$flag=NULL,$expire=NULL){Eden_Memcache_Error::i()->argument(1,'string')->argument(3,'int','null')->argument(4,'int','null');$this->_memcache->set($key,$data,$flag,$expire);return $this;}}class Eden_Memcache_Error extends Eden_Error{const NOT_INSTALLED='Memcache is not installed.';public static function i($message=NULL,$code=0){$class=__CLASS__;return new $class($message,$code);}}}
/** * deletes data of a cache * * @param string the key to the data * @return this */ public function remove($key) { //Argument 1 must be a string or array Eden_Memcache_Error::i()->argument(1, 'string', 'array'); apc_delete($key); return $this; }
public function set($key, $data, $flag = NULL, $expire = NULL) { Eden_Memcache_Error::i()->argument(1, 'string')->argument(3, 'int', 'null')->argument(4, 'int', 'null'); $this->_memcache->set($key, $data, $flag, $expire); return $this; }