Ejemplo n.º 1
0
 /**
  * Deletes all cache entries
  *
  * @return bool
  */
 public function clear()
 {
     try {
         $this->cache->manager()->flush();
         return true;
     } catch (\CouchbaseException $e) {
         return false;
     }
 }
Ejemplo n.º 2
0
 protected function removeInternal($key)
 {
     try {
         $this->storage->remove($key);
         return true;
     } catch (\CouchbaseException $e) {
         return false;
     }
 }
Ejemplo 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;
     }
 }
Ejemplo n.º 4
0
 /**
  * @param array $keys
  * @param mixed $var
  * @return kCouchbaseCacheList
  */
 public function query(kCouchbaseCacheQuery $query)
 {
     $couchBaseQuery = $query->toQuery();
     $meta = $this->bucket->query($couchBaseQuery);
     return new kCouchbaseCacheList($meta);
 }
Ejemplo n.º 5
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;
 }