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


PHP Client::exists方法代码示例

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


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

示例1: hasSession

 /**
  * @param string $sessionId
  * @return boolean
  */
 public function hasSession($sessionId)
 {
     if ($this->redis->exists('session_' . $sessionId)) {
         return true;
     }
     return false;
 }
开发者ID:squarer,项目名称:symfony3-demo,代码行数:11,代码来源:AppExtension.php

示例2: get

 /**
  * Get a variable
  *
  * @param string $key
  * @param mixed  $default
  * @return mixed
  */
 public function get($key, $default = null)
 {
     if ($this->client->exists($this->namespace . $key)) {
         return $this->client->get($this->namespace . $key);
     } else {
         return $default;
     }
 }
开发者ID:bravo3,项目名称:workflow,代码行数:15,代码来源:RedisMemoryPool.php

示例3: getUpdatedAt

 /**
  * {@inheritdoc}
  */
 public function getUpdatedAt()
 {
     if ($this->client->exists('migraine:date')) {
         $date = new \DateTime();
         $date->setTimestamp(intval($this->client->get('migraine:date')));
         return $date;
     }
     return null;
 }
开发者ID:jiabin,项目名称:migraine,代码行数:12,代码来源:RedisType.php

示例4: isCached

 /**
  * {@inheritDoc}
  */
 public function isCached($providerName, $query)
 {
     if (!$this->redis->exists($key = $this->getKey($providerName, $query))) {
         return false;
     }
     $cached = new BatchGeocoded();
     $cached->fromArray($this->deserialize($this->redis->get($key)));
     return $cached;
 }
开发者ID:toin0u,项目名称:geotools,代码行数:12,代码来源:Redis.php

示例5: lookupKeyInRedisDatabase

 /**
  * Checks if the activation key is present in the redis database.
  *
  * @param string $activationKey
  *
  * @return bool
  */
 private function lookupKeyInRedisDatabase($activationKey)
 {
     $persistentKey = $this->generateRedisKeyByApprovalKey($activationKey);
     $exists = $this->redis->exists($persistentKey);
     // the key is not needed anymore because the approval validation will be triggered once only.
     if ($exists) {
         $this->redis->del($persistentKey);
     }
     return $exists;
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:17,代码来源:PendingActivationsCluster.php

示例6: getAvailability

 /**
  * @inheritdoc
  */
 public function getAvailability(\string $id) : \bool
 {
     $key = sprintf(self::QUANTITY_KEY, $id);
     if (!$this->predis->exists($key)) {
         $value = $this->repository->getAvailability($id);
         $this->saveAvailability($id, $value);
     } else {
         $value = (int) $this->predis->get($key);
     }
     return $value;
 }
开发者ID:igaponov,项目名称:shop,代码行数:14,代码来源:ProductViewRepository.php

示例7: getById

 /**
  * @inheritdoc
  */
 public function getById(\string $id) : CustomerView
 {
     $key = self::KEY . ':' . $id;
     if ($this->client->exists($key)) {
         $item = $this->client->hgetall($key);
         $model = $this->createViewModel($item);
     } else {
         $model = $this->repository->getById($id);
         $this->save($model);
     }
     return $model;
 }
开发者ID:igaponov,项目名称:shop,代码行数:15,代码来源:CustomerViewRepository.php

示例8: getAllIndexed

 /**
  * @inheritDoc
  */
 public function getAllIndexed() : array
 {
     if (!$this->client->exists($this->key)) {
         $data = $this->repository->getAllIndexed();
         if ($data) {
             $this->client->hmset($this->key, $data);
         }
     } else {
         $data = $this->client->hgetall($this->key);
     }
     return $data;
 }
开发者ID:igaponov,项目名称:shop,代码行数:15,代码来源:DirectoryViewRepository.php

示例9: getEventsFor

 public function getEventsFor($id)
 {
     if (!$this->predis->exists('events:' . $id)) {
         throw new AggregateDoesNotExist($id);
     }
     $serializedEvents = $this->predis->lrange('events:' . $id, 0, -1);
     $eventStream = [];
     foreach ($serializedEvents as $serializedEvent) {
         $eventData = $this->serializer->deserialize($serializedEvent, 'array', 'json');
         $eventStream[] = $this->serializer->deserialize($eventData['data'], $eventData['type'], 'json');
     }
     return new EventStream($id, $eventStream);
 }
开发者ID:dddinphp,项目名称:last-wishes-gamify,代码行数:13,代码来源:RedisEventStore.php

示例10: handle

 /**
  * @param EventInterface $event
  */
 public function handle(EventInterface $event)
 {
     $this->redis->lpush(self::BUFFER_LIST_KEY, json_encode($event->toArray()));
     if ($this->redis->exists(self::BUFFER_TIMER_KEY)) {
         $this->redis->pexpire(self::BUFFER_TIMER_KEY, self::BUFFER_TIMEOUT_MILLISECONDS);
     } else {
         $this->redis->psetex(self::BUFFER_TIMER_KEY, self::BUFFER_TIMEOUT_MILLISECONDS, '1');
         while ($this->redis->exists(self::BUFFER_TIMER_KEY)) {
             usleep(self::BUFFER_SLEEP_MILLISECONDS);
         }
         $this->handleBufferedEvents();
     }
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:16,代码来源:HostSendertoolOnlineStateChanged.php

示例11: getFromCache

 protected function getFromCache($key)
 {
     if (!$this->cache->exists($key)) {
         return null;
     }
     return unserialize($this->cache->get($key));
 }
开发者ID:ShawnMcCool,项目名称:meetup-raffle-machine,代码行数:7,代码来源:MeetupService.php

示例12: validateDigest

 /**
  * @param string $digest
  * @param string $nonce
  * @param string $created
  * @param string $secret
  *
  * @return bool
  * @throws \Symfony\Component\Security\Core\Exception\NonceExpiredException
  */
 protected function validateDigest($digest, $nonce, $created, $secret)
 {
     /*
      * закомментили 7.01.2014 из-за проблемы возможного расхождения с клиентским временем
      *
     // Check created time is not in the future
     if (strtotime($created) > time()) {
         return false;
     }
     
     // Expire timestamp after 5 minutes
     if (time() - strtotime($created) > self::TTL) {
         return false;
     }
     */
     // Validate nonce is unique within 5 minutes
     if ($this->redis->exists(self::PREFIX . ':' . $nonce)) {
         if (null !== $this->logger) {
             $this->logger->debug(sprintf('Previously used nonce detected: %s', base64_decode($nonce)));
         }
         throw new NonceExpiredException('Previously used nonce detected');
     }
     $this->redis->setex(self::PREFIX . ':' . $nonce, self::TTL, time());
     // Validate Secret
     $expected = base64_encode(sha1(base64_decode($nonce) . $created . $secret, true));
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('[+] %s, [=] %s (created: %s, nonce: %s, secret: %s)', $digest, $expected, $created, base64_decode($nonce), $secret));
     }
     return $digest === $expected;
 }
