當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。