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


PHP Client::set方法代码示例

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


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

 /**
  * @inheritdoc
  */
 public function set($key, $value, $ttl = 0)
 {
     if ($ttl > 0) {
         return $this->predis->setex($key, $ttl, $value);
     }
     return $this->predis->set($key, $value);
 }
开发者ID:savritsky,项目名称:cache,代码行数:10,代码来源:PredisDriver.php

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

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

 /**
  * Write a string value to storage
  * @param string $key       the key
  * @param string $value     the string value to be written
  * @param null|int $timeout an optional timout in milliseconds
  * @return string redis result
  */
 public function stringWrite($key, $value, $timeout = null)
 {
     $result = $this->_redis->set($key, $value);
     if ($timeout !== null) {
         $this->_redis->pexpire($key, $timeout);
     }
     return $result;
 }
开发者ID:haberberger,项目名称:redisstoragebundle,代码行数:15,代码来源:RedisStorage.php

示例6: store

 /**
  * @param Password $password
  * @param bool $allowOverwrite
  */
 public function store(Password $password, $allowOverwrite = false)
 {
     if (!$allowOverwrite && $this->get($password->getId())) {
         throw new PhPsstException('The ID already exists', PhPsstException::ID_IS_ALREADY_TAKEN);
     }
     $this->client->set($password->getId(), $password->getJson());
     $this->client->expireat($password->getId(), $password->getTtl());
 }
开发者ID:felixsand,项目名称:phpsst,代码行数:12,代码来源:RedisStorage.php

示例7: add

 /**
  * @param $key
  * @param $value
  * @throws UnavailableException
  */
 public function add($key, $value)
 {
     // encrypt the tokens before storing in redis
     try {
         $this->client->set($key, $this->encryption->encrypt($value));
     } catch (ServerException $ex) {
         throw new UnavailableException($ex->getMessage());
     }
 }
开发者ID:RepoMon,项目名称:tokens,代码行数:14,代码来源:Redis.php

示例8: getCurrentOrderAction

 public function getCurrentOrderAction(Application $app)
 {
     // Pause the execution until the display is updated
     while (true === json_decode($this->client->get(BogoBogoSorter::DISPLAYED_KEY))) {
         usleep(500);
     }
     $this->client->set(BogoBogoSorter::DISPLAYED_KEY, json_encode(true));
     return $app->json(json_decode($this->client->get(BogoBogoSorter::DATA_KEY), true));
 }
开发者ID:avltree,项目名称:bogobogo,代码行数:9,代码来源:ApiController.php

示例9: set

 /**
  * * Add a value to the cache under a unique key
  *
  * @param string $key
  * @param mixed  $value
  * @param int    $ttl
  */
 public function set($key, $value, $ttl = null)
 {
     $this->client->set($key, $value);
     if ($ttl) {
         $cmd = $this->client->createCommand('EXPIRE');
         $cmd->setArguments(array($key, $ttl));
         $this->client->executeCommand($cmd);
     }
 }
开发者ID:alambike,项目名称:phpback,代码行数:16,代码来源:Redis.php

示例10: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, $data, $lifeTime = 0)
 {
     if ($lifeTime > 0) {
         $response = $this->client->setex($id, $lifeTime, $data);
     } else {
         $response = $this->client->set($id, $data);
     }
     return $response === true || $response == 'OK';
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:12,代码来源:PredisCache.php

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

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

示例13: save

 /**
  * {@inheritdoc}
  */
 public function save($id, $data, $lifeTime = 0)
 {
     if ($lifeTime > 0) {
         $response = $this->client->setex($this->prefix . $id, $lifeTime, $data);
     } else {
         $response = $this->client->set($this->prefix . $id, $data);
     }
     return $response === true || $response == 'OK';
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:12,代码来源:PredisDriver.php

示例14: checkWriteToStorage

 /**
  * @return void
  */
 private function checkWriteToStorage()
 {
     try {
         $this->client->set(self::KEY_HEARTBEAT, 'ok');
     } catch (\Exception $e) {
         $this->addDysfunction(self::HEALTH_MESSAGE_UNABLE_TO_WRITE_TO_STORAGE);
         $this->addDysfunction($e->getMessage());
     }
 }
开发者ID:spryker,项目名称:Heartbeat,代码行数:12,代码来源:StorageHealthIndicator.php

示例15: save

 /**
  * @param AbstractJob $job
  *
  * @return bool
  * @throws \Cronario\Exception\JobException
  */
 public function save(AbstractJob $job)
 {
     $data = $job->getData();
     if (!$job->isStored()) {
         $job->setId(uniqid());
     }
     $this->redis->set($this->namespace . $job->getId(), json_encode($data));
     return true;
 }
开发者ID:sunnyct,项目名称:cronario,代码行数:15,代码来源:Redis.php


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