本文整理匯總了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);
}
}
示例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;
}
示例3: isBlacklisted
/**
* @param $sid
*
* @return int
*/
private function isBlacklisted($sid)
{
return $this->redis->sismember('session:blacklist:OracleHookedRedisSessionProvider', $sid);
}
示例4: isOnline
/**
* Check if specific identifier is in set
* @param $identifier
* @return int
*/
public function isOnline($identifier)
{
return $this->redisClient->sismember($this->setName, $identifier);
}
示例5: existsInSet
/**
* 集合是否存在元素 $member
* @param $key
* @param $member
* @return bool
*/
public function existsInSet($key, $member)
{
return (bool) $this->redis->sismember($key, $member);
}
示例6: isExistsRequest
/**
* @param int $keyId
* @param int $searchId
* @return bool
*/
private function isExistsRequest($keyId, $searchId)
{
return $this->redis->sismember($this->getFormattedKey($keyId), $searchId);
}
示例7: existsInSet
public function existsInSet($key, $value)
{
return $this->_client->sismember($key, $value);
}
示例8: remKeyInIndex
private static function remKeyInIndex(Key $key)
{
return self::$_redis->sismember(Key::getIndexKey(), $key->getPrefix()) && self::$_redis->sismember($key->getPrefix(), $key->getSuffix());
}
示例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);
}