当前位置:网站首页>New to redis
New to redis
2022-07-06 15:58:00 【Star age Cao Botao】
New to Redis
Redis(Remote Dictionary Server ), Remote dictionary service , Is an open source use ANSI C Language writing 、 Support network 、 Log type that can be memory based or persistent 、Key-Value database , And provide multilingual API
Basic data type
- String
- Hash
- List
- Set
- Zset
Basic commands
select 1 # Select database 16 A database
DBSIZE # View the database size
keys * # Look at all the keys
flushdb # Clear current database
flushall # Clear all databases
Key Basic command :
set key val
get key
del key
rename key newkey
expire key 10 #10 Seconds expired
exists key # Whether there is key
type key # View type
ttl key # View expiration time
String
append key xxx # Additional content
strlen key # Look at string length
incr key # Self increasing 1
incrby key n # Self increasing n
decr key # Self reduction n
decrby key n # Self reduction n
getrange key start end # Gets the specified string
setrange key offset xx # Replace
setex key 10 val # Set expiration time
setnx key val # If it doesn't exist, set
mset mget # The batch Atomicity
getset key val # Get first and then set
Hash
hset user name zhangsan # Set up
hget user name # obtain
hmset user name zhangsan age 15 # The batch
hmget user name age # The batch
hgetall user # Get all the fields
hdel user name # Delete a field
hexists user age # Check whether a field exists
hkeys user # Get all the fields key
hvals user # Get all the fields value
hlen user # Get the number of fields
List
lpush # Insert one or more values into the list header
lpop user # Eject and remove
rpush # Add one or more values... To the list
rpop # Remove the last element of the list , The return value is the removed element .
lrange 0 -1 # Get all the elements
lrem user 1 zhangsan # Delete
lset user 0 "bar"
Set
sadd # Add one or more members to the collection
scard key # Get the number of members of the collection
sismember ket member # Judge member Is the element a collection key Members of
smembers key # Returns all members of the collection
srem # Remove one or more members of the collection
spop # Remove and return a random element from the collection
srandmember key [count] # Returns one or more random numbers in a set
Redis Business
Redis Transactions can execute more than one command at a time , And there are three important guarantees :
- Bulk operation is sending EXEC The command is put into the queue cache .
- received EXEC Enter transaction execution after command , The execution of any command in the transaction failed , The rest of the orders are still being carried out .
- In the transaction execution process , Command requests submitted by other clients will not be inserted into the transaction execution command sequence .
A transaction goes through the following three stages from the beginning to the execution :
- Start business .
- Order to join the team .
- Perform transactions .
It starts with MULTI Start a transaction , Then queue multiple commands into the transaction , Finally by EXEC Command triggers transaction , Execute all the commands in the transaction
Single Redis The execution of orders is atomic , but Redis There is no mechanism to maintain atomicity in transactions , therefore Redis The execution of a transaction is not atomic .
Transactions can be understood as a packaged batch execution script , But batch instructions are not atomic operations , The failure of an instruction in the middle will not result in the rollback of the previous instruction , It will not cause subsequent instructions not to do .
Persistence strategy
- RDB( Default )
- AOF
边栏推荐
- F - Birthday Cake(山东省赛)
- Printing quality inspection and verification system Industry Research Report - market status analysis and development prospect forecast
- Ball Dropping
- STM32 how to use stlink download program: light LED running light (Library version)
- Opencv learning log 31 -- background difference
- Learning record: use STM32 external input interrupt
- 差分(一维,二维,三维) 蓝桥杯三体攻击
- Perform general operations on iptables
- B - 代码派对(女生赛)
- 信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
猜你喜欢
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
渗透测试 2 --- XSS、CSRF、文件上传、文件包含、反序列化漏洞
VS2019初步使用
Information security - Analysis of security orchestration automation and response (soar) technology
【练习-7】Crossword Answers
数据在内存中的存储&载入内存,让程序运行起来
Determine the Photo Position
信息安全-威胁检测-flink广播流BroadcastState双流合并应用在过滤安全日志
7-1 懂的都懂 (20 分)
PySide6 信号、槽
随机推荐
毕业才知道IT专业大学生毕业前必做的1010件事
The most complete programming language online API document
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
Learning record: use stm32f1 watchdog
编程到底难在哪里?
China earth moving machinery market trend report, technical dynamic innovation and market forecast
China potato slicer market trend report, technical dynamic innovation and market forecast
【高老师UML软件建模基础】20级云班课习题答案合集
Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
0-1 knapsack problem (I)
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
Matlab comprehensive exercise: application in signal and system
Gartner:关于零信任网络访问最佳实践的五个建议
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
Essai de pénétration (1) - - outils nécessaires, navigation
Research Report of peripheral venous catheter (pivc) industry - market status analysis and development prospect prediction
Cost accounting [18]
Nodejs+vue网上鲜花店销售信息系统express+mysql
VS2019初步使用