当前位置:网站首页>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边栏推荐
猜你喜欢

Zhou Wei: look for non consensual investment opportunities to accompany the founding team that delays satisfaction

12437 words, take you to explore the principle of RPC communication

作业7.25 排序与查找

Pytorch学习笔记(二)神经网络的使用

Add a display horizontal line between idea methods
![[shaders realize overlay to re cover cross dressing effect _shader effect Chapter 9]](/img/f3/48ca9e1e8889afc0993084d6416575.png)
[shaders realize overlay to re cover cross dressing effect _shader effect Chapter 9]

404 pages and routing hooks

Plato farm is expected to further expand its ecosystem through elephant swap

初识Opencv4.X----图像透视变换

MLX90640 红外热成像仪测温传感器模块开发笔记(六)
随机推荐
注解和反射
GDB common commands
Digital collections accelerate the breaking of the circle and help the industry find new opportunities
@千行百业,一起乘云而上!
JS get the current time, time and timestamp conversion
Pytorch学习笔记(一)安装与常用函数的使用
"Intermediate and advanced test questions": what is the implementation principle of mvcc?
Upload pictures to get width and height
Native JS get transform value x y z and rotate rotation angle
Subscription and publication of messages
PHP uses sqlserver
php使用sqlserver
Multithreaded completable future usage
ISCC2021 LOCKK题解
Disease knowledge discovery based on spo semantic triples
.net6与英雄联盟邂逅之——根据官方LCU API制作游戏助手
Canvas upload image Base64 with cropping function jcrop.js
UE4 智能指针和弱指针
Force deduction ----- the number of words in the string
Pytorch学习笔记(二)神经网络的使用