开发者ID:bzis,项目名称:zomba,代码行数:39,代码来源:WsseProvider.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: testExpireIn

 /**
  * @covers BehEh\Flaps\Storage\PredisStorage::expireIn
  */
 public function testExpireIn()
 {
     $this->assertEquals(0, $this->client->exists('key'));
     $this->assertEquals(0, $this->client->exists('key:timestamp'));
     $this->storage->setValue('key', 1);
     $this->storage->setTimestamp('key', 1425829426.0);
     $this->assertEquals(1, $this->client->exists('key'));
     $this->assertEquals(1, $this->client->exists('key:timestamp'));
     $this->assertEquals(1, $this->storage->expireIn('key', 0));
     $this->assertEquals(0, $this->client->exists('key'));
     $this->assertEquals(0, $this->client->exists('key:timestamp'));
     $this->assertEquals(0, $this->storage->expireIn('key', 0));
 }
开发者ID:beheh,项目名称:flaps,代码行数:16,代码来源:PredisStorageTest.php

示例15: isAllowed

 /**
  * {@inheritdoc}
  * Example:
  * <code>
  * //Does Andres have access to the customers resource to create?
  * $acl->isAllowed('Andres', 'Products', 'create');
  * //Do guests have access to any resource to edit?
  * $acl->isAllowed('guests', '*', 'edit');
  * </code>
  *
  * @param string $role
  * @param string $resource
  * @param string $access
  *
  * @return bool
  */
 public function isAllowed($role, $resource, $access)
 {
     if ($this->redis->sIsMember("accessList:{$role}:{$resource}:" . Acl::ALLOW, $access)) {
         return Acl::ALLOW;
     }
     if ($this->redis->exists("rolesInherits:{$role}")) {
         $rolesInherits = $this->redis->sMembers("rolesInherits:{$role}");
         foreach ($rolesInherits as $role) {
             if ($this->redis->sIsMember("accessList:{$role}:{$resource}:" . Acl::ALLOW, $access)) {
                 return Acl::ALLOW;
             }
         }
     }
     /**
      * Return the default access action
      */
     return $this->getDefaultAction();
 }
开发者ID:nineeshk,项目名称:incubator,代码行数:34,代码来源:Redis.php


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