我正在尝试调试我遇到的一些Redis问题,并且有一些关于SET命令的不确定文档.
在我的Redis配置中; 我有以下几行(摘录):
# Note: with all the kind of policies, Redis will return an error on write
# operations, when there are not suitable keys for eviction.
#
# At the date of writing this commands are: set setnx setex append
Run Code Online (Sandbox Code Playgroud)
Status code reply: always OK since SET can't fail.
Run Code Online (Sandbox Code Playgroud)
对权威行为的任何见解?
tl; dr:如果redis实例内存不足,SET将返回错误响应.
据我所知,从redis.c中的源代码可以看出,在处理命令时,流程就像这样(伪代码):
IF memory is needed
IF we can free keys
Free keys
Process the command
SET -> process and return OK response
ELSE return error response
ELSE
Process command
SET -> process and return OK response
Run Code Online (Sandbox Code Playgroud)
它并不是用这种方式编写的,但基本思想归结为:在处理命令之前正在检查内存,因此即使命令不能失败,如果没有内存也会返回错误响应,无论实际响应是什么命令.
| 归档时间: |
|
| 查看次数: |
2222 次 |
| 最近记录: |