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是否有 ...
随机推荐
- AppServ 配置还是成功了
安装就不说了,一键式安装,还不错. 首先,登陆密码吧,用户是root ,密码是空: 之前创建的databases都还在, 可以用phpmyadmin管理,不在输入复杂的命令了, 方便,继续鼓捣php.
- 创建类模式(零):简单/静态工厂(Static Factory)
定义 简单工厂模式属于创建型模式,但不属于23种GOF设计模式之一,这也是为什么该模式标记为零的原因.简单工厂模式是由一个工厂对象决定创建出哪一种产品类的实例.简单工厂模式是工厂模式家族中最简单实用的 ...
- PHP再学习1——cURL表单提交、HTTP请求和响应分析
1.前言 最近迷恋WEB方面的技术,虽然自己是一个嵌入式工程师,但是我深知若需要把传感器终端的数据推送至“平台”必然会和WEB技术打交道.在工作中发现嵌入式工程师喜欢 二进制形式的协议,例如MODBU ...
- javax.naming.NameNotFoundException
2015-08-27 09:53:16,463 [localhost-startStop-1] DEBUG [org.springframework.jndi.JndiTemplate] - Look ...
- BZOJ 1043 HAOI2008 下落的圆盘 计算几何
题目大意:n个圆盘依次下落.求终于能看到的轮廓线面积 円盘反对! 让我们一起团结起来! 赶走円盘! 咳咳.非常神的一道题 今天去看了题解和白书才搞出来-- 首先我们倒着做 对于每一个圆盘处理出在它之后 ...
- 【转】DLX 精确覆盖 重复覆盖
问题描述: 给定一个n*m的矩阵,有些位置为1,有些位置为0.如果G[i][j]==1则说明i行可以覆盖j列. Problem: 1)选定最少的行,使得每列有且仅有一个1. 2)选定最少的行,使得每列 ...
- [MODX] 2. Chunks $
Chunk in Modx can cut your template into samll pieces to make code reuseable. [[$chunk_name]] For ex ...
- [AngularJS] Javascript scope and AngularJS $scope
Scope resolution of our Angular documents works exactly the same way scope resolution works in plain ...
- [AngularJS] ngCloak
The ngCloak directive is used to prevent the Angular html template from being briefly displayed by t ...
- 《RESTful Web Services》第三章 设计表述
3.1 如何使用实体头来注解表述 表述不仅仅是以某种格式序列化后的数据,它是一连串字节加上用于描述那些字节的元数据. Content-Type,用于描述表述类型.这个标头告诉接收方如何 ...