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


PHP Redis::set方法代碼示例

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


在下文中一共展示了Redis::set方法的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

 /**
  * Store data on the cache server.
  *
  * @param string       $key        Key we can use to retrieve the data.
  * @param string|array $data       Data to store on the cache server.
  * @param int          $expiration Time before the data expires on the cache server.
  *
  * @return bool Success/Failure.
  * @access public
  */
 public function set($key, $data, $expiration)
 {
     if ($this->connected === true && $this->ping() === true) {
         return $this->server->set($key, $this->isRedis ? $this->IgBinarySupport ? igbinary_serialize($data) : serialize($data) : $data, $expiration);
     }
     return false;
 }
開發者ID:sebst3r,項目名稱:nZEDb,代碼行數:17,代碼來源:Cache.php

示例3: 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

示例4: 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

示例5: 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

示例6: save

 /**
  * Save item in the cache.
  * 
  * @param string $key
  * @param string $value
  * @param int $ttl
  * @return void
  * 
  * @throws StorageException if storage error occurs, handler can not be used
  */
 protected function save($key, $value, $ttl)
 {
     try {
         $this->redis->set($key, $value, $ttl);
     } catch (\Exception $e) {
         throw new StorageException("Failed to save redis key: {$key}", 1, $e);
     }
 }
開發者ID:Nek-,項目名稱:php-circuit-breaker,代碼行數:18,代碼來源:RedisAdapter.php

示例7: set

 /**
  * Set a value in the cache
  * @param string $p_sKey The Key
  * @param mixed $p_mData The Data
  * @param mixed $p_mTTL The Time To Live. Integer or String (strtotime)
  * @return boolean True on succes, False on failure.
  */
 function set($p_sKey, $p_mData, $p_mTTL = null)
 {
     if ($p_mTTL !== null && is_string($p_mData)) {
         $p_mTTL = strtotime($p_mTTL);
     }
     $p_mTTL = $p_mTTL !== null ? $p_mTTL : $this->_defaults['expiry'];
     return $this->_handler->set($p_sKey, $p_mData, $p_mTTL);
 }
開發者ID:revolveweb,項目名稱:ppi-framework,代碼行數:15,代碼來源:Redis.php

示例8: 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

示例9: set

 public function set($key, $value, $ttl = null)
 {
     if (!is_null($ttl)) {
         return $this->connection->set($key, $value, $ttl);
     } else {
         return $this->connection->set($key, $value);
     }
 }
開發者ID:oat-sa,項目名稱:generis,代碼行數:8,代碼來源:class.PhpRedisDriver.php

示例10: 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

示例11: 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

示例12: store

 /**
  * @inheritdoc
  */
 public function store($key, $value, $ttl = null)
 {
     $key = $this->prefix . $key;
     if ($ttl) {
         $this->redis->set($key, serialize($value), $ttl);
         return;
     }
     $this->redis->set($key, serialize($value));
 }
開發者ID:icanboogie,項目名稱:storage,代碼行數:12,代碼來源:RedisStorage.php

示例13: 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

示例14: 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

示例15: testStdClass

 public function testStdClass()
 {
     $data = new \stdClass();
     $data->a = 'a';
     $data->b = 'b';
     $key = new CacheKey('test', rand(1, 1000));
     $this->cache->set($key, $data);
     $val = $this->cache->get($key);
     $this->assertEquals($data, $val);
 }
開發者ID:PhanQuocTrung,項目名稱:WeatherStation,代碼行數:10,代碼來源:RedisTest.php


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