当前位置:网站首页>Redis: redis data structure and key operation commands
Redis: redis data structure and key operation commands
2022-07-03 14:04:00 【dengfengling999】
Catalog :
(1)Redis Of 5 Data structures
(2)key Operation command of 1
(3)key Operation command of 2
(4)key Operation command of 3
(1)Redis Of 5 Data structures

1. String type string
The string type is Redis The most basic data structure in , It can store any kind of data , Including binary numbers
According to the , Serialized data ,JSON The object is even a picture . Maximum 512M.

2. List the type list
Redis List is a simple list of strings , Sort by insertion order , Elements can be repeated . You can add an element to the head of the list ( On the left ) Or tail ( On the right ), The bottom layer is a linked list structure .

3. Collection types set
Redis Of Set yes string An unordered unrepeated set of types .

4. Hash type hash
Redis hash It's a string Type of field and value Mapping table ,hash Ideal for storing objects .

5. Ordered set type zset (sorted set)
Redis Ordered set zset And collection set The same is true. string Collection of type elements , And duplicate members are not allowed .
The difference is zset Each element of the is associated with a score ( Scores can be repeated ),redis Sort the members of the set from small to large by score .

Redis There are a series of commands to operate Redis Data structure of
(2)key Operation command of 1

1.keys
grammar :keys pattern
effect : Find all matching patterns pattern Of key. pattern You can use wildcards .
wildcard :
- *: Express 0 Or more characters , for example :keys * Query all key.
- ?: Represents a single character , for example :wo?d , matching word , wood
- [] : Express choice [] A character in , for example wo[or]d, matching word, wood, Mismatch wold、woord

keys * : Query all key

keys k * : General matching , Query all with k At the beginning key

keys h*o : Query all with h start , With o At the end of the key

keys h?o : Query all with h start ,o ending , And there is only one character in the middle key

keys h[abc]llo : Query all with h start , With llo ending , also h You can only go back abc One character in key

(3)key Operation command of 2

1.exists
grammar :exists key[key…]
effect : Judge key Whether there is
Return value : Integers , There is key return 1, Other return 0. The use of multiple key, Return to the existing key The number of .

for example : return 0 or 1

Return the number of existence :

Redis The default is 16 Databases , There is a need to move one data to the second database :( With a few )
2.move
grammar :move key db
effect : Move key To the specified database , The mobile key Deleted in original library .
Return value : Move back successfully 1, Failure to return 0.

hold k Move to 2 Signal library :

3.ttl
grammar :ttl key
effect : see key The remaining lifetime of (ttl: time to live), In seconds .
Return value :
- -1 : No settings key Survival time , key Never expire .
- -2:key non-existent

for example :2 Library No k1, return -2,1 No. library has k1, return -1

4.expire
grammar :expire key seconds
effect : Set up key Survival time , Over time ,key Automatically delete . The unit is seconds .
Return value : Set successfully, return number 1, Other things are 0 .

to k2 Set the existence time : Set up 20 Delete after seconds

(3)key Operation command of 3
1.type
grammar :type key
effect : see key The data type of the stored value
Return value : The data type represented by the string
- none (key non-existent )
- string ( character string )
- list ( list )
- set ( aggregate )
- zset ( Ordered set )
- hash ( Hashtable )

for example :

2.rename (key Modification is not recommended )
grammar :rename key newkey
effect : take key Change the name newkey. When key and newkey identical , perhaps key When there is no , Return an error .
When newkey Preexisting time , RENAME The command will override the old value .

for example : rename hello:

3.del
grammar :del key [key…]
effect : Delete existing key, There is no the key Ignore .
Return value : Numbers , Delete the key The number of .

for example : Nonexistent neglect

边栏推荐
- Screenshot of the operation steps of upload labs level 4-level 9
- Uniapp skills - dom display and hiding
- Golang — 命令行工具cobra
- Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
- Thrift threadmanager and three monitors
- Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
- [combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
- jvm-对象生命周期
- The solution of Chinese font garbled code in keil5
- Current situation, analysis and prediction of information and innovation industry
猜你喜欢
![[technology development-24]: characteristics of existing IOT communication technology](/img/f3/a219fe8e7438b8974d2226b4c3d4a4.png)
[technology development-24]: characteristics of existing IOT communication technology

金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)

解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)

Multi person collaborative data annotation based on Baidu brain easydata from scratch
![[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered](/img/06/b71b505c7072d540955fda6da1dc1b.jpg)
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered

QT learning 24 layout manager (III)

Uniapp tips - scrolling components

FPGA test method takes mentor tool as an example

核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)

Qt学习17 对话框及其类型
随机推荐
[技術發展-24]:現有物聯網通信技術特點
QT learning 17 dialog box and its types
Use vscode to view hex or UTF-8 codes
Qt学习23 布局管理器(二)
selenium 浏览器(1)
JS general form submission 1-onsubmit
Example analysis of QT learning 18 login dialog box
消息订阅与发布
Qt学习20 Qt 中的标准对话框(中)
Qt学习25 布局管理器(四)
Which securities company has the lowest Commission for opening an account online? I want to open an account. Is it safe for the online account manager to open an account
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
Configure stylelint
Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
1px problem of mobile terminal
Logback log sorting
【BW16 应用篇】安信可BW16模组与开发板更新固件烧录说明