/** * Return the value from the couch cluster * * @param $bucket * @param $key * @return array|bool */ function getItemFromCache($bucket, $key) { $cluster = $this->couch; $bucket = $cluster->openBucket($bucket); try { $countries= $bucket->get($key); return (array)$countries->value; } catch (Exception $e) { return false; } } /** * Save item to couch cluster * * @param $bucket * @param $key * @param $item * @param array $options * @return bool * @internal param array */ function storeItemToCache($bucket, $key, $item, $options=array() ) { $cluster = $this->couch; $bucket = $cluster->openBucket($bucket); return $bucket->upsert($key, $item, $options); } /** * Couch Counter Return the value and increment in the same time * * @param $bucket * @param $key * @param int $step * @param array $options * @return mixed */ function counterToCache($bucket, $key, $step = 1, $options=array('initial' => 1) ) { $cluster = $this->couch; $bucket = $cluster->openBucket($bucket); return $bucket->counter($key, $step, $options)->value; } /** * Return the value of a counter * * @param $bucket * @param $key * @return bool */ function getCounterFromCache($bucket, $key ) { $cluster = $this->couch; $bucket = $cluster->openBucket($bucket); try { return $bucket->get($key)->value; } catch (Exception $e) { return false; } } /** * Delete the value from the couch cluster * * @param $bucket * @param $key * @return bool */ function deleteItemFromCache($bucket, $key) { $cluster = $this->couch; $bucket = $cluster->openBucket($bucket); return $bucket->remove($key); }