Redis中五种数据类型简单操作
Redis 操作 简单 数据类型 五种
2023-06-13 09:19:50 时间
#添加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
我想要获取技术服务或软件
服务范围:MySQL、ORACLE、SQLSERVER、MongoDB、PostgreSQL 、程序问题
服务方式:远程服务、电话支持、现场服务,沟通指定方式服务
技术标签:数据恢复、安装配置、数据迁移、集群容灾、异常处理、其它问题
本站部分文章参考或来源于网络,如有侵权请联系站长。
数据库远程运维 Redis中五种数据类型简单操作
例三: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" 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 #生成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集合的增删改查
SortedSet是有序的set集合
#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"
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
我想要获取技术服务或软件
服务范围:MySQL、ORACLE、SQLSERVER、MongoDB、PostgreSQL 、程序问题
服务方式:远程服务、电话支持、现场服务,沟通指定方式服务
技术标签:数据恢复、安装配置、数据迁移、集群容灾、异常处理、其它问题
本站部分文章参考或来源于网络,如有侵权请联系站长。
数据库远程运维 Redis中五种数据类型简单操作
相关文章
- 安装Redis:简单步骤指南(如何安装redis)
- Redis简易操作:如何删除数据(redis删除数据)
- 使用Redis实现自减操作(redis自减)
- 轻松清除Redis数据,一步到位(怎么清除redis数据)
- 鲁班学院准备Redis面试,来获取突破技能吧(鲁班学院redis面试)
- 深入了解Redis查看队列任务实现原理(查看redis队列任务)
- Redis如何进行更新操作(更新时redis如何操作)
- Redis双端指令掌控数据流动(两条语句操作redis)
- 分布式环境下Redis限速实现机制研究(分布式限速redis)
- 深入了解Redis查看配置的方法(如何查看redis的配置)
- 修复Redis连接简单几步带你轻松搞定(修改redis连接)
- 快速提升项目效率如何利用Redis优化项目性能(在项目中使用redis)
- 指令操作重启Redis服务器(命令行 重启redis)
- 库深入浅出Redis默认数据库(redis默认数据)
- Redis解决高并发系统耗时问题(redis高并发耗时)
- 研究Redis集群复制模型的优势与弊端(redis集群复制模型)
- Redis出现阻塞警报(redis阻塞告警)
- 解开Redis误区如何达成共识(redis误区怎么解决)
- Redis集群支持的安全JWT认证(redis集群jwt)