当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::zAdd方法代码示例

本文整理汇总了PHP中Redis::zAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::zAdd方法的具体用法?PHP Redis::zAdd怎么用?PHP Redis::zAdd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


在下文中一共展示了Redis::zAdd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 public function add($word, $score = 0)
 {
     $word = str_replace(' ', '', trim($word));
     $len = mb_strlen($word, 'UTF-8');
     if (!$len) {
         return false;
     }
     echo '=====Word:' . $word . '=====' . PHP_EOL;
     for ($i = 1; $i <= $len; $i++) {
         $key = mb_substr($word, 0, $i, 'UTF-8');
         echo 'key=' . $key . PHP_EOL;
         if (!$this->redis->zAdd($this->key_prefix . $key, 0, $word)) {
             return false;
         }
     }
     return $this->redis->zAdd($this->word_prefix, intval($score), $word);
 }
开发者ID:sinopex,项目名称:self-learning-project,代码行数:17,代码来源:Suggest.php

示例2: logRequest

 /**
  * @inheritdoc
  */
 public function logRequest($url, \DateTime $date = null)
 {
     if (null === $date) {
         $date = new \DateTime();
     }
     $timestamp = $date->getTimestamp();
     $hashKey = $this->getHashKey($timestamp, $url);
     $this->redis->zAdd($this->key, $timestamp, $hashKey);
 }
开发者ID:treehouselabs,项目名称:io-bundle,代码行数:12,代码来源:RedisRequestLogger.php

示例3: push

 /**
  * @see QueueInterface::push()
  */
 public function push(TaskInterface $task)
 {
     $eta = $task->getEta() ?: new \DateTime();
     $score = $eta->getTimestamp();
     $unique = $this->redis->incr('sequence');
     $member = $unique . '@' . $this->serializer->serialize($task);
     $result = $this->redis->zAdd('tasks', $score, $member);
     if (!$result) {
         throw new \RuntimeException(sprintf('Unable to push the task %s.', $task));
     }
 }
开发者ID:rybakit,项目名称:taskqueue,代码行数:14,代码来源:RedisQueue.php

示例4: state

 /**
  * 改变状态
  *
  * @param $state
  * @return $this
  */
 protected function state($state)
 {
     $setKey = $this->queue->name . ':' . self::JOBS_TAB;
     $this->client->zRem($setKey . ':' . $this->injectors['state'], $this->injectors['id']);
     $this->client->zRem($setKey . ':' . $this->injectors['tube'] . ':' . $this->injectors['state'], $this->injectors['id']);
     $this->set('state', $state);
     $score = $this->injectors['timing'];
     $this->client->zAdd($setKey . ':' . $state, $score, $this->injectors['id']);
     $this->client->zAdd($setKey . ':' . $this->injectors['tube'] . ':' . $state, $score, $this->injectors['id']);
     $this->set('updated_at', Util::now());
     return $this;
 }
开发者ID:lezhizhe,项目名称:RedisQueue-as-like-beanstalkd,代码行数:18,代码来源:Job.php

示例5: add_queue

 /**
  * @author  lix
  * @todo  加入队列处理
  * @param 
  * @return 
  */
 public function add_queue($queue_name = 'test_queue', $val_arr = array(), $max_num = 0)
 {
     $this->config->load('redis', TRUE);
     // $this->debug_dump($this->config);
     $this->debug_dump($this->config->item('redis'));
     $cfg = $this->config->item('redis');
     $rds = new Redis();
     $rds->connect($cfg['host'], $cfg['port']);
     $rds->select(9);
     for ($i = 0; $i < $max_num; $i++) {
         $rds->zAdd($queue_name, $i, $val_arr[$i]);
     }
     return;
 }
开发者ID:r00tjimmy,项目名称:queue-php-redis,代码行数:20,代码来源:test.php

示例6:

    }
    $redis->hMset('test:' . $incr . ':hset', $data);
}
// SET
for ($i = 0; $i <= rand(1000, 10000); $i++) {
    $incr = $redis->incr('test:incr:set');
    for ($j = 0; $j <= rand(10, 100); $j++) {
        $redis->sAdd('test:' . $incr . ':set', $j);
    }
}
// LIST
for ($i = 0; $i <= rand(1000, 10000); $i++) {
    $incr = $redis->incr('test:incr:list');
    for ($j = 0; $j <= rand(10, 100); $j++) {
        $redis->rPush('test:' . $incr . ':list', $j);
    }
}
// STRING
for ($i = 0; $i <= rand(1000, 10000); $i++) {
    $incr = $redis->incr('test:incr:string');
    for ($j = 0; $j <= rand(10, 100); $j++) {
        $redis->set('test:' . $incr . ':string', $j);
    }
}
// ZSET
for ($i = 0; $i <= rand(1000, 10000); $i++) {
    $incr = $redis->incr('test:incr:zset');
    for ($j = 0; $j <= rand(10, 100); $j++) {
        $redis->zAdd('test:' . $incr . ':zset', $j, md5($j));
    }
}
开发者ID:xingcuntian,项目名称:readmin,代码行数:31,代码来源:create-dump-keys.php

