当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::expire方法代码示例

本文整理汇总了PHP中Predis\Client::expire方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::expire方法的具体用法?PHP Client::expire怎么用?PHP Client::expire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predis\Client的用法示例。


在下文中一共展示了Client::expire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * {@inheritdoc}
  */
 public function save()
 {
     $contents = $this->getForStorage();
     $this->client->set($this->key, $contents);
     if ($this->expire !== null) {
         $this->client->expire($this->key, $this->expire);
     }
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:11,代码来源:Predis.php

示例2: cache

 /**
  * {@inheritDoc}
  */
 public function cache(BatchGeocoded $geocoded)
 {
     $this->redis->set($key = $this->getKey($geocoded->getProviderName(), $geocoded->getQuery()), $this->serialize($geocoded));
     if ($this->expire > 0) {
         $this->redis->expire($key, $this->expire);
     }
 }
开发者ID:toin0u,项目名称:geotools,代码行数:10,代码来源:Redis.php

示例3: createRate

 public function createRate($key, $limit, $period)
 {
     $this->client->hset($key, 'limit', $limit);
     $this->client->hset($key, 'calls', 1);
     $this->client->hset($key, 'reset', time() + $period);
     $this->client->expire($key, $period);
     return $this->getRateInfo($key);
 }
开发者ID:Privax,项目名称:RateLimitBundle,代码行数:8,代码来源:Redis.php

示例4: write

 /**
  * Writes session data.
  *
  * @param  string $id    A session ID
  * @param  string $data  A serialized chunk of session data
  *
  * @return bool true, if the session was written, otherwise an exception is thrown
  *
  * @throws \RuntimeException If the session data cannot be written
  */
 public function write($key, $data)
 {
     $result = $this->db->hset($this->getHashKey(), $key, serialize($data));
     $expires = (int) $this->options['lifetime'];
     if ($expires > 0) {
         $this->db->expire($this->getHashKey(), $expires);
     }
     return $result;
 }
开发者ID:realestateconz,项目名称:SncRedisBundle,代码行数:19,代码来源:RedisSessionStorage.php

示例5: save

 /**
  * @param Widget $widget
  * @param        $content
  */
 public function save(Widget $widget, $content)
 {
     $hash = $this->getHash($widget);
     if ($hash) {
         $this->redis->set($hash, $content);
         $this->redis->expire($hash, $this->widgetHelper->getCacheTimeout($widget));
         // cache for a week
     }
 }
开发者ID:victoire,项目名称:victoire,代码行数:13,代码来源:WidgetCache.php

示例6: set

 /**
  * {@inheritDoc}
  */
 public function set($key, $value, $namespace = KeyValue::DEFAULT_NAMESPACE, $expirationDateTime = KeyValue::NO_EXPIRE)
 {
     $effectiveKey = $this->buildKey($key, $namespace);
     $this->redisClient->set($effectiveKey, serialize($value));
     $keyValue = new KeyValue($key, $value, $namespace, $expirationDateTime);
     if ($expirationDateTime !== KeyValue::NO_EXPIRE) {
         $this->redisClient->expire($effectiveKey, $keyValue->getSecsToExpire());
     }
     return $keyValue;
 }
开发者ID:wopp,项目名称:keyvalue-bundle,代码行数:13,代码来源:KeyValueServiceRedisImpl.php

示例7: write

 public function write($key, $value, $expires = null)
 {
     $key = $this->prefix . $key;
     $this->store->set($key, serialize($value));
     if (isset($expires)) {
         $expires = $this->makeExpiry($expires);
         $this->store->expire($key, $expires);
     }
     $this->addToIndex($key, $expires);
     return $this;
 }
开发者ID:simon-downes,项目名称:spf,代码行数:11,代码来源:Redis.php

示例8: set

 public function set($id, $value, $ttl = null)
 {
     try {
         $this->redis->set($id, $value);
         if ($ttl) {
             $this->redis->expire($id, $ttl);
         }
         return true;
     } catch (Predis\PredisException $e) {
         return false;
     }
 }
开发者ID:maximebf,项目名称:cachecache,代码行数:12,代码来源:Redis.php

示例9: set

 /**
  * {@inheirtdoc}
  *
  * @return \Orno\Cache\Adapter\RedisAdapter
  */
 public function set($key, $data, $expiry = null)
 {
     if (is_null($expiry)) {
         $expiry = $this->getExpiry();
     }
     if (is_string($expiry)) {
         $expiry = $this->convertExpiryString($expiry);
     }
     $this->redis->set($key, $data);
     $this->redis->expire($key, $expiry);
     return $this;
 }
开发者ID:orno,项目名称:cache,代码行数:17,代码来源:RedisAdapter.php

示例10: set

 /**
  * Set a value identified by $key and with an optional $ttl.
  *
  * @param string $key
  * @param mixed  $value
  * @param int    $ttl
  *
  * @return $this
  */
 public function set($key, $value, $ttl = 0)
 {
     $ttl = $this->fromDefaultTtl($ttl);
     if ($ttl >= 0) {
         if ($this->isAvailable()) {
             $this->redis->set($key, $this->storageDataStructure($value));
             if ($ttl > 0) {
                 $this->redis->expire($key, $ttl);
             }
         }
         $this->setChain($key, $value, $ttl);
     }
     return $this;
 }
开发者ID:nilportugues,项目名称:cache,代码行数:23,代码来源:AbstractAdapter.php

示例11: listen

 /**
  * Start the worker and wait for requests
  */
 public function listen()
 {
     $context = new \ZMQContext();
     $server = new \ZMQSocket($context, \ZMQ::SOCKET_PULL);
     $server->bind('tcp://127.0.0.1:' . ($this->defaultPort + $this->client->getId() - 1));
     $this->logger->info('Client worker ' . $this->client . ' is ready');
     while (true) {
         $request = $server->recv();
         $this->logger->debug('Client worker ' . $this->client . ' receiving request : ' . $request);
         // Check if the input is valid, ignore if wrong
         $request = json_decode($request, true);
         if (!$this->isValidInput($request)) {
             $this->logger->error('Client worker ' . $this->client . ' received an invalid input');
             continue;
         }
         try {
             // Call the right method in the client and push to redis the result
             $result = call_user_func_array(array($this->client, $request['command']), $request['parameters']);
         } catch (ClientNotReadyException $e) {
             $this->logger->warning('Client worker ' . $this->client . ' received a request (#' . $request['invokeId'] . ') whereas the client is not ready. This is normal in case of client reconnection process. Ignoring.');
             continue;
         }
         $key = $this->key . '.client.commands.' . $request['invokeId'];
         $this->redis->rpush($key, serialize($result));
         $this->redis->expire($key, $this->expire);
     }
 }
开发者ID:phxlol,项目名称:lol-php-api,代码行数:30,代码来源:ClientWorker.php

示例12: setHistorySessionToRedis

 /**
  * @param $sid
  * @param $session
  */
 public function setHistorySessionToRedis($sid, $session)
 {
     $key = $this->getHistoryKey($sid);
     $this->redis->set($key, serialize($session));
     $this->redis->expire($key, 60 * 60 * 24 * 30);
     // preserve 30 days
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:11,代码来源:DataProvider.php

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

示例14: getWithName

 /**
  * @param       $key
  * @param       $queryName
  * @param array $options
  *
  * @return org_glizy_dataAccess_cache_Iterator
  */
 public function getWithName($key, $queryName, $options = array())
 {
     $data = $this->redis->get($key);
     if ($data == null) {
         $data = array();
         /** @var org_glizy_dataAccess_cache_Iterator $it */
         $it = org_glizy_ObjectFactory::createModelIterator($this->model, $queryName, $options);
         /** @var org_glizy_dataAccess_cache_ActiveRecord $ar */
         foreach ($it as $ar) {
             $data[] = $ar->getValuesAsArray();
         }
         $this->redis->set($key, $this->serialize($data));
     } else {
         $data = $this->unserialize($data);
     }
     if ($this->lifeTime != -1) {
         $this->redis->expire($key, $this->lifeTime);
     }
     return new org_glizy_dataAccess_cache_Iterator($data);
 }
开发者ID:GruppoMeta,项目名称:Movio,代码行数:27,代码来源:QueryRedis.php

示例15: set

 /**
  * Set cache value
  *
  * @param CacheKey $key
  * @param mixed $value
  * @param int $sessionLength
  */
 public function set(CacheKey $key, $value, $sessionLength = null)
 {
     if ($sessionLength == null) {
         $sessionLength = $this->timeThreshold;
     }
     $sKey = $this->getKey($key);
     if (is_array($value) || is_object($value)) {
         $value = serialize($value);
     }
     $this->redis->set($sKey, $value);
     if (!empty($sessionLength) && $sessionLength > 0) {
         $this->redis->expire($sKey, $sessionLength);
     }
 }
开发者ID:PhanQuocTrung,项目名称:WeatherStation,代码行数:21,代码来源:Redis.php


注:本文中的Predis\Client::expire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。