Set(集合)增删改查:

#删除当前选择数据库中的所有key
127.0.0.1:6379> flushdb
OK
#生成set集合,添加4个数据
127.0.0.1:6379> sadd set_ay_key "ay" "al" "xy" "xl"
(integer) 4
#查询set里面所有值
127.0.0.1:6379> smembers set_ay_key
1) "xy"
2) "al"
3) "ay"
4) "xl"
#删除value为"xl" , 返回 1 如果没有返回 0
127.0.0.1:6379> srem set_ay_key "xl"
(integer) 1
127.0.0.1:6379> smembers set_ay_key
1) "xy"
2) "al"
3) "ay"
#添加value为"xl"
127.0.0.1:6379> sadd set_ay_key "xl"
(integer) 1
127.0.0.1:6379> smembers set_ay_key
1) "xy"
2) "al"
3) "ay"
4) "xl"
#添加value为"xl" 添加不进去,但也不报错,set是不允许重复的
127.0.0.1:6379> sadd set_ay_key "xl"
(integer) 0
#不多解释
127.0.0.1:6379> sadd set_ay_key "xl"
(integer) 0
#不多解释
127.0.0.1:6379> sadd set_ay_key "xl"
(integer) 0
-------------------------------------------------------------------------------
List(集合)增删改查:

#添加key为list_ay_key的list集合
127.0.0.1:6379> lpush list_ay_key "ay" "al" "xy" "xl"
(integer) 4
#查询key为list_ay_key的集合
127.0.0.1:6379> lrange list_ay_key 0 -1
1) "xl"
2) "xy"
3) "al"
4) "ay"
#往list尾部添加元素
127.0.0.1:6379> rpush list_ay_key "together"
(integer) 5
#往list头部添加元素
127.0.0.1:6379> lpush list_ay_key "first"
(integer) 6
#查询list集合
127.0.0.1:6379> lrange list_ay_key 0 -1
1) "first"
2) "xl"
3) "xy"
4) "al"
5) "ay"
6) "together"
#更新index为0的值
127.0.0.1:6379> lset list_ay_key 0 "update_first"
OK
127.0.0.1:6379> lrange list_ay_key 0 -1
1) "update_first"
2) "xl"
3) "xy"
4) "al"
5) "ay"
6) "together"
#删除index为1上的值
127.0.0.1:6379> lrem list_ay_key 1 "update_first"
(integer) 1
127.0.0.1:6379> lrange list_ay_key 0 -1
1) "xl"
2) "xy"
3) "al"
4) "ay"
5) "together"
-------------------------------------------------------------------------------------

Hash集合(类似Java)增删改查:

127.0.0.1:6379> flushdb
OK
#生成hash集合,并添加key 为uuid_one value 为"12345"
127.0.0.1:6379> hset hash_ay_key "uuid_one" "12345"
(integer) 1
127.0.0.1:6379> hlen hash_ay_key
(integer) 1
#返回集合所有的key
127.0.0.1:6379> hkeys hash_ay_key
1) "uuid_one"
#返回集合所有value
127.0.0.1:6379> hvals hash_ay_key
1) "12345"
#集合添加值
127.0.0.1:6379> hset hash_ay_key "uuid_two" "22222"
(integer) 1
#集合添加值
127.0.0.1:6379> hset hash_ay_key "uuid_three" "33333"
(integer) 1
#获得key为uuid_one的值
127.0.0.1:6379> hget hash_ay_key uuid_one
"12345"
#删除key为uuid_three的值
127.0.0.1:6379> hdel hash_ay_key uuid_three
(integer) 1
127.0.0.1:6379> hkeys hash_ay_key
1) "uuid_one"
2) "uuid_two"
#获得所有,包括key和value
127.0.0.1:6379> hgetall hash_ay_key
1) "uuid_one"
2) "12345"
3) "uuid_two"
4) "22222"
#更新key为uuid_one的值
127.0.0.1:6379> hset hash_ay_key uuid_one "11111"
(integer) 0
127.0.0.1:6379> hset hash_ay_key "uuid_one" "11111"
(integer) 0
127.0.0.1:6379> hgetall hash_ay_key
1) "uuid_one"
2) "11111"
3) "uuid_two"
4) "22222"
---------------------------------------------------------------------------------

SortedSet(ZSet集合)增删改查:

#sorted set添加值ay 排序值为 1
127.0.0.1:6379> zadd zset_ay_key 1 "ay"
(integer) 1
127.0.0.1:6379> zadd zset_ay_key 2 "al"
(integer) 1
127.0.0.1:6379> zadd zset_ay_key 3 "xy"
(integer) 1
127.0.0.1:6379> zadd zset_ay_key 4 "xl"
(integer) 1
#查询所有的值
127.0.0.1:6379> zrange zset_ay_key 0 -1
1) "ay"
2) "al"
3) "xy"
4) "xl"
#删除所有的值
127.0.0.1:6379> zrem zet_ay_key "xl"
(integer) 0
127.0.0.1:6379> zrange zset_ay_key 0 -1
1) "ay"
2) "al"
3) "xy"
4) "xl"

