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/saddhttp://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/scardhttp://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/sdiffhttp://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/sdiffstorehttp://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/sinterhttp://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/sinterstorehttp://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/sismemberhttp://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/smembershttp://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/smovehttp://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/spophttp://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/srandmemberhttp://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/sremhttp://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/sunionhttp://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/sunionstorehttp://www.redis.cn/commands/sunionstore.html

SSCAN key cursor [MATCH pattern] [COUNT count]

Incrementally iterate Set elements

More: http://redis.io/commands/sscanhttp://www.redis.cn/commands/sscan.html

Redis 命令 - Sets的更多相关文章

  1. 常用 redis 命令(for php)

    Redis 主要能存储 5 种数据结构,分别是 strings,hashes,lists,sets 以及 sorted sets. 新建一个 redis 数据库 $redis = new Redis( ...

  2. redis命令大全

    redis windows下使用及redis命令 Redis 是一个开源,高级的键值对的存储.它经常作为服务端的数据结构,它的键的数据类型能够是strings, hashs, lists, sets( ...

  3. redis命令学习(二) · THIS SPACE

    列表(Lists)操作命令 Redis列表是简单的字符串列表,按照插入顺序排序. 你可以添加一个元素导列表的头部(左边)或者尾部(右边)LPUSH命令插入一个新的元素导头部,而RPUSH插入一个新元素 ...

  4. nosql Redis命令操作详解

    Redis命令操作详解 一.key pattern 查询相应的key (1)redis允许模糊查询key 有3个通配符 *.?.[] (2)randomkey:返回随机key (3)type key: ...

  5. Redis命令拾遗二(散列类型)

    本文版权归博客园和作者吴双共同所有,欢迎转载,转载和爬虫请注明原文地址 :博客园蜗牛NoSql系列地址  http://www.cnblogs.com/tdws/tag/NoSql/ Redis命令拾 ...

  6. redis命令总结

     Redis命令总结 redis 127.0.0.1:6379> info  #查看server版本内存使用连接等信息 redis 127.0.0.1:6379> client list  ...

  7. redis如何执行redis命令

    Redis 命令 Redis 命令用于在 redis 服务上执行操作.所以我们必须要启动Redis服务程序,也就是redis安装目录下的redis-server.exe,你可以双击执行,也可以打开cm ...

  8. Redis命令大全&中文解释&在线测试命令工具&在线中文文档

    在线测试命令地址:http://try.redis.io/ 官方文档:http://redis.io/commands http://redis.io/documentation Redis 命令参考 ...

  9. Redis命令

    redis的常用命令主要分为两个方面.一个是键值相关命令.一个是服务器相关命令(redis-cli进入终端) 1.键值相关命令 keys * 取出当前所有的key exists name 查看n是否有 ...

随机推荐

  1. C#引用传递

    学过C#的人都知道,通过值或通过引用,值类型和引用类型都可以作为方法参数传递.在C#中,不管是值类型或者是引用类型,所有方法参数在默认情况下是通过值传递的. 1)通过值传递值类型 在通过值传递作为方法 ...

  2. 乐观锁--CAS

    悲观锁与乐观锁的区别 悲观锁会把整个对象加锁占为已有后才去做操作,Java中的Synchronized属于悲观锁.悲观锁有一个明显的缺点就是:它不管数据存不存在竞争都加锁,随着并发量增加,且如果锁的时 ...

  3. C#学习笔记(十六):Attribute

    Attribute可以为类或方法添加一些附加的信息,我们可以看看MSDN对Attribute的描述: 公共语言运行时允许你添加类似关键字的描述声明,叫做attributes, 它对程序中的元素进行标注 ...

  4. C++中void型指针

    问题由来: PX_FORCE_INLINE void* operator new(size_t size, const char* handle, const char * filename, int ...

  5. 【PYTHON】二维码生成

    二维码是什么? 二维码从一维码扩展而来,增加另一维具有可读性的条码,用黑白矩形图形表示二进制数据,被设备扫描后获取其中包含的信息,二维码的长度.宽度均记载着数据,二维码具有定位点和容错机制,即便没有辨 ...

  6. Line去年营收超5亿美元 远超竞争对手WhatsApp

    原文地址: http://news.cnblogs.com/n/206072/ 凭借着修改表情取悦国际用户的做法,日本移动消息应用 Line 在全球的用户总数已经超过 4 亿.Line.微信.What ...

  7. UVa784 Maze Exploration

    // 题意:输入一个迷宫,从*开始遍历,把可达点标记为字符# 注意迷宫边界不规则,要用strlen判断. #include<cstdio> #include<cstring> ...

  8. 关于.net中线程原子性的自我总结

    首先来张图,一张 cpu的简图,仅从个人理解角度理解画的 大体 解释下这张图 这是 一张 i5的简图i5 大家都知道 是双核四线程,(超线程技术)l1,l2,l3是 1,2,3级缓存. Cpu工作:每 ...

  9. SAP BW顾问如何保持市场竞争力

    跟大部分电工一样,SAP顾问也经常有迷茫的时候.因为,这个世界变化实在太快了.每一个电工,总是在担心自己会不会被飞速发展的技术所淘汰.那么,作为 一个BW顾问,应该如何保持市场竞争力呢?我觉得需要两个 ...

  10. BZOJ 2733: [HNOI2012]永无乡 启发式合并treap

    2733: [HNOI2012]永无乡 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/pr ...