当前位置:网站首页>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
边栏推荐
- Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
- JS new challenges
- SQL Injection (POST/Select)
- The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
- selenium 浏览器(1)
- Go language unit test 4: go language uses gomonkey to test functions or methods
- Common mixins
- 从零开始的基于百度大脑EasyData的多人协同数据标注
- JS general form submission 1-onsubmit
- How to delete an attribute or method of an object
猜你喜欢
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
Configure stylelint
[email protected])"/>
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
Spring cup eight school league
Qt学习25 布局管理器(四)
如何使用lxml判断网站公告是否更新
Qt学习20 Qt 中的标准对话框(中)
SQL Injection (AJAX/JSON/jQuery)
The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
随机推荐
Summary of common error reporting problems and positioning methods of thrift
Golang — 命令行工具cobra
Vite project commissioning
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
[how to earn a million passive income]
MySQL data processing value addition, deletion and modification
JVM class loading
There is nothing new under the sun. Can the meta universe go higher?
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
Common network state detection and analysis tools
Analysis of the characteristics of page owner
【吉林大学】考研初试复试资料分享
SQL Injection (AJAX/JSON/jQuery)
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
FPGA测试方法以Mentor工具为例
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
Record 405 questions about bank callback post request
JS download files through URL links
jvm-对象生命周期
[acnoi2022] guess numbers