mirror of
https://github.com/fluencelabs/redis
synced 2025-06-18 19:51:22 +00:00
Modules: context flags now include OOM flag.
Plus freeMemoryIfNeeded() refactoring to improve legibility. Please review this commit for sanity.
This commit is contained in:
@ -1327,6 +1327,9 @@ int RM_GetSelectedDb(RedisModuleCtx *ctx) {
|
||||
*
|
||||
* * REDISMODULE_CTX_FLAGS_EVICT: Maxmemory is set and has an eviction
|
||||
* policy that may delete keys
|
||||
*
|
||||
* * REDISMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the
|
||||
* maxmemory setting.
|
||||
*/
|
||||
int RM_GetContextFlags(RedisModuleCtx *ctx) {
|
||||
|
||||
@ -1365,6 +1368,11 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
|
||||
flags |= REDISMODULE_CTX_FLAGS_READONLY;
|
||||
}
|
||||
|
||||
/* OOM flag. */
|
||||
if (getMaxmemoryState(NULL,NULL,NULL) == C_ERR) {
|
||||
flags |= REDISMODULE_CTX_FLAGS_OOM;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user