Example #1
0
 /**
  * @throws \Exception
  */
 private function verifyReturnCode()
 {
     $code = self::$cache->getResultCode();
     if ($code === \Memcached::RES_SUCCESS) {
         return;
     }
     $message = self::$cache->getResultMessage();
     throw new \Exception("Error {$code} interacting with memcached : {$message}");
 }
Example #2
0
 public static function setUpBeforeClass()
 {
     if (!\OC\Memcache\Memcached::isAvailable()) {
         self::markTestSkipped('The memcached extension is not available.');
     }
     $instance = new \OC\Memcache\Memcached(uniqid());
     if ($instance->set(uniqid(), uniqid()) === false) {
         self::markTestSkipped('memcached server seems to be down.');
     }
 }
Example #3
0
 /**
  * Decrease a stored number
  *
  * @param string $key
  * @param int $step
  * @return int | bool
  */
 public function dec($key, $step = 1)
 {
     return self::$cache->decrement($this->getPrefix() . $key, $step);
 }
Example #4
0
 /**
  * check if there is a memcache backend available
  *
  * @return bool
  */
 public function isAvailable()
 {
     return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Memcached::isAvailable();
 }