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


PHP Client::incr方法代码示例

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


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

示例1: persist

 /**
  * Persist an error.
  * @param Error $error
  * @param Handler $handler
  * @return mixed
  */
 public function persist(Error $error, Handler $handler)
 {
     $errorKey = $this->generateRedisKey($error);
     $json = $error->toJson();
     if (is_int($this->ttl)) {
         $this->predisClient->setex($errorKey, $this->ttl, $json);
     } else {
         $this->predisClient->set($errorKey, $json);
     }
     $countKey = $this->generateRedisKey($error, 'count');
     $this->predisClient->incr($countKey);
 }
开发者ID:tomwright,项目名称:oopz,代码行数:18,代码来源:Redis.php

示例2: addBeaconMetricTotal

 /**
  * Add beacon total nb given the key entry.
  *
  * @param string $entryKey Key entry
  *
  * @return $this Self Object
  */
 private function addBeaconMetricTotal($entryKey)
 {
     $this->doRedisQuery(function () use($entryKey) {
         $this->redis->incr($entryKey . '_total');
     });
     return $this;
 }
开发者ID:pramoddas,项目名称:elcodi,代码行数:14,代码来源:RedisMetricsBucket.php

示例3: register

 /**
  * @param $username
  * @param $password
  *
  * @throws UsernameExistsException
  *
  * @return string
  */
 public function register($username, $password)
 {
     if ($this->checkIfUsernameExists($username)) {
         throw new UsernameExistsException(UsernameExistsException::MESSAGE);
     }
     $userId = $this->redisClient->incr("global:nextUserId");
     $this->redisClient->set("username:{$username}:id", $userId);
     $this->redisClient->set("uid:{$userId}:username", $username);
     $this->redisClient->set("uid:{$userId}:password", $password);
     $authSecret = $this->getRand();
     $this->redisClient->set("uid:{$userId}:auth", $authSecret);
     $this->redisClient->set("auth:{$authSecret}", $userId);
     $this->redisClient->sadd("global:users", [$userId]);
     $this->session->set('userId', $userId);
     $this->session->set('username', $username);
     return $authSecret;
 }
开发者ID:KrunoKnego,项目名称:Symfony-Twitter-Clone,代码行数:25,代码来源:RedisRegistration.php

示例4: tweet

 /**
  * @param string $status
  */
 public function tweet($status)
 {
     $postId = $this->redisClient->incr("global:nextPostId");
     $userId = $this->session->get('userId');
     $post = $userId . "|" . (new \DateTime())->format('d/m/y') . "|" . $status;
     $this->redisClient->set("post:{$postId}", $post);
     $followers = $this->redisClient->smembers("uid:" . $userId . ":followers");
     if ($followers === false) {
         $followers = [];
     }
     $followers[] = $userId;
     foreach ($followers as $fid) {
         $this->redisClient->lpush("uid:{$fid}:posts", [$postId]);
     }
     $this->redisClient->lpush("global:timeline", [$postId]);
     $this->redisClient->ltrim("global:timeline", 0, 1000);
 }
开发者ID:KrunoKnego,项目名称:Symfony-Twitter-Clone,代码行数:20,代码来源:RedisTweet.php

示例5: generateNewHashAndStoreIt

 /**
  * Generates a new hash for the route and stores 2 keys (sha1 and hash) in Redis
  * @param string $sha1
  * @param string $route
  * @return mixed|string
  */
 private function generateNewHashAndStoreIt($sha1, $route)
 {
     $id = $this->redis->incr($this->getUniqueKey());
     $hash = $this->encode($id);
     $result = json_encode(array('hash' => $hash, 'route' => $route));
     $this->redis->set($this->getSha1Key() . ":{$sha1}", $result);
     $this->redis->set($this->getHashKey() . ":{$hash}", $sha1);
     return $result;
 }
开发者ID:opus-online,项目名称:yii-shortify,代码行数:15,代码来源:Shortify.php

示例6: send

 /**
  * @param string          $commandName
  * @param array           $parameters
  * @param int|string|null $invokeId
  *
  * @return int|string
  */
 protected function send($commandName, array $parameters = array(), $invokeId = null)
 {
     if (null == $invokeId) {
         $invokeId = $this->redis->incr($this->getKey('invokeId'));
     }
     $nextAvailableTime = (double) ConfigurationLoader::get('client.request.overload.available');
     $this->lastCall = microtime(true) + $nextAvailableTime;
     $this->con->send(json_encode(['invokeId' => $invokeId, 'command' => $commandName, 'parameters' => $parameters]), \ZMQ::MODE_DONTWAIT);
     return $invokeId;
 }
