当前位置:网站首页>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边栏推荐
- 消息的订阅和发布
- 基于多任务深度学习的实体和事件联合抽取模型
- 【论文阅读】GRAW+:A Two-View Graph Propagation Method With Word Coupling for Readability Assessment
- gdb常用命令
- [noip2003 popularity group] stack
- 「中高级试题」:MVCC实现原理是什么?
- Jzoffer51- reverse pairs in the array (merge sort solution)
- Flink SQL(三) 连接到外部系统System和JDBC
- Prediction and value evaluation of technology fusion relationship based on multiple features
- Disease knowledge discovery based on spo semantic triples
猜你喜欢

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

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

OA项目之会议排座和送审

uni-app从创建到运行到微信开发者工具

【深度学习】全连接网络

Research on technology subject division method based on patent multi-attribute fusion

Redis learning notes

二叉树的层序遍历(C语言实现)

Plato Farm有望通过Elephant Swap,进一步向外拓展生态

天翼云Web应用防火墙(边缘云版)支持检测和拦截Apache Spark shell命令注入漏洞
随机推荐
Difference between base addressing and index addressing
Canvas upload image Base64 with cropping function jcrop.js
Basic syntax of MySQL DDL and DML and DQL
Comparison between agile development and Devops
POM file details
Docker swarm cluster builds highly available MySQL active and standby
@A thousand lines of work, ride the cloud together!
JS download files, filesaver.js export txt and Excel files
The picture moves horizontally with the phone - gyroscope. 360 degree setting conditions
How to quickly design a set of cross end components that support rendering rich text content
Convert the array in JSON file to struct
OLAP (business) - transaction analysis (query)
How can red star Macalline design cloud upgrade the traditional home furnishing industry in ten minutes to produce film and television level interior design effects
基于双层主题模型的技术演化分析框架及其应用
GDB common commands
Research on Chinese medicine assisted diagnosis and treatment scheme integrating multiple natural language processing tasks -- taking diabetes as an example
Flink SQL (III) connects to the external system system and JDBC
Latest battle report: Ten certifications and five best practices
Rotation of 2D conversion, transform origin of 2D conversion center point and scale of 2D conversion
Plato Farm有望通过Elephant Swap,进一步向外拓展生态