当前位置:网站首页>Redis data operation
Redis data operation
2022-07-26 14:07:00 【__ Samual】
Catalog
One 、 understand Redis Data structure of
One 、 understand Redis Data structure of
1. data structure
- redis yes key-value Data structure of , Every piece of data is ⼀ Key value pairs
- The type of key is string
Bonds cannot be repeated
There are five types of values :
- character string string
- Hash hash
- list list
- aggregate set
- Ordered set zset
2. Data manipulation behavior
- preservation
- modify
- obtain
- Delete
Two 、Redis Data operation of
1. character string (string)
The string type is Redis The most basic data storage type in , It's in Redis Is binary safe , This means that the type can accept data in any format , Such as JPEG Image data or Json Object description information, etc . stay Redis Of string type Value The maximum length of data that can be held is 512M.
String command :
1. Set command :
a. Set individual :
set key value
b. Set up multiple :
mset key value [key value ...]c. Set key value and expiration time , In seconds
setex key seconds value2. Get orders :
Get the specified key value
get keyAccording to the multiple key Get multiple values :
mget key1 key2 ...
3. Modify the order :
Append a value to the specified key :
append key value
4. Key command :
Lookup key , Parameters ⽀ Hold regular expressions
keys pattern Judge whether the key exists , If there is a return 1, There is no return 0
exists key1 View key value The type of
type keyDelete key and corresponding value
del key1 key2 ... Set expiration time , In seconds , If no expiration time is specified, then ⼀ Direct existence , Until ⽤DEL remove
expire key secondsView effective time , In seconds
ttl key2. Hash (hash)
- hash⽤ For storing objects , The structure of the object is property 、 value
- value The type of string
1. Set command :
a、 Set individual values :
hset key field valueb、 Set multiple values :
hmset key field1 value1 field2 value2 ...2. Get orders :
Gets all the properties of the specified key :
hkeys keyobtain ⼀ The value of an attribute :
hget key field Get values for multiple properties :
hmget key field1 field2 ...Get the values of all properties :
hvals key3. The delete command :
- Delete the whole hash Keys and values , send ⽤del command
del keyDelete attribute , The value of the property will be ⼀ To delete
hdel key field1 field2 ...3. list (list)
- The element type of the list is string
- Follow the plug in ⼊ Order
1. Increase the order
On the left ⼊ data :
lpush key value1 value2 ...On the right ⼊ data :
rpush key value1 value2 ...Insert before or after the specified element ⼊ The new element :
linsert key before or after Existing elements The new element 2. Get elements :
Returns a list of ⾥ Specify the elements in the scope :
start、stopIs the subscript index of the element- The index starts on the left , The first ⼀ Elements are 0
- The index can be negative , It means counting from the tail , Such as
-1Said the last ⼀ Elements
lrange key start stop3. Modifying elements
- The index starts on the left , The first ⼀ Elements are 0
The index can be negative , Indicates that the tail starts counting , Such as
-1Said the last ⼀ Elements
lset key index value
4. Remove elements
Deletes the specified element
- Put the list before
countThe value of the second occurrence isvalueRemove the elements of - count > 0: Remove from the beginning to the end
- count < 0: Remove from the tail to the head
- count = 0: Remove all
lrem key count value4. aggregate (set)
- ⽆ Order set
- Element is string type
- The element has only ⼀ sex , No repetition
- explain : There is no modification operation for the collection
1. Increase the order :
Additive elements :
sadd key member1 member2 ...2. Get orders
Returns all the elements
smembers key3. The delete command
Deletes the specified element
srem key5. Ordered set (zset)
- sorted set, Ordered set
- Element is string type
- The element has only ⼀ sex , No repetition
- Every element is associated with ⼀ individual double Type of score, Said the weight , Weight elements from ⼩ To ⼤ Sort
- explain : There are no modifications
1. Increase the order
zadd key score1 member1 score2 member2 ...
2. Get orders
- Returns the elements in the specified range
- start、stop Is the subscript index of the element
- The index starts on the left , The first ⼀ Elements are 0
The index can be negative , It means counting from the tail , Such as
-1Said the last ⼀ Elements
zrange key start stop return score Values in min and max Member between
zrangebyscore key min max Return members member Of score value
zscore key member3. The delete command
Deletes the specified element
zrem key member1 member2 ...Delete in the weight range of the specified element
zremrangebyscore key min max边栏推荐
- Pytoch learning notes (III) use, modification, training (cpu/gpu) and verification of the model
- 天翼云Web应用防火墙(边缘云版)支持检测和拦截Apache Spark shell命令注入漏洞
- [noip2003 popularity group] stack
- 初识Opencv4.X----图像透视变换
- 手持振弦采集仪VH03各种接口使用说明
- Comparison between agile development and Devops
- Latest battle report: Ten certifications and five best practices
- Convert the array in JSON file to struct
- MySQL's practice of SQL analysis and optimization from the index principle
- Polymorphic case - making drinks
猜你喜欢

【论文阅读】GRAW+:A Two-View Graph Propagation Method With Word Coupling for Readability Assessment

Comparison between agile development and Devops

.net6与英雄联盟邂逅之——根据官方LCU API制作游戏助手

JS get the current time, time and timestamp conversion

Basic syntax of MySQL DDL and DML and DQL

基于SPO语义三元组的疾病知识发现

Digital collections accelerate the breaking of the circle and help the industry find new opportunities

@千行百业,一起乘云而上!

The shell script in Jenkins fails to execute but does not exit by itself

作业7.25 排序与查找
随机推荐
[GYCTF2020]FlaskApp
LCL three-phase PWM rectifier (inverter)
Basic knowledge about memory chips
循环队列(c语言实现)
Disease knowledge discovery based on spo semantic triples
敏捷开发与DevOps的对比
C language_ Combination of structure and array
Joint entity and event extraction model based on multi task deep learning
Red * is added to the input box to indicate mandatory items
.net6 encounter with the League of heroes - create a game assistant according to the official LCU API
「中高级试题」:MVCC实现原理是什么?
Pytorch学习笔记(二)神经网络的使用
Technology evolution analysis framework based on two-level topic model and its application
Pytoch learning notes (I) installation and use of common functions
JS, e.pagex, pagey modal box drag
The difference between V-model and.Sync modifier
DP sword finger offer II 100. sum of minimum paths in triangle
低功耗多通道WFAS1431无线数据采集采发仪使用流程说明
Native JS get transform value x y z and rotate rotation angle
消息的订阅和发布