Redis 命令 - Sets
SADD key member [member ...]
Add one or more members to a set
127.0.0.1:6379> SADD foo hello
(integer) 1
127.0.0.1:6379> SADD foo world
(integer) 1
127.0.0.1:6379> SADD foo hello
(integer) 0
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
More: http://redis.io/commands/sadd, http://www.redis.cn/commands/sadd.html
SCARD key
Get the number of members in a set
127.0.0.1:6379> SADD foo hello world
(integer) 2
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SCARD foo
(integer) 2
127.0.0.1:6379> SMEMBERS none
(empty list or set)
127.0.0.1:6379> SCARD none
(integer) 0
More: http://redis.io/commands/scard, http://www.redis.cn/commands/scard.html
SDIFF key [key ...]
Subtract multiple sets
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SDIFF foo bar
1) "world"
More: http://redis.io/commands/sdiff, http://www.redis.cn/commands/sdiff.html
SDIFFSTORE destination key [key ...]
Subtract multiple sets and store the resulting set in a key
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SDIFFSTORE result foo bar
(integer) 1
127.0.0.1:6379> SMEMBERS result
1) "world"
More: http://redis.io/commands/sdiffstore, http://www.redis.cn/commands/sdiffstore.html
SINTER key [key ...]
Intersect multiple sets
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SINTER foo bar
1) "hello"
More: http://redis.io/commands/sinter, http://www.redis.cn/commands/sinter.html
SINTERSTORE destination key [key ...]
Intersect multiple sets and store the resulting set in a key
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SINTERSTORE result foo bar
(integer) 1
127.0.0.1:6379> SMEMBERS result
1) "hello"
More: http://redis.io/commands/sinterstore, http://www.redis.cn/commands/sinterstore.html
SISMEMBER key member
Determine if a given value is a member of a set
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SISMEMBER foo world
(integer) 1
127.0.0.1:6379> SISMEMBER foo redis
(integer) 0
More: http://redis.io/commands/sismember, http://www.redis.cn/commands/sismember.html
SMEMBERS key
Get all the members in a set
127.0.0.1:6379> SADD foo hello
(integer) 1
127.0.0.1:6379> SADD foo world
(integer) 1
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
More: http://redis.io/commands/smembers, http://www.redis.cn/commands/smembers.html
SMOVE source destination member
Move a member from one set to another
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SMOVE foo bar world
(integer) 1
127.0.0.1:6379> SMEMBERS foo
1) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "world"
2) "hello"
3) "redis"
More: http://redis.io/commands/smove, http://www.redis.cn/commands/smove.html
SPOP key [count]
Remove and return one or multiple random members from a set
127.0.0.1:6379> SADD foo a b c d e
(integer) 5
127.0.0.1:6379> SPOP foo
"b"
127.0.0.1:6379> SMEMBERS foo
1) "d"
2) "a"
3) "c"
4) "e"
127.0.0.1:6379> SPOP foo
"a"
127.0.0.1:6379> SMEMBERS foo
1) "d"
2) "c"
3) "e"
More: http://redis.io/commands/spop, http://www.redis.cn/commands/spop.html
SRANDMEMBER key [count]
Get one or multiple random members from a set
127.0.0.1:6379> SADD foo a b c d
(integer) 4
127.0.0.1:6379> SRANDMEMBER foo
"b"
127.0.0.1:6379> SRANDMEMBER foo
"a"
More: http://redis.io/commands/srandmember, http://www.redis.cn/commands/srandmember.html
SREM key member [member ...]
Remove one or more members from a set
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SREM foo world
(integer) 1
127.0.0.1:6379> SMEMBERS foo
1) "hello"
More: http://redis.io/commands/srem, http://www.redis.cn/commands/srem.html
SUNION key [key ...]
Add multiple sets
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SUNION foo bar
1) "hello"
2) "world"
3) "redis"
More: http://redis.io/commands/sunion, http://www.redis.cn/commands/sunion.html
SUNIONSTORE destination key [key ...]
Add multiple sets and store the resulting set in a key
127.0.0.1:6379> SMEMBERS foo
1) "world"
2) "hello"
127.0.0.1:6379> SMEMBERS bar
1) "hello"
2) "redis"
127.0.0.1:6379> SUNIONSTORE result foo bar
(integer) 3
127.0.0.1:6379> SMEMBERS result
1) "hello"
2) "world"
3) "redis"
More: http://redis.io/commands/sunionstore, http://www.redis.cn/commands/sunionstore.html
SSCAN key cursor [MATCH pattern] [COUNT count]
Incrementally iterate Set elements
More: http://redis.io/commands/sscan, http://www.redis.cn/commands/sscan.html
Redis 命令 - Sets的更多相关文章
- 常用 redis 命令(for php)
Redis 主要能存储 5 种数据结构,分别是 strings,hashes,lists,sets 以及 sorted sets. 新建一个 redis 数据库 $redis = new Redis( ...
- redis命令大全
redis windows下使用及redis命令 Redis 是一个开源,高级的键值对的存储.它经常作为服务端的数据结构,它的键的数据类型能够是strings, hashs, lists, sets( ...
- redis命令学习(二) · THIS SPACE
列表(Lists)操作命令 Redis列表是简单的字符串列表,按照插入顺序排序. 你可以添加一个元素导列表的头部(左边)或者尾部(右边)LPUSH命令插入一个新的元素导头部,而RPUSH插入一个新元素 ...
- nosql Redis命令操作详解
Redis命令操作详解 一.key pattern 查询相应的key (1)redis允许模糊查询key 有3个通配符 *.?.[] (2)randomkey:返回随机key (3)type key: ...
- Redis命令拾遗二(散列类型)
本文版权归博客园和作者吴双共同所有,欢迎转载,转载和爬虫请注明原文地址 :博客园蜗牛NoSql系列地址 http://www.cnblogs.com/tdws/tag/NoSql/ Redis命令拾 ...
- redis命令总结
Redis命令总结 redis 127.0.0.1:6379> info #查看server版本内存使用连接等信息 redis 127.0.0.1:6379> client list ...
- redis如何执行redis命令
Redis 命令 Redis 命令用于在 redis 服务上执行操作.所以我们必须要启动Redis服务程序,也就是redis安装目录下的redis-server.exe,你可以双击执行,也可以打开cm ...
- Redis命令大全&中文解释&在线测试命令工具&在线中文文档
在线测试命令地址:http://try.redis.io/ 官方文档:http://redis.io/commands http://redis.io/documentation Redis 命令参考 ...
- Redis命令
redis的常用命令主要分为两个方面.一个是键值相关命令.一个是服务器相关命令(redis-cli进入终端) 1.键值相关命令 keys * 取出当前所有的key exists name 查看n是否有 ...
随机推荐
- JFinal搭建时,提示着不到contextpath
出项类似html截断现象 原因:此处是由于html不识别contextPath上下文所造成.其根本原因是html中使用contextPath与configHandler中加载的不一致造成(basePa ...
- Windows下sqlmap的使用_01
环境:win8.1 64位 一.下载 首先,需下载SqlMap以及适用于Windows系统的Python.下载地址如下: 1.1.SqlMap下载地址:https://github.com/ ...
- 教你50招提升ASP.NET性能(十八):在处理网站性能问题前,首先验证问题是否出在客户端
(29)Before tackling any website performance issue, first verify the problem isn’t on the client 招数29 ...
- cmp排序hdoj 1106排序
上班之余抽点时间出来写写博文,希望对新接触的朋友有帮助.今天在这里和大家一起学习一下cmp排序 /*标题还是比拟的水吧,但是花的时间还是比拟的多,心不够静*/ #include <iostrea ...
- java搭建finagle(1)
1.新建maven项目 2.pom文件添加依赖 添加3个主要依赖<dependency> <groupId>com.twitter</groupId> <ar ...
- Java模拟登录系统抓取内容【转载】
没有看考勤的习惯,导致我的一天班白上了,都是钱啊,系统也不发个邮件通知下.... 为了避免以后还有类似状况特别写了个java模拟登录抓取考勤内容的方法(部分代码来自网络),希望有人修改后也可以 ...
- Crystal Reports课程01-连接SQL Sever数据库
选择[OLE DB(ADO)] 选择[microsoft DB provider for SQL Sever],点击[下一步] 填写连接的服务器,数据库,用户名,密码等信息,然后点击[下一步] 选择[ ...
- Winform 水印TextBox
方法一: public partial class WaterTextBox : TextBox { private readonly Label lblwaterText = new Label() ...
- Java中Queue类实现
原先在java编程中,Queue的实现都是用LinkedList Queue queue = new LinkedList(); 但正如jdk中所说的那样: 注意,此实现不是同步的.如果多个线程同时访 ...
- quickstack is a tool to take call stack
https://github.com/yoshinorim/quickstack quickstack is a tool to take call stack traces with minimal ...