当前位置: 首页>>代码示例>>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;未经允许,请勿转载。