开发者ID:phxlol,项目名称:lol-php-api,代码行数:17,代码来源:LOLClientAsync.php

示例7: increase

 /**
  * Increase the cache item.
  *
  * @see http://redis.io/commands/incr
  * @see http://redis.io/commands/incrby
  *
  * @param string $key The cache key
  * @param int $increment Increment value
  *
  * @return mixed
  */
 public function increase($key, $increment = 1)
 {
     $increment = abs((int) $increment);
     if ($increment <= 1) {
         $this->client->incr($key);
     } else {
         $this->client->incrby($key, $increment);
     }
     return $this;
 }
开发者ID:Top-Tech,项目名称:Top-tech,代码行数:21,代码来源:Redis.php

示例8: generate

 /**
  * @return IdValue
  */
 public function generate()
 {
     $timestamp = $this->generateTimestamp();
     $sequence = 0;
     if (!is_null($this->lastTimestamp) && $timestamp->equals($this->lastTimestamp)) {
         // Get
         $sequence = $this->redis->incr(self::REDIS_SEQUENCE_KEY) & $this->config->getSequenceMask();
         if ($sequence === 0) {
             usleep(1000);
             $timestamp = $this->generateTimestamp();
         }
     } else {
         // Reset sequence if timestamp is different from last one.
         $sequence = 0;
         $this->redis->set(self::REDIS_SEQUENCE_KEY, $sequence);
     }
     // Update lastTimestamp
     $this->lastTimestamp = $timestamp;
     return new IdValue($timestamp, $this->regionId, $this->serverId, $sequence, $this->calculate($timestamp, $this->regionId, $this->serverId, $sequence));
 }
开发者ID:ada-u,项目名称:chocoflake,代码行数:23,代码来源:IdWorkerOnRedis.php

示例9: clear

 /**
  * {@inheritdoc}
  */
 public function clear($key = null)
 {
     if (is_null($key)) {
         $this->redis->flushdb();
         return true;
     }
     $keyString = $this->makeKeyString($key, true);
     $keyReal = $this->makeKeyString($key);
     $this->redis->incr($keyString);
     // increment index for children items
     $this->redis->del($keyReal);
     // remove direct item.
     $this->keyCache = array();
     return true;
 }
开发者ID:sergeym,项目名称:Stash,代码行数:18,代码来源:Predis.php

示例10: put

 public function put($job)
 {
     $job['id'] = $this->redis->incr("job_id");
     $this->redis->lpush("jobs", serialize($job));
     return $job['id'];
 }
开发者ID:ekowabaka,项目名称:ajumamoro,代码行数:6,代码来源:RedisBroker.php

示例11: incrementKey

 public function incrementKey($key)
 {
     return $this->client->incr($key);
 }
开发者ID:splitio,项目名称:php-client,代码行数:4,代码来源:PRedis.php

示例12: addBeaconMetricTotal

 /**
  * Add beacon total nb given the key entry
  *
  * @param string $entryKey Key entry
  *
  * @return $this Self Object
  */
 private function addBeaconMetricTotal($entryKey)
 {
     $this->redis->incr($entryKey . '_total');
     return $this;
 }
开发者ID:xphere,项目名称:elcodi,代码行数:12,代码来源:RedisMetricsBucket.php

示例13: flushAll

 public function flushAll($db, $table)
 {
     $key = implode(':', [$this->prefix, self::KEY_SCHEMA_VERSION, $db, $table]);
     $key = md5($key);
     $this->redis->incr($key);
 }
开发者ID:angejia,项目名称:pea,代码行数:6,代码来源:RedisMeta.php

示例14: increment

 /**
  * @param CertificationEvent $event
  */
 public function increment(CertificationEvent $event)
 {
     $this->redisClient->incr('total');
     $this->redisClient->incr($event->getCertification()->getContext()->getName());
     $this->redisClient->bgsave();
 }
开发者ID:puterakahfi,项目名称:certificationy-web-platform,代码行数:9,代码来源:MetricsCounterListener.php


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