changed GetUsedMemoryPresentage -> GetUsedMemoryRatio and return value between 0 and 1.

This commit is contained in:
meir@redislabs.com 2019-11-06 12:17:09 +02:00
parent 667c9cd8c7
commit 0a6f42fc8e
2 changed files with 5 additions and 5 deletions

View File

@ -5905,10 +5905,10 @@ size_t RM_MallocSize(void* ptr){
* 0 - no memory limit * 0 - no memory limit
* 100 and above, memory limit reached. * 100 and above, memory limit reached.
*/ */
float RM_GetUsedMemoryPercentage(){ float RM_GetUsedMemoryRatio(){
float level; float level;
getMaxmemoryState(NULL, NULL, NULL, &level); getMaxmemoryState(NULL, NULL, NULL, &level);
return level * 100; return level;
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
@ -6991,6 +6991,6 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API(BlockClientOnKeys); REGISTER_API(BlockClientOnKeys);
REGISTER_API(SignalKeyAsReady); REGISTER_API(SignalKeyAsReady);
REGISTER_API(GetBlockedClientReadyKey); REGISTER_API(GetBlockedClientReadyKey);
REGISTER_API(GetUsedMemoryPercentage); REGISTER_API(GetUsedMemoryRatio);
REGISTER_API(MallocSize); REGISTER_API(MallocSize);
} }

View File

@ -633,7 +633,7 @@ int REDISMODULE_API_FUNC(RedisModule_CommandFilterArgDelete)(RedisModuleCommandF
int REDISMODULE_API_FUNC(RedisModule_Fork)(RedisModuleForkDoneHandler cb, void *user_data); int REDISMODULE_API_FUNC(RedisModule_Fork)(RedisModuleForkDoneHandler cb, void *user_data);
int REDISMODULE_API_FUNC(RedisModule_ExitFromChild)(int retcode); int REDISMODULE_API_FUNC(RedisModule_ExitFromChild)(int retcode);
int REDISMODULE_API_FUNC(RedisModule_KillForkChild)(int child_pid); int REDISMODULE_API_FUNC(RedisModule_KillForkChild)(int child_pid);
float REDISMODULE_API_FUNC(RedisModule_GetUsedMemoryPercentage)(); float REDISMODULE_API_FUNC(RedisModule_GetUsedMemoryRatio)();
size_t REDISMODULE_API_FUNC(RedisModule_MallocSize)(void* ptr); size_t REDISMODULE_API_FUNC(RedisModule_MallocSize)(void* ptr);
#endif #endif
@ -844,7 +844,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API(Fork); REDISMODULE_GET_API(Fork);
REDISMODULE_GET_API(ExitFromChild); REDISMODULE_GET_API(ExitFromChild);
REDISMODULE_GET_API(KillForkChild); REDISMODULE_GET_API(KillForkChild);
REDISMODULE_GET_API(GetUsedMemoryPercentage); REDISMODULE_GET_API(GetUsedMemoryRatio);
REDISMODULE_GET_API(MallocSize); REDISMODULE_GET_API(MallocSize);
#endif #endif