/** * Returns cached value by key or false if there is no cache entry for the given key * * @param string $key * @return bool|mixed */ public function get($key) { try { return $this->unserializeCompound($this->cache->get($this->prepareKey($key))->value); } catch (\CouchbaseException $e) { return false; } }
/** * {@inheritdoc} */ public function getMulti(array $keys, array &$tokens = null) { try { $results = $this->client->get($keys); } catch (\CouchbaseException $e) { return array(); } $tokens = array(); foreach ($results as $key => $value) { if ($value->error) { unset($results[$key]); continue; } $results[$key] = $this->unserialize($value->value); $tokens[$key] = $value->cas; } return $results; }
protected function existsInternal($key) { try { $this->storage->get($key); return true; } catch (\CouchbaseException $e) { return false; } }
/** * @param array $keys * @param mixed $var */ public function multiGetAndTouch(array $keys) { try { $metas = $this->bucket->get($keys); KalturaLog::debug("key [" . print_r($keys, true) . "]"); $values = array(); foreach ($keys as $key) { $meta = $metas[$key]; if ($meta->error) { KalturaLog::warning($meta->error->getMessage()); } $values[$key] = $meta->value; } return $values; } catch (CouchbaseException $e) { } return false; }
/** * @param array $keys * @param mixed $var */ public function multiGetAndTouch(array $keys) { try { $metas = $this->bucket->get($keys); if ($this->debug) { KalturaLog::debug("key [" . implode(', ', $keys) . "], metas [" . print_r($metas, true) . "]"); } $values = array(); foreach ($keys as $key) { $meta = $metas[$key]; if ($meta->error) { KalturaLog::warning($meta->error->getMessage()); } $values[$key] = $meta->value; } return $values; } catch (CouchbaseException $e) { if ($e->getCode() == self::ERROR_CODE_THE_KEY_DOES_NOT_EXIST_IN_THE_SERVER) { return false; } throw $e; } }