/** * Decrease a stored number * * @param string $key * @param int $step * @return int | bool */ public function dec($key, $step = 1) { if (!$this->hasKey($key)) { return false; } return self::$cache->decrBy($this->getNamespace() . $key, $step); }
/** * Compare and delete * * @param string $key * @param mixed $old * @return bool */ public function cad($key, $old) { self::$cache->watch($this->getNamespace() . $key); if ($this->get($key) === $old) { $result = self::$cache->multi()->del($this->getNamespace() . $key)->exec(); return $result === false ? false : true; } self::$cache->unwatch(); return false; }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); if (!\OC\Memcache\Redis::isAvailable()) { self::markTestSkipped('The redis extension is not available.'); } $instance = new \OC\Memcache\Redis(self::getUniqueID()); if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) { self::markTestSkipped('redis server seems to be down.'); } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); if (!\OC\Memcache\Redis::isAvailable()) { self::markTestSkipped('The redis extension is not available.'); } set_error_handler(function ($errno, $errstr) { restore_error_handler(); self::markTestSkipped($errstr); }, E_WARNING); $instance = new \OC\Memcache\Redis(self::getUniqueID()); restore_error_handler(); if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) { self::markTestSkipped('redis server seems to be down.'); } }
public function setTTL($key, $ttl) { self::$cache->expire($this->getNamespace() . $key, $ttl); }
/** * check if there is a memcache backend available * * @return bool */ public function isAvailable() { return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Redis::isAvailable() || Memcached::isAvailable(); }