当前位置:网站首页>Redis basic data learning record (I)
Redis basic data learning record (I)
2022-04-22 17:10:00 【Hengrui】
set key (different type)value
key It's worth it ,
1、 String type
set name james
Set value when it does not exist
setnx name test
set age 23 ex 10
Set the timeout to 10 second
2.hash type
hset user:001 name james
Set up multiple groups
hmset user:001 name james age 15
Get all values
hgetall user:001
obtain key All of the field
hkeys user:2
Delete field
hdel user:1 age
3.list type
rpush james c b a // Insert from right to left cba, Return value 3
lrange james 0 -1 // Get all elements of the list from left to right return c b a
lpush key c b a // Insert... From left to right cba
linsert james before b teacher
4.set type
exists user // Check user Whether the key value exists sadd user a b c// towards user Insert 3 Elements , return 3
sadd user a b // If you add the same element , Repeat is invalid , return 0
smember user // obtain user All elements of , The returned results are out of order srem user a // return 1, Delete a Elements
scard user // return 2, Count the number of elements
5. Orderly zset type
zadd key score member [score member......]
zadd user:zan 200 james //james I like it 1, Returns the number of successful operations 1
zadd user:zan 200 james 120 mike 100 lee// return 3
zadd test:1 nx 100 james // key test:1 Must not exist , Mainly used to add
zadd test:1 xx incr 200 james // key test:1 There must be , It is mainly used to modify , This is the case 300
zadd test:1 xx ch incr -299 james // Return operation result 1,300-299=1
zrange test:1 0 -1 withscores // View likes ( fraction ) And member name
zcard test:1 // Count the number of members , return 1 Ranking scenario :
zadd user:3 200 james 120 mike 100 lee// Insert data first
zrange user:3 0 -1 withscores // View scores and members
zrank user:3 james // Return to rank : The first 3 Name return 2, from 0 Start to 2, common 3 name
zrevrank user:3 james // return 0, Reverse sort , The higher the number of likes , Top of the list
6. Overall, some instructions
1) Look at all the keys :
keys * set school enjoy set hello world
2) Total number of keys : dbsize //2 Key , If there are a lot of keys , It is forbidden to use this instruction online
3) Check if the key exists : exists key // There is returned 1, There is no return 0
4) Delete key : del key //del hello school, Returns the number of delete keys , Delete the nonexistent key and return to 0
5) Key expired : expire key seconds //set name test expire name 10, Express 10 Seconds expired
ttl key // View remaining expiration time
6) The data structure type of the key : type key //type hello // return string, Key does not exist return none
版权声明
本文为[Hengrui]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221648467772.html
边栏推荐
- leetcode:451. Sort by character frequency
- Bisect -- insert new data into the list and keep it in order
- 2022年环境影响评价工程师考试相关法律法规练习题及答案
- 云原生大厦的基石之一「云原生可观测性」
- Introduction to webrtc: 4 Rtcpeerconnection connects audio and video streams
- SDN学习之Opendaylight浅析(三)
- SDN学习之Opendaylight浅析(五)
- GlobalMapper20 如何批量的把shp转为kml并带上属性
- ASP.NET Core实现JWT授权与认证(2.实战篇)
- [sentence pattern] 24. Special questions
猜你喜欢

Vscode plug-in package migration and specified location

OJ daily practice -- find the sum of score sequences

SaaS 长河下,AfterShip 技术升级的“加减法”

openstack利用devstack安装,安装之后dashboard报错Internal Server Error

Detonate the most bombs - C language DFS recursive approach

Shiro cache management

7 Questions d'entrevue sur la fermeture

关于闭包的7道面试题

华为走在老路上

2022年环境影响评价工程师考试评价技术方法练习题及答案
随机推荐
ifconfig、route、ip route、ip addr、 ip link 用法
ES6 Reflect对象
20220421 hardware imaging
今天又出bug了,在用到mogoDb查询数据时,发现返回的数据为null...
MySQL配置参数和命令
对数器的概念和使用
Kubernetes详解(七)——Service对象部署和应用
SDN学习之Opendaylight浅析(五)
leetcode:451. 根据字符出现频率排序
Cloud native observability, one of the cornerstones of cloud native building
Sqlalchemy过滤时间
分布式(三)——实现分布式锁
Use appcube to quickly build 5g message service number with zero threshold
The most expensive new shares in 2022 are coming. Xiaomi and Huawei earn 10 times
Notes on deep learning (I) -- loss function
华为走在老路上
运维自动化之ansible--(playbook模式)
關於閉包的7道面試題
DevExpress WPF入门指南 - 运行时生成的POCO视图模型(一)
Huawei is on the old road