當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::sismember方法代碼示例

本文整理匯總了PHP中Predis\Client::sismember方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::sismember方法的具體用法?PHP Client::sismember怎麽用?PHP Client::sismember使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Predis\Client的用法示例。


在下文中一共展示了Client::sismember方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: followOrUnfollow

 /**
  * @param int $userId
  */
 public function followOrUnfollow($userId)
 {
     if ($this->sessionUserId === $userId) {
         return;
     }
     if (!$this->redisClient->sismember("uid:" . $this->sessionUserId . ":following", $userId)) {
         $this->follow($userId);
     } else {
         $this->unfollow($userId);
     }
 }
開發者ID:KrunoKnego,項目名稱:Symfony-Twitter-Clone,代碼行數:14,代碼來源:RedisFollow.php

示例2: checkKeyContains

 /**
  * Checks whether a key contains a given item
  *
  * @param string $key       The key
  * @param mixed  $item      The item
  * @param null   $itemValue Optional and only used for zsets and hashes. If
  * specified, the method will also check that the $item has this value/score
  *
  * @return bool
  *
  * @throws ModuleException
  */
 private function checkKeyContains($key, $item, $itemValue = null)
 {
     $result = null;
     if (!is_scalar($item)) {
         throw new ModuleException($this, "All arguments of [dont]seeRedisKeyContains() must be scalars");
     }
     switch ($this->driver->type($key)) {
         case 'string':
             $reply = $this->driver->get($key);
             $result = strpos($reply, $item) !== false;
             break;
         case 'list':
             $reply = $this->driver->lrange($key, 0, -1);
             $result = in_array($item, $reply);
             break;
         case 'set':
             $result = $this->driver->sismember($key, $item);
             break;
         case 'zset':
             $reply = $this->driver->zscore($key, $item);
             if (is_null($reply)) {
                 $result = false;
             } elseif (!is_null($itemValue)) {
                 $result = (double) $reply === (double) $itemValue;
             } else {
                 $result = true;
             }
             break;
         case 'hash':
             $reply = $this->driver->hget($key, $item);
             $result = is_null($itemValue) ? !is_null($reply) : (string) $reply === (string) $itemValue;
             break;
         case 'none':
             throw new ModuleException($this, "Key \"{$key}\" does not exist");
             break;
     }
     return $result;
 }
開發者ID:solutionDrive,項目名稱:Codeception,代碼行數:50,代碼來源:Redis.php

示例3: isBlacklisted

 /**
  * @param $sid
  *
  * @return int
  */
 private function isBlacklisted($sid)
 {
     return $this->redis->sismember('session:blacklist:OracleHookedRedisSessionProvider', $sid);
 }
開發者ID:akentner,項目名稱:incoming-ftp,代碼行數:9,代碼來源:OracleHookedRedisSessionProvider.php

示例4: isOnline

 /**
  * Check if specific identifier is in set
  * @param $identifier
  * @return int
  */
 public function isOnline($identifier)
 {
     return $this->redisClient->sismember($this->setName, $identifier);
 }
開發者ID:mikicaivosevic,項目名稱:online-users,代碼行數:9,代碼來源:RedisStorage.php

示例5: existsInSet

 /**
  * 集合是否存在元素 $member
  * @param $key
  * @param $member
  * @return bool
  */
 public function existsInSet($key, $member)
 {
     return (bool) $this->redis->sismember($key, $member);
 }
開發者ID:inhere,項目名稱:php-librarys,代碼行數:10,代碼來源:Redis.php

示例6: isExistsRequest

 /**
  * @param int $keyId
  * @param int $searchId
  * @return bool
  */
 private function isExistsRequest($keyId, $searchId)
 {
     return $this->redis->sismember($this->getFormattedKey($keyId), $searchId);
 }
開發者ID:avelov,項目名稱:techery_friends,代碼行數:9,代碼來源:RequestedFriendsService.php

示例7: existsInSet

 public function existsInSet($key, $value)
 {
     return $this->_client->sismember($key, $value);
 }
開發者ID:Antevenio,項目名稱:redis,代碼行數:4,代碼來源:Client.php

示例8: remKeyInIndex

 private static function remKeyInIndex(Key $key)
 {
     return self::$_redis->sismember(Key::getIndexKey(), $key->getPrefix()) && self::$_redis->sismember($key->getPrefix(), $key->getSuffix());
 }
開發者ID:chriskite,項目名稱:rem,代碼行數:4,代碼來源:Rem.php

示例9: testHandleLogWithGoodMessageNotImplementingJobInterface

 public function testHandleLogWithGoodMessageNotImplementingJobInterface()
 {
     $worker = new WorkerPresence();
     $worker->setMemory(12345);
     $frame = new Frame('MESSAGE', array('delivery_tag' => 'delivery-' . mt_rand()), $worker->toJson());
     $loop = LoopFactory::create();
     $options = array('eventloop' => $loop, 'on_error' => array($this, 'throwRedisError'));
     $redisSync = new PredisSync('tcp://127.0.0.1:6379');
     $redisSync->connect();
     $resolver = $this->getResolver();
     $resolver->expects($this->once())->method('ack');
     $done = false;
     $phpunit = $this;
     $redis = new PredisAsync('tcp://127.0.0.1:6379', $options);
     $redis->connect(function () use($resolver, $phpunit, $redis, $frame, $redisSync, &$done, $worker) {
         $component = new LogBuilderComponent();
         $component->handleLog($redis, $phpunit->getLogger(), $frame, $resolver)->then(function ($hashId) use($phpunit, $redis, $redisSync, &$done, $worker) {
             $redis->disconnect();
             $phpunit->assertEquals($worker->toJson(), $redisSync->get($hashId));
             $phpunit->assertTrue($redisSync->sismember('garbages', $hashId));
             $done = true;
         });
     });
     $loop->run();
     $this->assertTrue($done);
 }
開發者ID:gloubster,項目名稱:server,代碼行數:26,代碼來源:LogBuilderComponentTest.php


注:本文中的Predis\Client::sismember方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。