/** * Quick memcache interaction helper has transaction support using \Sky\Memcache * Sample Usage: * mem('myKey', $myValue); // srite my key/value pair to memcache * echo mem('myKey'); // read the value stored in 'myKey' and echo it * mem('myKey', null); // delete myKey from memcache * * @param mixed $key can be a string or an array of strings * @param mixed $value if not set, will be a read, if null, delete, else set * @param string $duration how long you want to store the value, ex: '10 minutes' * @return mixed */ function mem($key, $value = '§k¥', $duration = null) { if ($value == '§k¥') { return \Sky\Memcache::get($key); } else { if (!is_null($value)) { return \Sky\Memcache::set($key, $value, $duration); } else { return \Sky\Memcache::delete($key); } } }
/** * Caches the current state of the object */ public function updateCache() { $this->_cached_time = date('c'); \Sky\Memcache::set($this->getMemKey(), $this); }