当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::exists方法代码示例

本文整理汇总了PHP中Redis::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::exists方法的具体用法?PHP Redis::exists怎么用?PHP Redis::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


在下文中一共展示了Redis::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exists

 public function exists($key)
 {
     if (!$this->isConnected()) {
         return false;
     }
     return (bool) $this->redis->exists($key);
 }
开发者ID:everlution,项目名称:redlock,代码行数:7,代码来源:PhpRedisAdapter.php

示例2: testExists

 public function testExists()
 {
     $key = 'key' . rand();
     $this->assertFalse($this->redis->exists($key));
     $this->redis->add($key, 'val');
     $this->assertTrue($this->redis->exists($key));
 }
开发者ID:hieutrieu,项目名称:phpredis,代码行数:7,代码来源:TestRedis.php

示例3: getMy

 /**
  * @param $key
  * @return Option
  */
 public static function getMy($key)
 {
     $hash = self::hash($key);
     if (self::$redis->exists(self::myPrefix() . ":" . $hash)) {
         return Option::Some(unserialize(self::$redis->get(self::myPrefix() . ":" . $hash)));
     } else {
         return Option::None();
     }
 }
开发者ID:pldin601,项目名称:HomeMusic,代码行数:13,代码来源:RedisCache.php

示例4: getHashes

 /**
  * Returns a list of all affected hashes for a given set of tags.
  *
  * @param array $tags
  *
  * @return array
  */
 private function getHashes(array $tags)
 {
     $hashes = [];
     foreach ($tags as $tag) {
         $tag = $this->redis->prefix($tag);
         if (!$this->redis->exists($tag)) {
             continue;
         }
         $hashes = array_merge($hashes, $this->redis->smembers($tag));
     }
     return array_unique($hashes);
 }
开发者ID:spiritix,项目名称:lada-cache,代码行数:19,代码来源:Invalidator.php

示例5: getWithFallback

 /**
  * Try to get an item, and if missed call the fallback method to produce the value and store it.
  *
  * @param string $key
  * @param callable $fallback
  * @param int|\DateInterval|\DateTime|callback $validity Number of seconds this is valid for (if int)
  * @return mixed
  */
 function getWithFallback($key, callable $fallback, $validity = null)
 {
     $value = $this->connection->get($key);
     if (!$value && !$this->connection->exists($key)) {
         $value = $fallback();
         if (is_callable($validity)) {
             $validity = call_user_func($validity, $value);
         }
         $this->set($key, $value, $validity);
         return $value;
     }
     return $value;
 }
开发者ID:digitalcreations,项目名称:cache-phpredis,代码行数:21,代码来源:Cache.php

示例6: isFrozen

 /**
  * Tells if this backend is frozen.
  *
  * @return boolean
  */
 public function isFrozen()
 {
     if (null === $this->frozen) {
         $this->frozen = $this->redis->exists($this->buildKey('frozen'));
     }
     return $this->frozen;
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:12,代码来源:RedisBackend.php

示例7: validateDigest

 /**
  * @param string $digest
  * @param string $nonce
  * @param string $created
  * @param string $secret
  *
  * @return bool
  * @throws \Symfony\Component\Security\Core\Exception\NonceExpiredException
  */
 protected function validateDigest($digest, $nonce, $created, $secret)
 {
     /*
      * закомментили 7.01.2014 из-за проблемы возможного расхождения с клиентским временем
      *
     // Check created time is not in the future
     if (strtotime($created) > time()) {
         return false;
     }
     
     // Expire timestamp after 5 minutes
     if (time() - strtotime($created) > self::TTL) {
         return false;
     }
     */
     // Validate nonce is unique within 5 minutes
     if ($this->redis->exists(self::PREFIX . ':' . $nonce)) {
         if (null !== $this->logger) {
             $this->logger->debug(sprintf('Previously used nonce detected: %s', base64_decode($nonce)));
         }
         throw new NonceExpiredException('Previously used nonce detected');
     }
     $this->redis->setex(self::PREFIX . ':' . $nonce, self::TTL, time());
     // Validate Secret
     $expected = base64_encode(sha1(base64_decode($nonce) . $created . $secret, true));
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('[+] %s, [=] %s (created: %s, nonce: %s, secret: %s)', $digest, $expected, $created, base64_decode($nonce), $secret));
     }
     return $digest === $expected;
 }
开发者ID:bzis,项目名称:zomba,代码行数:39,代码来源:WsseProvider.php

