添加到集合
root@netkiller ~ % redis-cli -n 16 127.0.0.1:6379[16]> zadd book 1 "Linux" 1 127.0.0.1:6379[16]> zadd book 2 "Java" 1 127.0.0.1:6379[16]> zadd book 3 "Python" 1 127.0.0.1:6379[16]> zadd book 4 "PHP" 1 127.0.0.1:6379[16]>
zrange 查看集合內容
127.0.0.1:6379[16]> zrange book 0 -1 withscores 1) "Linux" 2) "1" 3) "Java" 4) "2" 5) "Perl" 6) "5"
指定開始和結束範圍
127.0.0.1:6379[16]> zrange book 0 4 Linux Java Python PHP 127.0.0.1:6379[16]> zrange book 1 4 Java Python PHP 127.0.0.1:6379[16]> zrange book 2 3 Python PHP
zrem 刪除集合成員
127.0.0.1:6379[16]> zadd book 5 "Rabby" 1 127.0.0.1:6379[16]> zrange book 4 5 Perl Rabby 127.0.0.1:6379[16]> zrem book Rabby 1 127.0.0.1:6379[16]> zrange book 4 5 Perl 127.0.0.1:6379[16]> zrem book PHP Python 2
zcard 返回成員數量
127.0.0.1:6379[16]> zcard book 3