当前位置:网站首页>Redis transaction and watch instruction
Redis transaction and watch instruction
2022-06-26 15:00:00 【Hua Weiyun】
Redis Affairs and watch Instructions
Redis Business
redis Our business is MULTI Instructions indicate that things are open , Sent by the client after the service is opened EXEC DISCARD WATCH MULTI The order is executed immediately , Other instructions will be put into the business queue , Then come back and send a message to the client :QUEUE
When the client sends... To the server EXEC Time of instruction , The server traverses the business queue of the client , Carry out all instructions saved , And return all the performance results to the client .
watch Instructions
watch The directive is able to monitor multiple database keys , When excc The time when the order is fulfilled , If the monitored database key has been modified , Failure in business performance , The principle is redis There are in the database watched_keys Dictionaries , Dictionary keys are watch Command supervised database key , Values are linked lists , Record all client information that monitors this key .
When the database modification instruction is executed, it will call touchWatchedKey function ,touchWatchedKey Function will set the client of the correction key CLIENT_DIRTY_CAS identification
// When key Corrected , Call this function void signalModifiedKey(redisDb *db, robj *key) { touchWatchedKey(db,key);}// Touch One key, If we should key Being supervised , Then the client will perform EXEC defeat void touchWatchedKey(redisDb *db, robj *key) { list *clients; listIter li; listNode *ln; // If there is no supervised in the database key, Come straight back if (dictSize(db->watched_keys) == 0) return; // Find out what to supervise key Of client Linked list clients = dictFetchValue(db->watched_keys, key); // Not found back if (!clients) return; /* Mark all the clients watching this key as CLIENT_DIRTY_CAS */ /* Check if we are already watching for this key */ listRewind(clients,&li); // Traverse everything to supervise the key Of client while((ln = listNext(&li))) { client *c = listNodeValue(ln); // Set up CLIENT_DIRTY_CAS identification c->flags |= CLIENT_DIRTY_CAS; }}Then the server receives a message from the client exec When the command , The server depends on the client CLIENT_DIRTY_CAS Identification judgment , If there is this sign , The description has been corrected , The server will reject the business submitted by the client .
summary
This is it. redis Relevant contents of the transaction , The transaction is started through MULTI command , All commands go into the transaction queue , When executed exec When ordered , The commands in the transaction queue are submitted together ,watch Command to monitor keys , When a key is modified during a transaction , The monitor corresponding to this key can detect , Then the transaction will fail to commit , Ensure transaction consistency .
️ Thank you for your
If you think this is helpful for you :
- Welcome to follow me ️, give the thumbs-up , Comment on , forward
- Focus on
Panpan small class, Push good articles for you regularly , There are also group chat and irregular lottery activities , You can say what you want , Communicate with the great gods , Learning together . - If there is anything inappropriate, you are welcome to criticize and correct .
边栏推荐
- teamviewer显示设备数量上限解决方法
- 重磅白皮书发布,华为持续引领未来智慧园区建设新模式
- Deploy the flask environment using the pagoda panel
- Keil4打开单片机工程一片空白,cpu100%程序卡死的问题解决
- The engine "node" is inconsistent with this module
- 使用 Abp.Zero 搭建第三方登录模块(二):服务端开发
- nvidia-smi 报错
- 【云原生】 ”人人皆可“ 编程的无代码 iVX 编辑器
- Is it safe to open a stock account through the account opening link given by the broker manager? I want to open an account
- 工作上对金额价格类小数点的总结以及坑
猜你喜欢

北京银行x华为:网络智能运维夯实数字化转型服务底座

Talk about the RPA direction planning: stick to simple and valuable things for a long time

Notes on writing questions in C language -- table tennis competition

The engine "node" is inconsistent with this module

【云原生】 ”人人皆可“ 编程的无代码 iVX 编辑器

人的顶级能量从哪里获取?

程序分析与优化 - 8 寄存器分配

feil_uVission4左侧工目录消失

10分钟了解BIM+GIS融合,常见BIM数据格式及特性

【使用yarn运行报错】The engine “node“ is incompatible with this module.
随机推荐
R语言epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布、使用cex.X.axis参数指定X轴轴刻度数值标签字体的大小
NVIDIA SMI error
fileinput. js php,fileinput
TCP拥塞控制详解 | 1. 概述
Excel-VBA 快速上手(二、条件判断和循环)
集群中命令的执行过程
Informatics Olympiad all in one 1400: count the number of words (string matching)
Is the QR code for account opening given by the manager of the securities firm safe? Who can I open an account with?
【soloπ】adb连接单个多个手机
聊聊 RPA 方向的规划:简单有价值的事情长期坚持做
The engine "node" is inconsistent with this module
Redis集群消息
Talk about the RPA direction planning: stick to simple and valuable things for a long time
A remove the underline from the label
权威发布 | 延安大学2022年教师岗位招聘公告
TCP 复位攻击原理
R language uses GLM function to build Poisson logarithm linear regression model, processes three-dimensional contingency table data to build saturation model, uses step function to realize stepwise re
Sharing ideas for a quick switch to an underlying implementation
Complimentary Book Cognitive Control: how does our brain accomplish tasks?
Is it safe to open an account by digging money? Is there any risk?