當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。