Exemplo n.º 1
0
 /**
  * Deletes cache entry by key
  *
  * @param string $key
  * @return bool
  */
 public function delete($key)
 {
     try {
         return (bool) $this->cache->remove($this->prepareKey($key));
     } catch (\CouchbaseException $e) {
         return false;
     }
 }
Exemplo n.º 2
0
 protected function removeInternal($key)
 {
     try {
         $this->storage->remove($key);
         return true;
     } catch (\CouchbaseException $e) {
         return false;
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function flush()
 {
     // depending on config & client version, flush may not be available
     try {
         /*
          * Flush wasn't always properly implemented[1] in the client, plus
          * it depends on server config[2] to be enabled. Return status has
          * been null in both success & failure cases.
          * Flush is a very pervasive function that's likely not called
          * lightly. Since it's probably more important to know whether or
          * not it succeeded, than having it execute as fast as possible, I'm
          * going to add some calls and test if flush succeeded.
          *
          * 1: https://forums.couchbase.com/t/php-flush-isnt-doing-anything/1886/8
          * 2: http://docs.couchbase.com/admin/admin/CLI/CBcli/cbcli-bucket-flush.html
          */
         $this->client->upsert('cb-flush-tester', '');
         $manager = $this->client->manager();
         if (method_exists($manager, 'flush')) {
             // ext-couchbase >= 2.0.6
             $manager->flush();
         } elseif (method_exists($this->client, 'flush')) {
             // ext-couchbase < 2.0.6
             $this->client->flush();
         } else {
             return false;
         }
     } catch (\CouchbaseException $e) {
         return false;
     }
     try {
         // cleanup in case flush didn't go through; but if it did, we won't
         // be able to remove it and know flush succeeded
         $result = $this->client->remove('cb-flush-tester');
         return (bool) $result->error;
     } catch (\CouchbaseException $e) {
         // exception: "The key does not exist on the server"
         return true;
     }
 }
Exemplo n.º 4
0
 /**
  * @param array $keys
  * @param boolean
  */
 public function multiDelete(array $keys)
 {
     try {
         $metas = $this->bucket->remove($keys);
         KalturaLog::debug("key [" . print_r($keys, true) . "]");
         return true;
     } catch (CouchbaseException $e) {
         return false;
     }
 }
Exemplo n.º 5
0
 /**
  * @param array $keys
  * @param boolean
  */
 public function multiDelete(array $keys)
 {
     try {
         $metas = $this->bucket->remove($keys);
         if ($this->debug) {
             KalturaLog::debug("key [" . print_r($keys, true) . "]");
         }
         return true;
     } catch (CouchbaseException $e) {
         if ($e->getCode() == self::ERROR_CODE_THE_KEY_DOES_NOT_EXIST_IN_THE_SERVER) {
             return false;
         }
         throw $e;
     }
 }
Exemplo n.º 6
0
 /**
  * Remove cache entries matching any given tags
  * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG
  *
  * @param  array  $tags Array of tags
  * @return boolean true if no problem
  */
 protected function cleanAnyTags(array $tags = [])
 {
     $ids = $this->getIdsMatchingAnyTags($tags);
     $this->cacheBucket->remove($ids);
     return true;
 }