当前位置:网站首页>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
- Function calling convention
- Richview trvstyle liststyle list style (bullet number)
- 叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
- 解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
- Golang — template
- Example analysis of QT learning 18 login dialog box
- Using registered classes to realize specific type matching function template
- SQL Injection (POST/Select)
- [556. Next larger element III]
猜你喜欢
![[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

jvm-对象生命周期

Use and design of Muduo buffer class

jvm-运行时数据区

Rasp implementation of PHP
![Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:](/img/2f/33504391a661ecb63d42d75acf3a37.png)
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:

Implementation of Muduo accept connection, disconnection and sending data

RichView TRVStyle ListStyle 列表样式(项目符号编号)

UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料

Dlopen() implements dynamic loading of third-party libraries
随机推荐
信创产业现状、分析与预测
How to promote the progress of project collaboration | community essay solicitation
Dlopen() implements dynamic loading of third-party libraries
[combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
page owner特性浅析
QT learning 24 layout manager (III)
Common mixins
QT learning 17 dialog box and its types
Go language unit test 4: go language uses gomonkey to test functions or methods
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
Golang — template
selenium 浏览器(1)
[combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
Uniapp skills - scrolling components -1
Implementation of Muduo accept connection, disconnection and sending data
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
Mastering the cypress command line options is the basis for truly mastering cypress
[technology development-24]: characteristics of existing IOT communication technology
Use and design of Muduo buffer class