當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Redis::setTimeout方法代碼示例

本文整理匯總了PHP中Redis::setTimeout方法的典型用法代碼示例。如果您正苦於以下問題:PHP Redis::setTimeout方法的具體用法?PHP Redis::setTimeout怎麽用?PHP Redis::setTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Redis的用法示例。


在下文中一共展示了Redis::setTimeout方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepend

 /**
  * @param mixed $value
  *
  * @return RedisNoSQLList
  */
 public function prepend($value)
 {
     $this->redis->lpush($this->key, $value);
     if ($this->timeout) {
         $this->redis->setTimeout($this->key, $this->timeout);
     }
     return $this;
 }
開發者ID:justthefish,項目名稱:hesper,代碼行數:13,代碼來源:RedisNoSQLList.php

示例2: increment

 public static function increment($host)
 {
     $count = self::$redis->incrBy(self::$prefix . $host, 1);
     if (self::$redis->get(self::$prefix . $host) == 1) {
         self::$redis->setTimeout(self::$prefix . $host, self::$ttl);
     }
     return $count;
 }
開發者ID:ariarijp,項目名稱:cassowary,代碼行數:8,代碼來源:RedisAdapter.php

示例3: setJson

 /**
  * 設置值(string)會將$value自動轉為json格式
  * @param string $key KEY名稱
  * @param string|array $value 獲取得到的數據
  * @param int $timeOut 時間
  * @return bool
  */
 public function setJson($key, $value, $timeOut = 0)
 {
     $value = json_encode($value);
     $retRes = $this->redis->set($key, $value);
     if ($timeOut > 0) {
         $this->redis->setTimeout($key, $timeOut);
     }
     return $retRes;
 }
開發者ID:WALES7CH,項目名稱:TP-Admin,代碼行數:16,代碼來源:RedisHandler.class.php

示例4: addValue

 protected function addValue($key, $value, $expires = 0)
 {
     $r = $this->redis->setnx($key, $value);
     if ($r && $expires) {
         $this->redis->setTimeout($key, $expires);
     }
     return $r;
 }
開發者ID:jellycheng,項目名稱:windframework,代碼行數:8,代碼來源:WindRedisCache.php

示例5: testttl

 public function testttl()
 {
     $this->redis->set('x', 'y');
     $this->redis->setTimeout('x', 5);
     for ($i = 5; $i > 0; $i--) {
         $this->assertEquals($i, $this->redis->ttl('x'));
         sleep(1);
     }
 }
開發者ID:virtulis,項目名稱:phpredis,代碼行數:9,代碼來源:TestRedis.php

示例6: set

 /**
  * 設置值
  * @param string $key KEY名稱
  * @param string|array $value 獲取得到的數據
  * @param int $timeOut 時間
  * @return bool
  */
 public function set($key, $value, $timeOut = 0)
 {
     $value = json_encode($value);
     $retRes = parent::set($key, $value);
     if ($timeOut > 0) {
         parent::setTimeout($key, $timeOut);
     }
     return $retRes;
 }
開發者ID:cloklo,項目名稱:CxWoole,代碼行數:16,代碼來源:CxRedis.php

示例7: testPersist

 public function testPersist()
 {
     $this->redis->set('x', 'y');
     $this->redis->setTimeout('x', 100);
     $this->assertTrue(TRUE === $this->redis->persist('x'));
     // true if there is a timeout
     $this->assertTrue(-1 === $this->redis->ttl('x'));
     // -1: timeout has been removed.
     $this->assertTrue(FALSE === $this->redis->persist('x'));
     // false if there is no timeout
     $this->redis->delete('x');
     $this->assertTrue(FALSE === $this->redis->persist('x'));
     // false if the key doesn’t exist.
 }
開發者ID:stonegithubs,項目名稱:phpredis,代碼行數:14,代碼來源:TestRedis.php

示例8: add

 /**
  * Add to the cache
  *
  * Add a new variable to the cache that you will then be able
  * to retrieve using the $this->get($name) method.
  *
  * @param  string  $name   The name of the cache variable to store.
  * @param  string  $value  The value of the cache variable to store.
  * @param  integer $expire When should it expire? Default: 900 seconds.
  * 
  * @return boolean       Depending on the success of the operation, 
  *                       either true or false. 
  */
 public function add($name, $value, $expiry = 900)
 {
     $this->redis->add($name, serialize($value));
     $this->redis->setTimeout($name, $expiry);
 }
開發者ID:jeremykendall,項目名稱:frapi,代碼行數:18,代碼來源:Redis.php


注:本文中的Redis::setTimeout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。