当前位置:网站首页>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

边栏推荐
- [understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
- “又土又穷”的草根高校,凭什么被称为“东北小清华”?
- Go: send the get request and parse the return JSON (go1.16.4)
- Spring cup eight school league
- Golang — template
- The solution of Chinese font garbled code in keil5
- selenium 浏览器(1)
- JVM系列——概述,程序计数器day1-1
- 记录关于银行回调post请求405 问题
- C language standard IO function sorting
猜你喜欢

Ocean CMS vulnerability - search php

Mastering the cypress command line options is the basis for truly mastering cypress

Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material

使用vscode查看Hex或UTF-8编码

UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂

消息订阅与发布

Comprehensive case of MySQL data addition, deletion, modification and query

Current situation, analysis and prediction of information and innovation industry
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
随机推荐
There is nothing new under the sun. Can the meta universe go higher?
page owner特性浅析
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
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
JS general form submission 1-onsubmit
FPGA测试方法以Mentor工具为例
Ocean CMS vulnerability - search php
QT learning 22 layout manager (I)
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
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
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
[技术发展-24]:现有物联网通信技术特点
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
信创产业现状、分析与预测
Similarities and differences of sessionstorage, localstorage and cookies
Richview trvstyle liststyle list style (bullet number)
JVM class loading
[technology development-24]: characteristics of existing IOT communication technology
Qt学习17 对话框及其类型