当前位置:网站首页>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
边栏推荐
- 阿里云架构师解读四大主流游戏架构
- Principle of synchronized implementation
- Unfortunately, I broke the leader's confidential documents and spit blood to share the code skills of backup files
- Codeforces Round #784 (Div. 4)
- kettle庖丁解牛第14篇之JSON输入
- RSA 加密解密签名验签
- Trc20 fund collection solution based on thinkphp5 version
- Simple understanding of arguments in JS
- Chapter VIII project stakeholder management of information system project manager summary
- Go language learning notes - exception handling | go language from scratch
猜你喜欢

Simple understanding of arguments in JS

Pre parsing of JS

Kernel PWN learning (3) -- ret2user & kernel ROP & qwb2018 core

Practice of Flink streaming batch integration in Xiaomi

Leetcode0587. 安装栅栏(difficult)

Redis 异常 read error on connection 解决方案

653. Sum of two IV - input BST

Alibaba cloud architects interpret the four mainstream game architectures

机器学习(六)——贝叶斯分类器

What is monitoring intelligent playback and how to use intelligent playback to query video recording
随机推荐
KVM installation and deployment
《信息系统项目管理师总结》第八章 项目干系人管理
Redis 内存占满导致的 Setnx 命令执行失败
Cloud computing competition -- basic part of 2020 competition [task 3]
kettle庖丁解牛第14篇之JSON输入
653. 两数之和 IV - 输入 BST
[geek challenge 2019] havefun1
Emuelec compilation summary
Redis 异常 read error on connection 解决方案
Chapter VIII project stakeholder management of information system project manager summary
Redis 过期 key 清理删除策略汇总
JS what is an event? Event three elements and operation elements
JS and how to judge custom attributes in H5
How to protect open source projects from supply chain attacks - Security Design (1)
Colorui solves the problem of blocking content in bottom navigation
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
ATSS(CVPR2020)
[C language] document operation
LeetCode 1611. The minimum number of operations to make an integer 0
重载、重写、隐藏的对比