示例8: _display_cache

 public function _display_cache(&$CFG, &$URI)
 {
     $cache_path = $CFG->item('cache_path') === '' ? APPPATH . 'cache/' : $CFG->item('cache_path');
     $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
     if ($CFG->item('cache_query_string') && !empty($_SERVER['QUERY_STRING'])) {
         $uri .= '?' . $_SERVER['QUERY_STRING'];
     }
     $filepath = $cache_path . md5($uri);
     $redis = new Redis();
     $host = $CFG->item("redis_host");
     $port = $CFG->item("redis_port");
     $redis->connect($host, $port);
     if ($redis->exists($filepath)) {
         $cache = $redis->get($filepath);
         if (!preg_match('/^(.*)ENDCI--->/', $cache, $match)) {
             return false;
         }
     } else {
         return false;
     }
     $cache_info = unserialize($match[1]);
     $expire = $cache_info['expire'];
     $last_modified = $cache_info["last_modified"];
     $this->set_cache_header($last_modified, $expire);
     foreach ($cache_info['headers'] as $header) {
         $this->set_header($header[0], $header[1]);
     }
     $this->_display(substr($cache, strlen($match[0])));
     log_message('debug', 'Cache is current. Sending it to browser.');
     return TRUE;
 }
开发者ID:richwandell,项目名称:Codeigniter-Example-App,代码行数:31,代码来源:MY_Output.php

示例9: removeWord

 /**
  * {@inheritDoc}
  */
 public function removeWord($language, $word)
 {
     $word = mb_strtolower($word, mb_detect_encoding($word));
     if ($this->redis->exists($word)) {
         $languages = unserialize($this->redis->get($word));
         if (false !== ($index = array_search($language, $languages))) {
             unset($languages[$index]);
             if (!count($languages)) {
                 $this->redis->del($word);
             } else {
                 $this->redis->set($word, serialize($languages));
             }
         }
     }
     return $this;
 }
开发者ID:jackblackjack,项目名称:LanguageDetector,代码行数:19,代码来源:RedisDictionary.php

示例10: testExists

 public function testExists()
 {
     $this->redis->delete('key');
     $this->assertFalse($this->redis->exists('key'));
     $this->redis->set('key', 'val');
     $this->assertEquals(True, $this->redis->exists('key'));
 }
开发者ID:virtulis,项目名称:phpredis,代码行数:7,代码来源:TestRedis.php

示例11: exists

	/**
	 * key是否存在,存在返回ture
	 * @param string $cache_id KEY名称
	 */
	public function exists($cache_id) {
		try {
			return $this->_redis->exists($cache_id);
		} catch (Exception $e) {
			$this->_error = $e->getMessage();
			return false;
		}
	}
开发者ID:neil-chen,项目名称:NeilChen,代码行数:12,代码来源:RedisCache.class.php

示例12: appendValue

 /**
  * Appends data to an existing item on the Redis server.
  *
  * @param  string $key
  * @param  string $value
  * @param  int    $expiration
  * @return bool
  */
 protected function appendValue($key, $value, $expiration = 0)
 {
     if ($this->redis->exists($key)) {
         $this->redis->append($key, $value);
         return $this->redis->expire($key, $expiration);
     }
     return $this->redis->setex($key, $expiration, $value);
 }
开发者ID:snc,项目名称:SncRedisBundle,代码行数:16,代码来源:RedisProfilerStorage.php

示例13: destroy

 /**
  * 摧毁SESSION
  *
  * @param int $id key
  *
  * @return bool true/false
  */
 public function destroy($id)
 {
     $id = 'sess_' . $id;
     if ($this->redis->exists($id)) {
         return $this->redis->delete($id);
     }
     return true;
 }
开发者ID:3032441712,项目名称:person,代码行数:15,代码来源:Data.php

示例14: find

 /**
  * {@inheritDoc}
  */
 public function find($storageName, $key)
 {
     $key = $this->getKeyName($key);
     if (!$this->client->exists($key)) {
         throw new NotFoundException();
     }
     return json_decode($this->client->get($key), true);
 }
开发者ID:nicktacular,项目名称:KeyValueStore,代码行数:11,代码来源:RedisStorage.php

示例15: destroy

 /**
  * Destroy a session.
  * Expects a session id.
  * @param string $sessionId
  * @return boolean
  */
 public function destroy($sessionId = '')
 {
     if ($sessionId !== '' && $this->_redis->exists($this->_key($sessionId))) {
         $this->_redis->del($this->_key($sessionId));
     }
     session_destroy();
     return true;
 }
开发者ID:hubvioos,项目名称:42framework,代码行数:14,代码来源:RedisHandler.php


注:本文中的Redis::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。