当前位置:网站首页>Un7.27: common commands of redis database.
Un7.27: common commands of redis database.
2022-07-28 04:00:00 【Excellent little Aiko】
Today, I'd like to share with you some things I've been exposed to redis command .
One 、 brief introduction .
redis Is an open source in-memory data structure storage system , It can be used as a database / Caching and message middleware . In the form of key value pairs (key-value), Per second /10 ten thousand ++.
Two 、 Database type .
We often see two kinds of databases , A is MySQL,Oracle,DB2,SQLServer Mainly relational database , There is another kind. , That is to say Redis,mongo db,Memcached Mainly non relational database .
3、 ... and 、 effect .
redis As a typical non relational database , Not only has the function of caching , And it can also queue tasks 、 Message queue , And distributed locking , It provides great convenience for our programmers .
Four 、 data type .
redis In order to key-value Key value pairs exist in the form of ,key Is string ,value There are five common .
1、 character string :String
2、 Hash :hash Suitable for storing objects
3、 list :list Sequence list , Can have repeating elements
4、 aggregate :set unordered set , There can be no repeating elements
5、 Ordered set :sorted set Ordered set , There can be no repeating elements ( Ranking List )
5、 ... and 、String String common commands .
1、 assignment :set key(name) value(xiaoai)

2、 Get value , Post value override :get key(name)

3、 Survival time :setex key( City ) seconds(10) value(taiyuan)

4、key Set value when it does not exist , Existence is invariable :setnx key value

6、 ... and 、hash Hash common commands .
1、 take key In the field field The value of the set value, command :Hset key(001) field(name) value(xiaoai)

2、 Get the specified field , command :Hset key field

3、 Delete the specified field , command :Hdel key field

4、 Get all fields , command :Hkeys key

5、 Get all values , command :Hvals key

6、 Get specified key All fields and values of , command :Hgetall key

7、 ... and 、list Common commands .
1、 Insert one or more values into the list header , command :Lpush key value1 [value2,value3......]

2、 Get the elements in the specified range of the list , command :LRange key start stop

3、 Remove and get the last element of the list , command :Rpop key

4、 Get list length , command :Llen key

5、 Remove and get the last element of the list , Or find pop-up elements , command :BRpop key1 [key2] timeout
8、 ... and 、set Set common commands .
1、 Add multiple members . command :sadd key 1 2

2、 Back to the assembly , command :smembers key

3、 How many? , command :scard key

4、 intersection 、 share . command :sinter key1,key2

5、 Combine , command :sunion key1,key2
6、 Difference set , The following element does not exist , command :sdiff key1,key2
7、 remove , command :SRem key key1,key2
Nine 、sorted set command .
1、 Add one or more ( Sort from small to large ), command :zadd key score1 member1 [score2 member2]
2、 Gets the specified range element , command :zrange key star stop[with scores]
3、 Revise the score , command :zincrby key increment( How much to add ) member( member )
4、 Remove one or more elements , command :zrem key member
Ten 、 General Command .
1、 Find all that match key, command :keys pattern

2、 Check the given key Whether the value exists , command :exists key

3、 return key The type of value stored , command :type key
![]()
4、 Return to a given key The remaining lifetime of ( second ), command :ttl key
![]()
5、 This command is used in key Delete... When it exists key( Not shown here ), command :del key
That's what I sum up about redis Common commands , Of course , You can also collect more commands to improve your knowledge system , For daily use , These are basically enough , Good luck .
边栏推荐
- Ch340 RTS DTR pin programming drives OLED
- UBI read only file system
- [image classification] 2021 MLP mixer nips
- 过滤器、拦截器、监听器
- Appnium -- app automated test tool
- Web Security Foundation - Command Execution Vulnerability
- 简单、好用的性能测试工具推荐
- Servlet usage
- [untitled]
- Developing rc522 module based on c8t6 chip to realize breathing lamp
猜你喜欢

企业数字化建设“三不五要”原则

Security exception handling mechanism

numeric_ Limits the range and related attributes of each data type learned

Summary of static blog building tools

How does MySQL ensure high availability

静态博客搭建工具汇总
![[leetcode] 34. Find the first and last positions of elements in the sorted array](/img/f0/3eaa33fa7b13abe5f27b136239507d.png)
[leetcode] 34. Find the first and last positions of elements in the sorted array

构建“产业大脑”,以“数字化”提升园区运营管理及服务能力!

Appnium--APP自动化测试工具

Selenium--WEB自动化测试工具
随机推荐
After 95, Alibaba P7 published the payroll: it's really heartbreaking
Appnium--APP自动化测试工具
Screenshot of deepstream detection results
简单、好用的性能测试工具推荐
21 days, fat brother personally takes you to play oauth2
numeric_ Limits the range and related attributes of each data type learned
Filters, interceptors, listeners
Protocols in swift
WordPress simple mkblog blog theme template v2.1
【无标题】
Summary and interpretation of CONDA virtual environment
[MySQL database] index and transaction (often used in interview)
My creation anniversary
[openvx] VX for basic use of objects_ lut
CH340 RTS DTR引脚编程驱动OLED
Machine learning 06: Decision Tree Learning
Convert py file to exe executable file
ServletContext、request、response
基于SSM实现在线租房系统
[openvx] VX for basic use of objects_ matrix