当前位置:网站首页>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
边栏推荐
- Trc20 fund collection solution based on thinkphp5 version
- JS node operation, why learn node operation
- STM32 and FreeRTOS stack parsing
- JS what is an event? Event three elements and operation elements
- Enter "net start MySQL" and "system error 5. Access denied" appears. Detailed explanation of the problem
- Flutter's loading animation is more interesting
- How to obtain geographical location based on photos and how to prevent photos from leaking geographical location
- Personal homepage software fenrus
- DVWA range practice record
- Leetcode question bank 78 Subset (recursive C implementation)
猜你喜欢

成功的DevOps Leader 应该清楚的3个挑战

653. 两数之和 IV - 输入 BST

High paid programmer & interview question series 91 limit 20000 loading is very slow. How to solve it? How to locate slow SQL?

LeetCode 1611. The minimum number of operations to make an integer 0

Pre parsing of JS

112. Path sum

Flink 流批一体在小米的实践

小程序报错 :should have url attribute when using navigateTo, redirectTo or switchTab

npm报错 :operation not permitted, mkdir ‘C: \Program Files \node js \node_ cache _ cacache’

小程序报错:Cannot read property 'currentTarget' of undefined
随机推荐
Alibaba cloud architects interpret the four mainstream game architectures
Amazon cloud technology entry Resource Center, easy access to the cloud from 0 to 1
GUI, CLI and UNIX Philosophy
Group Backpack
kettle庖丁解牛第14篇之JSON输入
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
ALV tree (ll LR RL RR) insert delete
501. 二叉搜索树中的众数
501. Mode in binary search tree
Redis 过期 key 清理删除策略汇总
Using sqlmap injection to obtain the account and password of the website administrator
Redis 异常 read error on connection 解决方案
Write down the post order traversal of the ~ binary tree
Applet error: cannot read property'currenttarget'of undefined
Exclusive thoughts and cases of JS
Give the method of instantiating the object to the new object
Production practice elk
Go language learning notes - structure | go language from scratch
Leetcode question bank 78 Subset (recursive C implementation)
Your guide to lowering your cholesterol with TLC (continuously updated)