Redis Sets
Sets
Sets 就是一个集合,集合的概念就是一堆不重复值的组合。利用Redis提供的Sets数据结构,可以存储一些集合性的数据,比如在微博应用中,可以将一个用户所有的关注人存在一个集合中,将其所有粉丝存在一个集合。Redis还为集合提供了求交集、并集、差集等操作,可以非常方便的实现如共同关注、共同喜好、二度好友等功能,对上面的所有集合操作,你还可以使用不同的命令选择将结果返回给客户端还是存集到一个新的集合中。
求差集
redis> SMEMBERS peter's_movies 1) "bet man" 2) "start war" 3) "2012" redis> SMEMBERS joe's_movies 1) "hi, lady" 2) "Fast Five" 3) "2012" redis> SDIFF peter's_movies joe's_movies 1) "bet man" 2) "start war
redis> SMEMBERS songs 1) "Billie Jean" redis> SMEMBERS my_songs 1) "Believe Me" redis> SUNION songs my_songs 1) "Billie Jean" 2) "Believe Me"
求交集
redis> SMEMBERS group_1 1) "LI LEI" 2) "TOM" 3) "JACK" redis> SMEMBERS group_2 1) "HAN MEIMEI" 2) "JACK" redis> SINTER group_1 group_2 1) "JACK"
Redis Sets的更多相关文章
- redis sets类型及操作
sets类型及操作set是集合,它是string类型的无序集合.通过hash table实现,添加.删除.查找的复杂度都是0(1).对集合我们可以实现取交际.差集并集.通过这些操作我们可以实现SNS中 ...
- Redis 常用操作
import org.junit.Before;import org.junit.Test;import redis.clients.jedis.Jedis;import java.util.Set; ...
- Redis系列(六)-SortedSets设计技巧
阅读目录: 介绍 Score占位 更多位信息 总结 介绍 Redis Sorted Sets是类似Redis Sets数据结构,不允许重复项的String集合.不同的是Sorted Sets中的每个成 ...
- Trying to hack Redis via HTTP requests
Trying to hack Redis via HTTP requests Context Imagine than you can access a Redis server via HTTP r ...
- Redis Clients Handling
This document provides information about how Redis handles clients from the point of view of the net ...
- How To Install and Use Redis
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-Redis About Redis redis, dev ...
- 深入理解redis数据类型
转载请注明出处:https://www.cnblogs.com/wenjunwei/p/9720033.html redis的存储模型 redis不是普通的键值对存储,它实际上是一个数据结构存储服务器 ...
- Intro to Jedis – the Java Redis Client Library
转自:http://www.baeldung.com/jedis-java-redis-client-library 1. Overview This article is an introducti ...
- redis的数据类型与应用场景(二)
1. 如何学习 redis有好多数据类型,有这么多数据类型,我们不可能每个都记得完完全全.但是我们必须知道它有哪些数据类型,每个数据类型是怎样的,有什么作用.redis的每一个数据类型都有一大堆命令, ...
随机推荐
- Oracle 常见问题
查看Oracle数据库是否安装成功 sqlplus /nolog SQL>conn / as sysdba Connected to an Idle instance(表明成功) SQL> ...
- HTML: margin重疊現象的說明
2句話: ①相鄰的兩個普通元素,上下邊距,不是簡單的相加,而是取邊距較大的元素(若相邻的两个普通兄弟元素,它们的margin 值是一样的,则各取两个元素的margin 值的一半.)②关系为父子的两个d ...
- Bootstrap页面布局1 - 下载BS(bootstrap简称)
1.bootstrap 官方网站:http://wrongwaycn.github.io/bootstrap/docs/index.html 2.如图: 3.下载后得到如下目录结构 bootstrap ...
- nginx下使用memcache
nginx配置支持memcache,但不支持写,支持读,所以读取部分由程序设置,整个代码如下nginx的server段配置如下:#将静态文件放入memcachelocation ~* \.(gif|j ...
- JS中基本window.document对象操作以及常用事件!
一.找到元素 1.document.getELementById("id"):根据id找,最多找一个. var a=document.getELementById("id ...
- Python之 for循环\while循环
list或tuple可以表示一个有序集合.如果我们想依次访问一个list中的每一个元素呢?比如 list: L = ['Adam', 'Lisa', 'Bart'] print L[0] print ...
- 蓝牙BLE ATT剖析(一)
一.概述 The attribute protocol allows a device referred to as the server to expose a set of attributes ...
- UIView 的粗浅解析
The UIView class defines a rectangular area on the screen and the interfaces for managing the conten ...
- 通过runtime替换系统类实现的代码(从github开源库fdstackview中摘录)
其中部分代码为汇编:由此可见oc的runtime的灵活性和能力.此代码仅供参考 // ---------------------------------------------------- // R ...
- 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...