redis 127.0.0.1:6379> ZADD runoobkey 1 redis
(integer) 1
redis 127.0.0.1:6379> ZADD runoobkey 2 mongodb
(integer) 1
redis 127.0.0.1:6379> ZADD runoobkey 3 mysql
(integer) 1
redis 127.0.0.1:6379> ZADD runoobkey 3 mysql
(integer) 0
redis 127.0.0.1:6379> ZADD runoobkey 4 mysql
(integer) 0
redis 127.0.0.1:6379> ZRANGE runoobkey 0 10 WITHSCORES

1) "redis"
2) "1"
3) "mongodb"
4) "2"
5) "mysql"
6) "4"
-------------------------------------------------------------------------------------

redis字段使用说明的更多相关文章

  1. Redis常见使用说明

    1 概述Remote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统.Redis是一个开源的使用ANSI C语言编写. ...

  2. redis API使用说明

    List相关: LPOP key : 删除并取得LIST头部一个元素 RPOP key : 删除并取得LIST尾部一个元素 BLPOP key [key ...] timeout : 删除并取得LIS ...

  3. CentOS-Docker安装Redis(单点)

    下载镜像 $ docker pull redis 创建目录 $ mkdir -p /usr/redis/data 运行镜像 $ docker run --restart=unless-stopped ...

  4. CentOS-yum安装Redis(单点)

    源文件安装(推荐安装) 在CentOS系统中,首先安装EPEL仓库,然后更新yum源: $ yum install epel-release -y $ yum update -y 然后安装Redis数 ...

  5. Scrapy学习-23-分布式爬虫

    scrapy-redis分布式爬虫 分布式需要解决的问题 request队列集中管理 去重集中管理 存储管理   使用scrapy-redis实现分布式爬虫 github开源项目: https://g ...

  6. UniEAP V4 WorkShop用户手册

    版权声明<UniEAP V4 WorkShop用户手册>的版权归东软集团(大连)有限公司所有.未经东软集团(大连)有限公司的书面准许,不得将本手册的任何部分以任何形式.采用任何手段(电子的 ...

  7. redis存储对象,实体类新加字段空指针问题处理

    redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sorted set ...

  8. Redis使用说明详解

    原博主地址:http://www.cnblogs.com/wangyuyu/p/3786236.html Redis使用详细教程 一.Redis基础部分: 1.redis介绍与安装比mysql快10倍 ...

  9. Redis基于eval的多字段原子增量计算

    目录 目录 1 1. 前言 1 2. 优点 1 3. 方法一:使用struct 2 3.1. 设置初始值(覆盖原有的,如果存在) 2 3.2. 查询k1的值 2 3.3. 设置初始值(覆盖原有的,如果 ...

  10. 因在缓存对象中增加字段,而导致Redis中取出缓存转化成Java对象时出现反序列化失败的问题

    背景描述 因为业务需求的需要,我们需要在原来项目中的一个DTO类中新增两个字段(我们项目使用的是dubbo架构,这个DTO在A项目/服务的domain包中,会被其他的项目如B.C.D引用到).但是这个 ...

随机推荐

  1. 用FineBI实现hive图表的可视化

    图表的可视化,本来我以为很麻烦,因为看着图就感觉很难的样子,其实用FineBI来做很简单. 1.安装FineBI 2将下列jar包导入FineBI,webapps\webroot\WEB-INF\li ...

  2. pycharm 连接 docker容器

    1.ubuntu 18.04 先安装sudo apt-get install openssh-server 2.修改" /etc/ssh/sshd_config" 改成 Permi ...

  3. Flume实现写入es

    Flume定制elasticsearch sink源码 最近尝试通过Flume将消息写入elasticsearch,但是flume并没有对每个es版本提供支持,仅仅保留了对0.9版本支持,可能是由于e ...

  4. SQL中各种join的区别

    INNER JOIN 在表中存在至少一个匹配时,INNER JOIN 关键字返回行 返回的是一个交集 内连接就是等值连接 自然连接(outer join. left join, right join) ...

  5. scrapy中发送post请求

    1.可以使用`yield scrapy.FormRequest(url,formdata,callback)`方法发送POST请求. 其中构造参数formdata可以是字典,也可以是可迭代的(key, ...

  6. uniapp文件复制,重命名以及删除

    查找某目录下的文件 plus.io.resolveLocalFileSystemURL(        "_www/static/本地.png",            funct ...

  7. GPIO原理及配制方法

    GPIO原理及配制方法 引用地址: ARM SOC芯片的GPIO结构示意图 @@@ GPIO的八种模式 1,输入浮空模式 2,输入上拉模式 3,输入下拉模式 4,模拟输入模式 5,开漏输出模式 6,开 ...

  8. cudnn Backend API注意事项

    一.在包含多个节点的图中,不支持in-place node.(如果图只包含一个节点,支持in-place node) Note that graphs with more than one opera ...

  9. oracle to_char函数的用法

    select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual; 其中,HH24代表是24小时制的,mi代表分钟,不要写为mm

  10. Security Bulletin: IBM WebSphere Application Server is vulnerable to a remote code execution vulnerability (CVE-2023-23477)

    Skip to content     Support     DownloadsDocumentationForumsCasesMonitoringManage support account   ...