Redis的底层类型之set

智数探秘
• 阅读 391

sets

A Redis set is an unordered collection of unique strings (members).
无序的字符串集合

相关命令:

  • SADD
SADD key member [member ...]
  • SREM
SREM key member [member ...]
  • SMEMBERS

Returns all the members of the set value stored at key.

  • SISMEMBER
SISMEMBER key member

Returns if member is a member of the set stored at key.1 if the element is a member of the set.0 if the element is not a member of the set, or if key does not exist.

  • SMISMEMBER

Returns whether each member is a member of the set stored at key.

SMISMEMBER key member [member ...]
  • SINTER

    SINTER key [key ...]

    Returns the members of the set resulting from the intersection of all the given sets.求交集

  • SCARD

Returns the set cardinality (number of elements) of the set stored at key.
计算集合中的基数,其实就是set中元素的总数量,因为set是没有重复的。

  • SDIFF
SDIFF key [key ...]

Returns the members of the set resulting from the difference between the first set and all the successive sets.

返回第一个集合和剩余集合的差集,是指包含在第一个集合中但不包含在其他集合中的元素。

  • SDIFFSTORE
SDIFFSTORE destination key [key ...]

This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.

  • SINTERCARD

This command is similar to SINTER, but instead of returning the result set, it returns just the cardinality of the result.

返回:结果交集中的元素数

  • SINTERSTORE

This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination.

  • SMOVE

将 member 元素从 source 集合移动到 destination 集合

  • SPOP

移除并返回集合中的一个随机元素

  • SSCAN

Redis Sscan 命令用于迭代集合中键的元素。

SADD myset1 "hello"
SADD myset1 "hi"
SADD myset1 "bar"
sscan myset1 0 match h*

1) "0"
2) 1) "hello"
   2) "h1"
  • SUNION
  • SUNIONSTORE
点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Wesley13 Wesley13
4年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Stella981 Stella981
4年前
Opencv中Mat矩阵相乘——点乘、dot、mul运算详解
Opencv中Mat矩阵相乘——点乘、dot、mul运算详解2016年09月02日00:00:36 \牧野(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fme.csdn.net%2Fdcrmg) 阅读数:59593
Stella981 Stella981
4年前
Linux查看GPU信息和使用情况
1、Linux查看显卡信息:lspci|grepivga2、使用nvidiaGPU可以:lspci|grepinvidia!(https://oscimg.oschina.net/oscnet/36e7c7382fa9fe49068e7e5f8825bc67a17.png)前边的序号"00:0f.0"是显卡的代
Stella981 Stella981
4年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Easter79 Easter79
4年前
Twitter的分布式自增ID算法snowflake (Java版)
概述分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。而twitter的snowflake解决了这种需求,最初Twitter把存储系统从MySQL迁移
Wesley13 Wesley13
4年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
4年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Stella981 Stella981
4年前
JavaScript常用函数
1\.字符串长度截取functioncutstr(str,len){vartemp,icount0,patrn/^\x00\xff/,strre"";for(vari
Python进阶者 Python进阶者
2年前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这
智数探秘
智数探秘
Lv1
今日听君歌一曲,暂凭杯酒长精神。
文章
5
粉丝
0
获赞
0