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


PHP Redis::setex方法代碼示例

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


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

示例1: set

 public function set($sKey, $oData, $iTTL = -1)
 {
     $iTTL = $this->buildTTL($iTTL);
     if ($iTTL === 0) {
         return $this->oClient->set($this->buildKey($sKey), $this->serialize($oData));
     }
     return $this->oClient->setex($this->buildKey($sKey), $iTTL, $this->serialize($oData));
 }
開發者ID:asticode,項目名稱:php-cache-manager,代碼行數:8,代碼來源:RedisHandler.php

示例2: set

 /**
  * {@inheritdoc}
  */
 public function set($key, $data, $ttl = 0)
 {
     if ($ttl > 0) {
         return $this->redis->setex($key, (int) $ttl, $data);
     }
     return $this->redis->set($key, $data);
 }
開發者ID:lingualeo,項目名稱:php-cache,代碼行數:10,代碼來源:RedisCache.php

示例3: set

 public function set($id, $data, $lifetime = false)
 {
     if ($lifetime) {
         return $this->_redis->setex($id, $lifetime, $data);
     } else {
         return $this->_redis->set($id, $data);
     }
 }
開發者ID:sttt,項目名稱:phpredis-kohana3.3,代碼行數:8,代碼來源:Redis.php

示例4: setItem

 /**
  * Stores item in Redis.
  *
  * @param \iveeCore\ICacheable $item to be stored
  *
  * @return boolean true on success
  */
 public function setItem(ICacheable $item)
 {
     $ttl = $item->getCacheExpiry() - time();
     if ($ttl < 1) {
         return false;
     }
     return $this->redis->setex($item->getKey(), $ttl, gzencode(serialize($item)));
 }
開發者ID:Covert-Inferno,項目名稱:iveeCore,代碼行數:15,代碼來源:RedisWrapper.php

示例5: createUserToken

 /**
  * @param int $userId
  *
  * @return string
  */
 public function createUserToken($userId)
 {
     $generator = new SecureRandom();
     $rand = $generator->nextBytes(12);
     $wsseToken = sha1($rand);
     $this->redis->setex(self::PREFIX . ':' . $userId, $this->ttl, $wsseToken);
     return $wsseToken;
 }
開發者ID:bzis,項目名稱:zomba,代碼行數:13,代碼來源:WsseTokenManager.php

示例6: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, $data, $lifeTime = 0)
 {
     if (0 === $lifeTime) {
         return $this->_redis->set($id, $data);
     } else {
         return $this->_redis->setex($id, $lifeTime, $data);
     }
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:11,代碼來源:RedisCache.php

示例7: put

 /**
  * @inheritdoc
  */
 public function put($key, $value, $ttl = 0)
 {
     if ($ttl > 0) {
         return $this->redis->setex($key, $ttl, $value);
     } else {
         return $this->redis->set($key, $value);
     }
 }
開發者ID:lixiongyou,項目名稱:pudding,代碼行數:11,代碼來源:Redis.php

示例8: set

 public function set($key, $value, $ttl = 0)
 {
     if ($ttl > 0) {
         return self::$cache->setex($this->getNamespace() . $key, $ttl, json_encode($value));
     } else {
         return self::$cache->set($this->getNamespace() . $key, json_encode($value));
     }
 }
開發者ID:adolfo2103,項目名稱:hcloudfilem,代碼行數:8,代碼來源:redis.php

示例9: write

 /**
  * {@inheritDoc}
  */
 public function write($sessionId, $data)
 {
     if (0 < $this->ttl) {
         $this->redis->setex($this->getRedisKey($sessionId), $this->ttl, $data);
     } else {
         $this->redis->set($this->getRedisKey($sessionId), $data);
     }
 }
開發者ID:ronnylt,項目名稱:SncRedisBundle,代碼行數:11,代碼來源:RedisSessionHandler.php

示例10: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, $data, $lifeTime = false)
 {
     if (0 < $lifeTime) {
         $result = $this->redis->setex($id, (int) $lifeTime, serialize($data));
     } else {
         $result = $this->redis->set($id, serialize($data));
     }
     return (bool) $result;
 }
開發者ID:slaparra,項目名稱:voting-details,代碼行數:12,代碼來源:RedisCache.php

示例11: setItem

 /**
  * Stores item in Redis.
  *
  * @param \iveeCrest\ICacheable $item to be stored
  *
  * @return boolean true on success
  */
 public function setItem(ICacheable $item)
 {
     $key = md5($this->uniqId . '_' . $item->getKey());
     $ttl = $item->getCacheTTL();
     //emulate memcached behaviour: TTLs over 30 days are interpreted as (absolute) UNIX timestamps
     if ($ttl > 2592000) {
         $this->redis->set($key, serialize($item));
         return $this->redis->expireAt($key, $ttl);
     } else {
         return $this->redis->setex($key, $ttl, serialize($item));
     }
 }
開發者ID:plugh3,項目名稱:eve-trade1-perl,代碼行數:19,代碼來源:RedisWrapper.php

示例12: set

	/**
	 * 設置緩存
	 * @param string $cache_id
	 * @param mixed $data 緩存數據
	 * @param int $left 緩存時間 秒
	 * @return bool
	 */
	public function set($cache_id, $data, $left = 60) {
		try {
			$value = serialize($data);
			if ($left === 0) {
				$retRes = $this->_redis->set($cache_id, $value);
			} else {
				$retRes = $this->_redis->setex($cache_id, $left, $value);
			}
			return $retRes;
		} catch (Exception $e) {
			$this->_error = $e->getMessage();
			return false;
		}
	}
開發者ID:neil-chen,項目名稱:NeilChen,代碼行數:21,代碼來源:RedisCache.class.php

示例13: testExpireAtWithLong

 public function testExpireAtWithLong()
 {
     $longExpiryTimeExceedingInt = 3153600000.0;
     $this->redis->delete('key');
     $this->assertTrue($this->redis->setex('key', $longExpiryTimeExceedingInt, 'val') === TRUE);
     $this->assertTrue($this->redis->ttl('key') === $longExpiryTimeExceedingInt);
 }
開發者ID:remicollet,項目名稱:phpredis,代碼行數:7,代碼來源:TestRedis.php

示例14: write

 /**
  * Store some data in session.
  * Expects a session id and the data to write.
  * @param string $sessionId
  * @param mixed $data
  * @return boolean
  */
 public function write($sessionId = '', $data = '')
 {
     if ($sessionId !== '') {
         $this->_redis->setex($this->_key($sessionId), $this->_lifetime, $data);
     }
     return true;
 }
開發者ID:hubvioos,項目名稱:42framework,代碼行數:14,代碼來源:RedisHandler.php

示例15: write

 /**
  * Write session data
  *
  * @param   string  $session_id    The session id
  * @param   string  $session_data  The encoded session data
  *
  * @return  boolean  True on success, false otherwise
  *
  * @since   __DEPLOY_VERSION__
  */
 public function write($session_id, $session_data)
 {
     if ($this->ttl > 0) {
         return $this->redis->setex($this->prefix . $session_id, $this->ttl, $session_data);
     }
     return $this->redis->set($this->prefix . $session_id, $session_data);
 }
開發者ID:Rai-Ka,項目名稱:joomla-cms,代碼行數:17,代碼來源:RedisHandler.php


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