redis 集合

Posted Halo3224

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis 集合相关的知识,希望对你有一定的参考价值。

 

127.0.0.1:6379> SADD myset1 a b c
(integer) 3
127.0.0.1:6379> SADD web maiziedu.com
(integer) 1
127.0.0.1:6379> SADD web maiziedu.com
(integer) 0
127.0.0.1:6379> SADD web phpfamily.org jd.com
(integer) 2
127.0.0.1:6379> SADD web phpfamily.org jd.com
(integer) 0
127.0.0.1:6379> SADD web phpfamily.org jd.com taobao.com
(integer) 1
127.0.0.1:6379> SMEMBERS web
1) "jd.com"
2) "phpfamily.org"
3) "taobao.com"
4) "maiziedu.com"
127.0.0.1:6379> 
View Code

 

 

 

127.0.0.1:6379> SADD web maiziedu.com
(integer) 1
127.0.0.1:6379> SADD web maiziedu.com
(integer) 0
127.0.0.1:6379> SADD web phpfamily.org jd.com
(integer) 2
127.0.0.1:6379> SADD web phpfamily.org jd.com
(integer) 0
127.0.0.1:6379> SADD web phpfamily.org jd.com taobao.com
(integer) 1
127.0.0.1:6379> SMEMBERS web
1) "jd.com"
2) "phpfamily.org"
3) "taobao.com"
4) "maiziedu.com"
127.0.0.1:6379> SISMEMBER web j
(integer) 0
127.0.0.1:6379> SISMEMBER web jd.com
(integer) 1
127.0.0.1:6379> SISMEMBER web taobao
(integer) 0
127.0.0.1:6379> SISMEMBER web taobao.com
(integer) 1
127.0.0.1:6379> SISMEMBER web3 taobao.com
(integer) 0
127.0.0.1:6379> SMEMBERS web
1) "jd.com"
2) "phpfamily.org"
3) "taobao.com"
4) "maiziedu.com"
127.0.0.1:6379> SREM web jd.com
(integer) 1
127.0.0.1:6379> SMEMBERS web
1) "phpfamily.org"
2) "taobao.com"
3) "maiziedu.com"
127.0.0.1:6379> SREM web taobao.com maiziedu.com
(integer) 2
127.0.0.1:6379> SMEMBERS web
1) "phpfamily.org"
127.0.0.1:6379> 

 

127.0.0.1:6379> SADD mycourse php java c python android
(integer) 5
127.0.0.1:6379> SMEMBERS mycourse
1) "python"
2) "java"
3) "c"
4) "php"
5) "android"
127.0.0.1:6379> SPOP mycourse
"android"
127.0.0.1:6379> SPOP mycourse
"c"
127.0.0.1:6379> SMEMBERS mycourse
1) "java"
2) "php"
3) "python"
127.0.0.1:6379> 
View Code

 

127.0.0.1:6379> SMEMBERS mycourse
1) "java"
2) "php"
3) "python"
127.0.0.1:6379> clear
127.0.0.1:6379> SRANDMEMBER mycourse
"python"
127.0.0.1:6379> SRANDMEMBER mycourse
"java"
127.0.0.1:6379> SRANDMEMBER mycourse
"python"
127.0.0.1:6379> SRANDMEMBER mycourse
"php"
127.0.0.1:6379> SRANDMEMBER mycourse
"python"
127.0.0.1:6379> SRANDMEMBER mycourse
"php"
127.0.0.1:6379> SRANDMEMBER mycourse 2
1) "python"
2) "php"
127.0.0.1:6379> SRANDMEMBER mycourse 2
1) "python"
2) "java"
127.0.0.1:6379> SRANDMEMBER mycourse 2
1) "java"
2) "php"
127.0.0.1:6379> SRANDMEMBER mycourse 3
1) "python"
2) "java"
3) "php"
127.0.0.1:6379> SRANDMEMBER mycourse 3
1) "python"
2) "java"
3) "php"
127.0.0.1:6379> SRANDMEMBER mycourse -2
1) "php"
2) "php"
127.0.0.1:6379> SRANDMEMBER mycourse -2
1) "java"
2) "java"
127.0.0.1:6379> SRANDMEMBER mycourse -2
1) "java"
2) "php"
127.0.0.1:6379> 
View Code

 

以上是关于redis 集合的主要内容,如果未能解决你的问题,请参考以下文章

金蝶handler中 collection 代码片段理解

Alfred常见使用

比较 C# 中的字符串片段并从集合中删除项目

带有红宝石集合/可枚举的酷技巧和富有表现力的片段[关闭]

java代码中 单表查询出的list集合 怎么读写到redis中

[ jquery 文档处理 insertBefore(content) before(content|fn) ] 此方法用于把所有匹配的元素插入到另一个指定的元素元素集合的前面,实现外部插入(代码片段