示例7: checkSerializer

 private function checkSerializer($mode)
 {
     $this->redis->delete('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->delete('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]);
     // lGetRange
     $this->assertTrue($a === $this->redis->lGetRange('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));
     // lRemove
     $this->assertTrue($this->redis->lRemove('key', $a[3]) === 1);
     $this->assertTrue(array_slice($a, 0, 3) === $this->redis->lGetRange('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->lGetRange('key', 0, -1));
     // sAdd
     $this->redis->delete('key');
     $s = array(1, 'a', array(1, 2, 3), array('k' => 'v'));
     $this->assertTrue(1 === $this->redis->sAdd('key', $s[0]));
     $this->assertTrue(1 === $this->redis->sAdd('key', $s[1]));
     $this->assertTrue(1 === $this->redis->sAdd('key', $s[2]));
     $this->assertTrue(1 === $this->redis->sAdd('key', $s[3]));
     // variadic sAdd
     $this->redis->delete('k');
     $this->assertTrue(3 === $this->redis->sAdd('k', 'a', 'b', 'c'));
     $this->assertTrue(1 === $this->redis->sAdd('k', 'a', 'b', 'c', 'd'));
     // sRemove
     $this->assertTrue(1 === $this->redis->sRemove('key', $s[3]));
     $this->assertTrue(0 === $this->redis->sRemove('key', $s[3]));
     // variadic
     $this->redis->delete('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'));
     // sContains
     $this->assertTrue(TRUE === $this->redis->sContains('key', $s[0]));
     $this->assertTrue(TRUE === $this->redis->sContains('key', $s[1]));
     $this->assertTrue(TRUE === $this->redis->sContains('key', $s[2]));
     $this->assertTrue(FALSE === $this->redis->sContains('key', $s[3]));
     unset($s[3]);
     // sMove
     $this->redis->delete('tmp');
     $this->redis->sMove('key', 'tmp', $s[0]);
     $this->assertTrue(FALSE === $this->redis->sContains('key', $s[0]));
     $this->assertTrue(TRUE === $this->redis->sContains('tmp', $s[0]));
     unset($s[0]);
     // sorted sets
     $z = array('z0', array('k' => 'v'), FALSE, NULL);
     $this->redis->delete('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]));
     // zDelete
     $this->assertTrue(1 === $this->redis->zDelete('key', $z[3]));
     $this->assertTrue(0 === $this->redis->zDelete('key', $z[3]));
     unset($z[3]);
     // check that zDelete doesn't crash with a missing parameter (GitHub issue #102):
     $this->assertTrue(FALSE === @$this->redis->zDelete('key'));
     // variadic
     $this->redis->delete('k');
     $this->redis->zAdd('k', 0, 'a');
     $this->redis->zAdd('k', 1, 'b');
     $this->redis->zAdd('k', 2, 'c');
     $this->assertTrue(2 === $this->redis->zDelete('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:stonegithubs,项目名称:phpredis,代码行数:101,代码来源:TestRedis.php

示例8: die

$guanyintea_keys = $redis->keys('guanyintea*');
foreach ($guanyintea_keys as $key) {
    if ($redis->exists($key)) {
        $redis->delete($key);
        echo $key . " delete success " . PHP_EOL;
    } else {
        die('delete table guanyintea key not exists');
    }
}
$sql = 'select * from guanyintea';
$result = mysql_query($sql);
$i = 0;
while ($guanyintea_res = mysql_fetch_array($result)) {
    $redis->set('guanyintea:product_id:title:' . $guanyintea_res['product_id'], $guanyintea_res['title']);
    $redis->set('guanyintea:product_id:old_price:' . $guanyintea_res['product_id'], $guanyintea_res['old_price']);
    $redis->set('guanyintea:product_id:new_price:' . $guanyintea_res['product_id'], $guanyintea_res['new_price']);
    $redis->set('guanyintea:product_id:subhead:' . $guanyintea_res['product_id'], $guanyintea_res['subhead']);
    $redis->set('guanyintea:product_id:weight:' . $guanyintea_res['product_id'], $guanyintea_res['weight']);
    $redis->set('guanyintea:product_id:product_num:' . $guanyintea_res['product_id'], $guanyintea_res['product_num']);
    if ($guanyintea_res['is_show'] == 1) {
        $redis->zAdd('guanyintea:is_show:product_id:1:', $i, $guanyintea_res['product_id']);
    } else {
        $redis->zAdd('guanyintea:is_show:product_id:0:', $i, $guanyintea_res['product_id']);
    }
    echo 'guanyintea ' . $guanyintea_res['product_id'] . ' update success' . PHP_EOL;
    $i++;
}
mysql_free_result($result);
echo 'table guanyintea update success ' . PHP_EOL;
mysql_close($mysql_conn);
echo 'update success';
开发者ID:linfasfasf,项目名称:yinghemall,代码行数:31,代码来源:redis_migrate.php

示例9: Redis

<?php

header("Content-type:text/html;charset='utf-8'");
//######################
$redis = new Redis();
$redis->connect('localhost', '6379');
#此处加上验证更安全
$wytypeid = $redis->zRangeByScore('zjseowytypeid', '-inf', '+inf', array('withscores' => false));
//如果为数组为0的话,组件一个0~19的数组,没执行一次sPop随机返回并删除名称为key的set中一个元素
//$redis->DEL('typeid');
if (count($wytypeid) == 0) {
    for ($i = 0; $i < 10; $i++) {
        $redis->zAdd('zjseowytypeid', $i, $i);
    }
    $wytypeid = $redis->zRangeByScore('zjseowytypeid', '-inf', '+inf', array('withscores' => false));
}
$randwytypeid = array_rand($wytypeid);
//取得key
$lanmu = $wytypeid[$randwytypeid];
//根据key删除值
$redis->zRemRangeByScore('zjseowytypeid', $lanmu, $lanmu);
//根据取得要删除的key选择一个相等的值去除
//var_dump($wytypeid);exit;
$jkysid = array(47, 48, 49, 50, 51, 52, 53, 54, 55, 56);
//这里是对应的织梦后台栏目
//对应10个栏目的id
//var_dump($wyurl);
$type = $jkysid[$lanmu];
//根据上面取到的得到要插入数据的栏目
//////////////////////////////////////////【获取关键词开始】//////////////////////////////////////////////////////
//获取关键词从redis中[每获取一个就删除一个,知道关键词耗尽]
开发者ID:l496501043,项目名称:first,代码行数:31,代码来源:weixin_wz.php

示例10: zAdd

 /**
  * @param string $key
  * @param float  $score
  * @param string $value
  */
 public function zAdd($key, $score, $value)
 {
     $this->_redis->zAdd($key, $score, $value);
 }
开发者ID:aladin1394,项目名称:CM,代码行数:9,代码来源:Client.php

示例11: count

$len = count($userset);
echo 'user count: ' . $len, PHP_EOL;
//generate 1-dim ran
$i = 0;
$tb = microtime(true);
foreach ($userset as $uid) {
    $pipeline->sCard($uid);
    if ($i % 10000 == 0) {
        echo '*';
    }
    $i++;
}
$tempArray = $pipeline->exec();
$i = 0;
foreach ($userset as $index => $uid) {
    $redis->zAdd('rank-1', $tempArray[$index], $uid);
    if ($i % 10000 == 0) {
        echo '.';
    }
    $i++;
}
echo PHP_EOL;
$te = microtime(true);
$cost = $te - $tb;
echo 'generate 1-dim rank cost: ' . $cost, PHP_EOL;
//generate 2-dim rank
$tb = microtime(true);
$i = 0;
foreach ($userset as $uid) {
    $pipeline->sMembers($uid);
    if ($i % 10000 == 0) {
开发者ID:shenxinyu,项目名称:redis_rank,代码行数:31,代码来源:rank.php

示例12: remakeRedis

 function remakeRedis()
 {
     $total_cnt = 0;
     $redis = new \Redis();
     try {
         $redis->connect('127.0.0.1', '6379', 2.5, NULL, 150);
         if ($redis->select(1) == false) {
             \CADB\RespondJson::ResultPage(array(-1, 'redis 데이터베이스에 연결할 수 없습니다.'));
         }
         $redis->flushDb();
         if (is_array($this->autocomplete)) {
             foreach ($this->autocomplete as $k => $_data) {
                 foreach ($_data as $data) {
                     $redis->zAdd($k, $data['score'], $data['name']);
                     $total_cnt++;
                 }
             }
         }
     } catch (RedisException $e) {
         var_dump($e);
     }
     $redis->close();
     \CADB\RespondJson::ResultPage(array(0, $total_cnt . '건의 자동완성문장을 입력했습니다.'));
 }
开发者ID:jinbonetwork,项目名称:collective-agreement-database,代码行数:24,代码来源:save.php

示例13: testZX

 public function testZX()
 {
     $this->redis->delete('key');
     $this->assertTrue(array() === $this->redis->zRange('key', 0, -1));
     $this->assertTrue(array() === $this->redis->zRange('key', 0, -1, true));
     $this->assertTrue(1 === $this->redis->zAdd('key', 0, 'val0'));
     $this->assertTrue(1 === $this->redis->zAdd('key', 2, 'val2'));
     $this->assertTrue(1 === $this->redis->zAdd('key', 1, 'val1'));
     $this->assertTrue(1 === $this->redis->zAdd('key', 3, 'val3'));
     $this->assertTrue(array('val0', 'val1', 'val2', 'val3') === $this->redis->zRange('key', 0, -1));
     // withscores
     $ret = $this->redis->zRange('key', 0, -1, true);
     $this->assertTrue(count($ret) == 4);
     $this->assertTrue($ret['val0'] == 0);
     $this->assertTrue($ret['val1'] == 1);
     $this->assertTrue($ret['val2'] == 2);
     $this->assertTrue($ret['val3'] == 3);
     $this->assertTrue(0 === $this->redis->zDelete('key', 'valX'));
     $this->assertTrue(1 === $this->redis->zDelete('key', 'val3'));
     $this->assertTrue(array('val0', 'val1', 'val2') === $this->redis->zRange('key', 0, -1));
     // zGetReverseRange
     $this->assertTrue(1 === $this->redis->zAdd('key', 3, 'val3'));
     $this->assertTrue(1 === $this->redis->zAdd('key', 3, 'aal3'));
     $zero_to_three = $this->redis->zRangeByScore('key', 0, 3);
     $this->assertTrue(array('val0', 'val1', 'val2', 'aal3', 'val3') === $zero_to_three || array('val0', 'val1', 'val2', 'val3', 'aal3') === $zero_to_three);
     $this->assertTrue(5 === $this->redis->zCount('key', 0, 3));
     // withscores
     $this->redis->zRemove('key', 'aal3');
     $zero_to_three = $this->redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE));
     $this->assertTrue(array('val0' => 0, 'val1' => 1, 'val2' => 2, 'val3' => 3) == $zero_to_three);
     $this->assertTrue(4 === $this->redis->zCount('key', 0, 3));
     // limit
     $this->assertTrue(array('val0') === $this->redis->zRangeByScore('key', 0, 3, array('limit' => array(0, 1))));
     $this->assertTrue(array('val0', 'val1') === $this->redis->zRangeByScore('key', 0, 3, array('limit' => array(0, 2))));
     $this->assertTrue(array('val1', 'val2') === $this->redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 2))));
     $this->assertTrue(array('val0', 'val1') === $this->redis->zRangeByScore('key', 0, 1, array('limit' => array(0, 100))));
     $this->assertTrue(4 === $this->redis->zSize('key'));
     $this->assertTrue(1.0 === $this->redis->zScore('key', 'val1'));
     $this->assertFalse($this->redis->zScore('key', 'val'));
     $this->assertFalse($this->redis->zScore(3, 2));
     // zincrby
     $this->redis->delete('key');
     $this->assertTrue(1.0 === $this->redis->zIncrBy('key', 1, 'val1'));
     $this->assertTrue(1.0 === $this->redis->zScore('key', 'val1'));
     $this->assertTrue(2.5 === $this->redis->zIncrBy('key', 1.5, 'val1'));
     $this->assertTrue(2.5 === $this->redis->zScore('key', 'val1'));
     //zUnion
     $this->redis->delete('key1');
     $this->redis->delete('key2');
     $this->redis->delete('key3');
     $this->redis->delete('keyU');
     $this->redis->zAdd('key1', 0, 'val0');
     $this->redis->zAdd('key1', 1, 'val1');
     $this->redis->zAdd('key2', 2, 'val2');
     $this->redis->zAdd('key2', 3, 'val3');
     $this->redis->zAdd('key3', 4, 'val4');
     $this->redis->zAdd('key3', 5, 'val5');
     $this->assertTrue(4 === $this->redis->zUnion('keyU', array('key1', 'key3')));
     $this->assertTrue(array('val0', 'val1', 'val4', 'val5') === $this->redis->zRange('keyU', 0, -1));
     // Union on non existing keys
     $this->redis->delete('keyU');
     $this->assertTrue(0 === $this->redis->zUnion('keyU', array('X', 'Y')));
     $this->assertTrue(array() === $this->redis->zRange('keyU', 0, -1));
     // !Exist U Exist
     $this->redis->delete('keyU');
     $this->assertTrue(2 === $this->redis->zUnion('keyU', array('key1', 'X')));
     $this->assertTrue($this->redis->zRange('key1', 0, -1) === $this->redis->zRange('keyU', 0, -1));
     // test weighted zUnion
     $this->redis->delete('keyZ');
     $this->assertTrue(4 === $this->redis->zUnion('keyZ', array('key1', 'key2'), array(1, 1)));
     $this->assertTrue(array('val0', 'val1', 'val2', 'val3') === $this->redis->zRange('keyZ', 0, -1));
     $this->redis->zDeleteRangeByScore('keyZ', 0, 10);
     $this->assertTrue(4 === $this->redis->zUnion('keyZ', array('key1', 'key2'), array(5, 1)));
     $this->assertTrue(array('val0', 'val2', 'val3', 'val1') === $this->redis->zRange('keyZ', 0, -1));
     $this->redis->delete('key1');
     $this->redis->delete('key2');
     $this->redis->delete('key3');
     // zInter
     $this->redis->zAdd('key1', 0, 'val0');
     $this->redis->zAdd('key1', 1, 'val1');
     $this->redis->zAdd('key1', 3, 'val3');
     $this->redis->zAdd('key2', 2, 'val1');
     $this->redis->zAdd('key2', 3, 'val3');
     $this->redis->zAdd('key3', 4, 'val3');
     $this->redis->zAdd('key3', 5, 'val5');
     $this->redis->delete('keyI');
     $this->assertTrue(2 === $this->redis->zInter('keyI', array('key1', 'key2')));
     $this->assertTrue(array('val1', 'val3') === $this->redis->zRange('keyI', 0, -1));
     // Union on non existing keys
     $this->assertTrue(0 === $this->redis->zInter('keyX', array('X', 'Y')));
     $this->assertTrue(array() === $this->redis->zRange('keyX', 0, -1));
     // !Exist U Exist
     $this->assertTrue(0 === $this->redis->zInter('keyY', array('key1', 'X')));
     $this->assertTrue(array() === $this->redis->zRange('keyY', 0, -1));
     // test weighted zInter
     $this->redis->delete('key1');
     $this->redis->delete('key2');
     $this->redis->delete('key3');
     $this->redis->zAdd('key1', 0, 'val0');
     $this->redis->zAdd('key1', 1, 'val1');
//.........这里部分代码省略.........
开发者ID:virtulis,项目名称:phpredis,代码行数:101,代码来源:TestRedis.php

示例14: getredis

 public function getredis()
 {
     die;
     $redis = new Redis();
     $redis->connect('121.40.144.140', 6379);
     $result = $redis->set('test', "11111111111");
     //var_dump($result);    //结果:bool(true)
     $getinfo = $redis->get('test');
     var_dump($getinfo);
     $redis->delete('test');
     //写入排行榜
     $redis->zAdd('readsort', 45, '1');
     $redis->zAdd('readsort', 5, '2');
     $redis->zAdd('readsort', 55, '3');
     $redis->zAdd('readsort', 45, '4');
     $redis->zAdd('readsort', 86, '5');
     $redis->zAdd('readsort', 8, '6');
     $redis->zDelete('readsort', '6');
     $redis->zDelete('readsort', '5');
     $redis->zDelete('readsort', '4');
     $redis->zDelete('readsort', '3');
     $redis->zDelete('readsort', '2');
     $redis->zDelete('readsort', '1');
     //$data=$redis->zRange('readsort',0,-1,true);
     //从大到小排列zRevRange
     $data = $redis->zRevRange('readsort', 0, -1, true);
     var_dump($data);
 }
开发者ID:xtzlyp,项目名称:xtzlyp_blog,代码行数:28,代码来源:IndexController.class.php

示例15: setAdd

 /**
  * 将value写入set集合 如果value存在 不写入 返回false
  * 如果是有序集合则根据score值更新该元素的顺序
  * @param $set string 集合名
  * @param $value mixed 值
  * @param $stype int 集合类型 0:无序集合 1:有序集和 默认0
  * @param $score int 元素排序值
  */
 public static function setAdd($set, $value = null, $stype = 0, $score = null)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     if ($stype && $score !== null) {
         $return = $redis->zAdd($set, $score, $value);
     } else {
         $return = $redis->sAdd($set, $value);
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:22,代码来源:MyRedis.class.php


注:本文中的Redis::zAdd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。