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