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


PHP Redis::srem方法代碼示例

本文整理匯總了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']]);
 }
開發者ID:mgdigital,項目名稱:busque,代碼行數:7,代碼來源:PHPRedisAdapterSpec.php

示例2: removeSurvey

 public function removeSurvey($surveyID)
 {
     if (!$this->exists()) {
         return;
     }
     Redis::srem("User:{$this->id}:surveys", $surveyID);
 }
開發者ID:nickyleach,項目名稱:OSTSurvey,代碼行數:7,代碼來源:User.php

示例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();
 }
開發者ID:stevenharradine,項目名稱:php-dark-launch,代碼行數:11,代碼來源:Dark_Launch.php

示例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();
 }
開發者ID:kkwoker,項目名稱:php-dark-launch,代碼行數:12,代碼來源:Dark_Launch.php

示例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);
     }
 }
開發者ID:nosun,項目名稱:php-resque-cronjob,代碼行數:15,代碼來源:ResqueStatus.php

示例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);
開發者ID:kunx-edu,項目名稱:tp1030,代碼行數:27,代碼來源:test.php

示例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++) {
開發者ID:isS,項目名稱:NoSQL,代碼行數:31,代碼來源:redisWithPHP.php

示例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]));
//.........這裏部分代碼省略.........
開發者ID:Jerry-Shaw,項目名稱:phpredis,代碼行數:101,代碼來源:RedisTest.php


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