mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Modules API: OOM_WARNING flags.
In some modules it may be useful to have an idea about being near to OOM. Anyway additionally an explicit call to get the fill ratio will be added in the future.
This commit is contained in:
parent
de7de53e64
commit
0afac6939a
@ -1330,6 +1330,9 @@ int RM_GetSelectedDb(RedisModuleCtx *ctx) {
|
|||||||
*
|
*
|
||||||
* * REDISMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the
|
* * REDISMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the
|
||||||
* maxmemory setting.
|
* maxmemory setting.
|
||||||
|
*
|
||||||
|
* * REDISMODULE_CTX_FLAGS_OOM_WARNING: Less than 25% of memory remains before
|
||||||
|
* reaching the maxmemory level.
|
||||||
*/
|
*/
|
||||||
int RM_GetContextFlags(RedisModuleCtx *ctx) {
|
int RM_GetContextFlags(RedisModuleCtx *ctx) {
|
||||||
|
|
||||||
@ -1369,8 +1372,10 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* OOM flag. */
|
/* OOM flag. */
|
||||||
if (getMaxmemoryState(NULL,NULL,NULL,NULL) == C_ERR) {
|
float level;
|
||||||
|
if (getMaxmemoryState(NULL,NULL,NULL,&level) == C_ERR) {
|
||||||
flags |= REDISMODULE_CTX_FLAGS_OOM;
|
flags |= REDISMODULE_CTX_FLAGS_OOM;
|
||||||
|
if (level > 0.75) flags |= REDISMODULE_CTX_FLAGS_OOM_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
|
@ -83,6 +83,8 @@
|
|||||||
#define REDISMODULE_CTX_FLAGS_EVICT (1<<9)
|
#define REDISMODULE_CTX_FLAGS_EVICT (1<<9)
|
||||||
/* Redis is out of memory according to the maxmemory flag. */
|
/* Redis is out of memory according to the maxmemory flag. */
|
||||||
#define REDISMODULE_CTX_FLAGS_OOM (1<<10)
|
#define REDISMODULE_CTX_FLAGS_OOM (1<<10)
|
||||||
|
/* Less than 25% of memory available according to maxmemory. */
|
||||||
|
#define REDISMODULE_CTX_FLAGS_OOM_WARNING (1<<11)
|
||||||
|
|
||||||
#define REDISMODULE_NOTIFY_GENERIC (1<<2) /* g */
|
#define REDISMODULE_NOTIFY_GENERIC (1<<2) /* g */
|
||||||
#define REDISMODULE_NOTIFY_STRING (1<<3) /* $ */
|
#define REDISMODULE_NOTIFY_STRING (1<<3) /* $ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user