本文整理汇总了PHP中Redis::srem方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::srem方法的具体用法?PHP Redis::srem怎么用?PHP Redis::srem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redis
的用法示例。
在下文中一共展示了Redis::srem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: it_can_srem
public function it_can_srem()
{
$this->redis->srem('test', 'test')->shouldBeCalled();
$this->sRem('test', ['test']);
$this->redis->srem('test', 'test')->willThrow(new \RedisException());
$this->shouldThrow(DriverException::class)->during('sRem', ['test', ['test']]);
}
示例2: removeSurvey
public function removeSurvey($surveyID)
{
if (!$this->exists()) {
return;
}
Redis::srem("User:{$this->id}:surveys", $surveyID);
}
示例3: disable_feature
/**
* Disable a dark launch feature
* @param $feature string - The name of the feature
*/
public function disable_feature($feature_name)
{
$multi = $this->redis->multi();
$this->redis->del("{$this->feature_namespace()}:feature:{$feature_name}");
$this->redis->srem("{$this->feature_namespace()}:features", $feature_name);
$multi->exec();
}
示例4: disable_feature
/**
* Disable a dark launch feature
* @param $feature string - The name of the feature
*/
public function disable_feature($feature_name)
{
$feature_name = str_replace('_', '-', $feature_name);
$multi = $this->redis->multi();
$this->redis->hdel("{$this->_feature_namespace()}:feature", $feature_name);
$this->redis->srem("{$this->_feature_namespace()}:features", $feature_name);
$multi->exec();
}
示例5: setPausedWorker
/**
* Mark a worker as paused/active
*
* @since 0.0.1
* @param string $workerName Name of the paused worker
* @param bool $paused Whether to mark the worker as paused or active
*/
public function setPausedWorker($workerName, $paused = true)
{
if ($paused) {
$this->redis->sadd(self::$pausedWorkerKey, $workerName);
} else {
$this->redis->srem(self::$pausedWorkerKey, $workerName);
}
}
示例6: Redis
<?php
//$file = 'lock.lock';
//$fp = fopen($file,'r+');
//$flag1 = flock($fp,LOCK_EX);
//
//
//$fp2 = fopen($file,'r+');
////$flag2 = flock($fp2,LOCK_EX);
////var_dump($flag1,$flag2);
/**
* redis锁
*/
$redis = new Redis();
$redis->conncec('127.0.0.1', 6379);
$redis = new Redis();
$redis->conncec('127.0.0.1', 6379);
for ($i = 0; $i < 3; ++$i) {
if ($redis->isMember(1)) {
sleep(1);
} else {
$redis->sadd('lock_stock', 1);
break;
}
}
//正常的扣库存流程了
$redis->srem('stock_lock', 1);
示例7: rand
$redis->lpop("list");
$redis->rpop("list");
echo $redis->lsize("list");
echo $redis->lget("list", 0);
echo $redis->lset("list", 1, "new_value");
$data = $redis->lRange("list", 0, -1);
echo "<pre>";
print_r($data);
$bool = $redis->ltrim("list", 0, 5);
echo $redis->lrem("list", "5");
$bool = $redis->rpoplpush("srcKey", "dstKey");
// SET
for ($i = 0; $i < 10; $i++) {
$redis->sadd("myset", $i + rand(10, 99));
}
$bool = $redis->srem("myset", 16);
echo (int) $bool;
$bool = $redis->sMove("myset", "myset1", 35);
echo $bool;
$data = $redis->smembers("myset");
$bool = $redis->sismember("myset", 555);
echo (int) $bool;
echo $redis->scard("myset");
$redis->sinterstore("output", "myset", "myset1");
$data = $redis->smembers("output");
echo "<pre>";
// sort
$data = $redis->sort("myset", array("sort" => "desc"));
echo "<pre>";
print_r($data);
for ($i = 0; $i < 10; $i++) {
示例8: checkSerializer
private function checkSerializer($mode)
{
$this->redis->del('key');
$this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === Redis::SERIALIZER_NONE);
// default
$this->assertTrue($this->redis->setOption(Redis::OPT_SERIALIZER, $mode) === TRUE);
// set ok
$this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === $mode);
// get ok
// lPush, rPush
$a = array('hello world', 42, TRUE, array('<tag>' => 1729));
$this->redis->del('key');
$this->redis->lPush('key', $a[0]);
$this->redis->rPush('key', $a[1]);
$this->redis->rPush('key', $a[2]);
$this->redis->rPush('key', $a[3]);
// lrange
$this->assertTrue($a === $this->redis->lrange('key', 0, -1));
// lGet
$this->assertTrue($a[0] === $this->redis->lGet('key', 0));
$this->assertTrue($a[1] === $this->redis->lGet('key', 1));
$this->assertTrue($a[2] === $this->redis->lGet('key', 2));
$this->assertTrue($a[3] === $this->redis->lGet('key', 3));
// lrem
$this->assertTrue($this->redis->lrem('key', $a[3]) === 1);
$this->assertTrue(array_slice($a, 0, 3) === $this->redis->lrange('key', 0, -1));
// lSet
$a[0] = array('k' => 'v');
// update
$this->assertTrue(TRUE === $this->redis->lSet('key', 0, $a[0]));
$this->assertTrue($a[0] === $this->redis->lGet('key', 0));
// lInsert
$this->assertTrue($this->redis->lInsert('key', Redis::BEFORE, $a[0], array(1, 2, 3)) === 4);
$this->assertTrue($this->redis->lInsert('key', Redis::AFTER, $a[0], array(4, 5, 6)) === 5);
$a = array(array(1, 2, 3), $a[0], array(4, 5, 6), $a[1], $a[2]);
$this->assertTrue($a === $this->redis->lrange('key', 0, -1));
// sAdd
$this->redis->del('{set}key');
$s = array(1, 'a', array(1, 2, 3), array('k' => 'v'));
$this->assertTrue(1 === $this->redis->sAdd('{set}key', $s[0]));
$this->assertTrue(1 === $this->redis->sAdd('{set}key', $s[1]));
$this->assertTrue(1 === $this->redis->sAdd('{set}key', $s[2]));
$this->assertTrue(1 === $this->redis->sAdd('{set}key', $s[3]));
// variadic sAdd
$this->redis->del('k');
$this->assertTrue(3 === $this->redis->sAdd('k', 'a', 'b', 'c'));
$this->assertTrue(1 === $this->redis->sAdd('k', 'a', 'b', 'c', 'd'));
// srem
$this->assertTrue(1 === $this->redis->srem('{set}key', $s[3]));
$this->assertTrue(0 === $this->redis->srem('{set}key', $s[3]));
// variadic
$this->redis->del('k');
$this->redis->sAdd('k', 'a', 'b', 'c', 'd');
$this->assertTrue(2 === $this->redis->sRem('k', 'a', 'd'));
$this->assertTrue(2 === $this->redis->sRem('k', 'b', 'c', 'e'));
$this->assertTrue(FALSE === $this->redis->exists('k'));
// sismember
$this->assertTrue(TRUE === $this->redis->sismember('{set}key', $s[0]));
$this->assertTrue(TRUE === $this->redis->sismember('{set}key', $s[1]));
$this->assertTrue(TRUE === $this->redis->sismember('{set}key', $s[2]));
$this->assertTrue(FALSE === $this->redis->sismember('{set}key', $s[3]));
unset($s[3]);
// sMove
$this->redis->del('{set}tmp');
$this->redis->sMove('{set}key', '{set}tmp', $s[0]);
$this->assertTrue(FALSE === $this->redis->sismember('{set}key', $s[0]));
$this->assertTrue(TRUE === $this->redis->sismember('{set}tmp', $s[0]));
unset($s[0]);
// sorted sets
$z = array('z0', array('k' => 'v'), FALSE, NULL);
$this->redis->del('key');
// zAdd
$this->assertTrue(1 === $this->redis->zAdd('key', 0, $z[0]));
$this->assertTrue(1 === $this->redis->zAdd('key', 1, $z[1]));
$this->assertTrue(1 === $this->redis->zAdd('key', 2, $z[2]));
$this->assertTrue(1 === $this->redis->zAdd('key', 3, $z[3]));
// zRem
$this->assertTrue(1 === $this->redis->zRem('key', $z[3]));
$this->assertTrue(0 === $this->redis->zRem('key', $z[3]));
unset($z[3]);
// check that zRem doesn't crash with a missing parameter (GitHub issue #102):
$this->assertTrue(FALSE === @$this->redis->zRem('key'));
// variadic
$this->redis->del('k');
$this->redis->zAdd('k', 0, 'a');
$this->redis->zAdd('k', 1, 'b');
$this->redis->zAdd('k', 2, 'c');
$this->assertTrue(2 === $this->redis->zRem('k', 'a', 'c'));
$this->assertTrue(1.0 === $this->redis->zScore('k', 'b'));
$this->assertTrue($this->redis->zRange('k', 0, -1, true) == array('b' => 1.0));
// zRange
$this->assertTrue($z === $this->redis->zRange('key', 0, -1));
// zScore
$this->assertTrue(0.0 === $this->redis->zScore('key', $z[0]));
$this->assertTrue(1.0 === $this->redis->zScore('key', $z[1]));
$this->assertTrue(2.0 === $this->redis->zScore('key', $z[2]));
// zRank
$this->assertTrue(0 === $this->redis->zRank('key', $z[0]));
$this->assertTrue(1 === $this->redis->zRank('key', $z[1]));
$this->assertTrue(2 === $this->redis->zRank('key', $z[2]));
//.........这里部分代码省略.........