本文整理汇总了PHP中Memcached::getResultCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::getResultCode方法的具体用法?PHP Memcached::getResultCode怎么用?PHP Memcached::getResultCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::getResultCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: has
/**
* {@inheritdoc}
*/
public function has($name)
{
if ($this->driver->get($name) === false) {
return $this->driver->getResultCode() != \Memcached::RES_NOTFOUND;
}
return true;
}
示例2: get
/**
* Retrieve an item from the cache by key.
*
* @param string $key
* @return mixed
*/
public function get($key)
{
$value = $this->memcached->get($this->prefix . $key);
if ($this->memcached->getResultCode() == 0) {
return $value;
}
}
示例3: exists
/**
* {@inheritdoc}
*/
public function exists()
{
if (false === $this->memcached->get($this->storeId)) {
return MemcachedClient::RES_SUCCESS === $this->memcached->getResultCode();
}
return true;
}
示例4: testInvalidate
/**
* @group memcached
*/
public function testInvalidate()
{
$mc = new MemcachedCacheBackend();
$mc->addServer(new MemcachedServer(self::TEST_MEMCACHE_SERVER));
$mc->invalidate('test');
$this->assertFalse($this->memcache->get('test'));
$this->assertEquals(\Memcached::RES_NOTFOUND, $this->memcache->getResultCode());
}
示例5: get
/**
* @param string $key
* @return mixed|null
*/
public function get($key)
{
$result = $this->memcache->get($key);
if ($this->memcache->getResultCode() === \Memcached::RES_NOTFOUND) {
return NULL;
}
return $result;
}
示例6: get
/**
* Get item
* @param string $namespace
* @param string $key
* @return mixed stored item
*/
public function get($namespace, $key)
{
$store_key = $this->getStoreKey($namespace, $key);
$value = $this->connect->get($store_key);
if ($this->connect->getResultCode() == \Memcached::RES_NOTFOUND) {
return null;
}
return $value;
}
示例7: get
public function get($id)
{
$flags = null;
$result = @$this->memcached->get($id);
if (false === $result && \Memcached::RES_NOTFOUND == $this->memcached->getResultCode()) {
return null;
}
return $result;
}
示例8: delete
public function delete($key)
{
$this->memcachedObj->delete($key);
$resultCode = $this->memcachedObj->getResultCode();
if ($resultCode != \Memcached::RES_SUCCESS && $resultCode != \Memcached::RES_NOTFOUND) {
throw new StorageException('[STORAGE] "' . $this->getStorageName() . '::delete" failed for key "' . $key . '"!' . ' StorageRespCode: ' . $resultCode);
}
unset($this->casArray[$key]);
return $resultCode;
}
示例9: retrieve
/**
* Responsible for retrieving the authentication token from which persistent storage is in use.
*
* @return AccessToken|void
*/
public function retrieve($hash)
{
$cached = $this->memcached->get($this->prefix . $hash);
if ($this->memcached->getResultCode() === \Memcached::RES_SUCCESS) {
$json = json_decode($cached, true);
if (isset($json['token'], $json['expires'])) {
return new AccessToken($json['token'], DateTime::createFromFormat('U', $json['expires']));
}
}
}
示例10: isCached
/**
* Checks the cache for the presence of a given key.
*
* Memcached does not have a built-in method to check if a key is cached,
* so internally this method just calls the load() function and checks the
* result code via Memcached::getResultCode().
*
* @param string $key The key to check.
* @return boolean TRUE if the requested key is cached, FALSE otherwise.
*/
public function isCached($key)
{
if (isset($this->cache)) {
$result = $this->load($key);
if ($this->cache->getResultCode() == Memcached::RES_SUCCESS) {
return true;
}
}
return false;
}
示例11: many
/**
* Retrieve multiple items from the cache by key.
*
* Items not found in the cache will have a null value.
*
* @param array $keys
* @return array
*/
public function many(array $keys)
{
$prefixedKeys = array_map(function ($key) {
return $this->prefix . $key;
}, $keys);
$values = $this->memcached->getMulti($prefixedKeys, null, Memcached::GET_PRESERVE_ORDER);
if ($this->memcached->getResultCode() != 0) {
return array_fill_keys($keys, null);
}
return array_combine($keys, $values);
}
示例12: collect
public function collect()
{
$newValue = $this->memcached->increment($this->key);
if (false !== $newValue) {
return $this;
}
if (\Memcached::RES_NOTFOUND !== $this->memcached->getResultCode()) {
throw new \Exception('Error collecting value');
}
$this->memcached->set($this->key, 1, time() + $this->timeInterval);
}
示例13: getItem
/**
* Gets item from Memcached.
*
* @param string $key under which the item is stored
*
* @return mixed
* @throws \iveeCrest\Exceptions\KeyNotFoundInCacheException if key is not found
*/
public function getItem($key)
{
$item = $this->memcached->get(md5($this->uniqId . '_' . $key));
if ($this->memcached->getResultCode() == \Memcached::RES_NOTFOUND) {
$exceptionClass = Config::getIveeClassName('KeyNotFoundInCacheException');
throw new $exceptionClass("Key not found in memcached.");
}
//count memcached hit
$this->hits++;
return $item;
}
示例14: read
/**
* @param string $name
* @param mixed $defaultValue
* @return string
*/
public function read($name, $defaultValue = null)
{
if (!$this->memcached instanceof \Memcached) {
$this->connect();
}
$result = $this->memcached->get($name);
if ($result === false && $this->memcached->getResultCode() === \Memcached::RES_NOTFOUND) {
return $defaultValue;
} else {
return $result;
}
}
示例15: check
/**
* @return bool
*/
public function check()
{
if (array_key_exists($this->key, static::$cache)) {
return true;
}
$value = $this->memcached->get($this->key);
if ($this->memcached->getResultCode() == Memcached::RES_SUCCESS) {
static::$cache[$this->key] = $value;
return true;
}
return false;
}