当前位置:网站首页>Setnx command execution failed due to full redis memory
Setnx command execution failed due to full redis memory
2022-04-23 09:32:00 【Notes of Pan Guangyu de Xiaobai】
One 、 Problem occurs
Under normal circumstances , adopt setnx Set a lock , It should be 1s After expired ( Prevent concurrent requests , Handle the same logic ), But what actually happened was , Deal with the following logic for the first time , Throw an exception . explain setnx Function returned false.
$redis_key_lock = 'lock';
//@todo Set up a 1s Lock of
$lock = $redis->setnx($redis_key_lock, 1);
//@todo Will be locked in 1s After expired
$redis->expire($redis_key_lock, 1);
if ($lock) {
// Perform other logic
} else {
throw new \Exception(" Lock present ");
}
Two 、 Troubleshoot problems
redis Your memory is full
adopt redis.conf Check it out. redis Expiration strategy
# maxmemory-policy volatile-lru
explain redis The default expiration policy is used noeviction
Default expiration policy noeviction Not for expired keys Do any cleaning , When the memory is full , Will refuse to perform all write operations , By flipping through redis The configuration file , You can find relevant tips , And in addition to setnx, Other write operation related instructions , Will fail .
The solution is to quickly release redis Memory , Give Way setnx The command can be executed normally .
版权声明
本文为[Notes of Pan Guangyu de Xiaobai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230929494125.html
边栏推荐
- kettle庖丁解牛第14篇之JSON输入
- SQL used query statements
- npm ERR! network
- Thread scheduling (priority)
- Go language learning notes - language interface | go language from scratch
- Kernel PWN learning (4) -- double fetch & 0ctf2018 baby
- Go language learning notes - slice, map | go language from scratch
- js 原型链的深入
- Go language learning notes - array | go language from scratch
- Amazon cloud technology entry Resource Center, easy access to the cloud from 0 to 1
猜你喜欢
Three challenges that a successful Devops leader should be aware of
npm ERR! network
Pre parsing of JS
Kettle实验 (三)
Acquisition of DOM learning elements JS
Go language learning notes - array | go language from scratch
MySQL of database -- basic common query commands
Cross domain configuration error: when allowcredentials is true, allowedorigins cannot contain the special value "*“
SAP 101K 411K 库存变化
Leetcode question bank 78 Subset (recursive C implementation)
随机推荐
Unfortunately, I broke the leader's confidential documents and spit blood to share the code skills of backup files
Detailed explanation of delete, truncate and drop principles in MySQL database
JS DOM event
《数字电子技术基础》3.1 门电路概述、3.2 半导体二极管门电路
Learn FPGA (from Verilog to HLS)
Cloud computing competition -- basic part of 2020 competition [task 3]
Single sign on SSO
npm ERR! network
Flink SQL realizes the integration of stream and batch
Redis 过期 key 清理删除策略汇总
Kettle实验 (三)
GUI, CLI and UNIX Philosophy
Number of islands
Write down the post order traversal of the ~ binary tree
1 + X cloud computing intermediate -- script construction, read-write separation
Two methods of building Yum source warehouse locally
How to protect open source projects from supply chain attacks - Security Design (1)
501. 二叉搜索树中的众数
NLLLoss+log_ SoftMax=CE_ Loss
Colorui solves the problem of blocking content in bottom navigation