Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
fef1e63c
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
fef1e63c
编写于
11月 21, 2019
作者:
S
Salvatore Sanfilippo
提交者:
GitHub
11月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6346 from MeirShpilraien/expose_zmalloc_capabilities
Expose used memory to modules via redismodule api
上级
c697edf4
70469b76
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
0 deletion
+26
-0
src/module.c
src/module.c
+22
-0
src/redismodule.h
src/redismodule.h
+4
-0
未找到文件。
src/module.c
浏览文件 @
fef1e63c
...
...
@@ -5995,6 +5995,26 @@ int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos)
return
REDISMODULE_OK
;
}
/*
* For a given pointer, return The amount of memory
* allocated for this pointer.
*/
size_t
RM_MallocSize
(
void
*
ptr
){
return
zmalloc_size
(
ptr
);
}
/*
* Return the a number between 0 to 1 indicating
* the amount of memory currently used.
* 0 - no memory limit
* 1 and above, memory limit reached.
*/
float
RM_GetUsedMemoryRatio
(){
float
level
;
getMaxmemoryState
(
NULL
,
NULL
,
NULL
,
&
level
);
return
level
;
}
/* --------------------------------------------------------------------------
* Scanning keyspace and hashes
* -------------------------------------------------------------------------- */
...
...
@@ -7360,6 +7380,8 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API
(
BlockClientOnKeys
);
REGISTER_API
(
SignalKeyAsReady
);
REGISTER_API
(
GetBlockedClientReadyKey
);
REGISTER_API
(
GetUsedMemoryRatio
);
REGISTER_API
(
MallocSize
);
REGISTER_API
(
ScanCursorCreate
);
REGISTER_API
(
ScanCursorDestroy
);
REGISTER_API
(
ScanCursorRestart
);
...
...
src/redismodule.h
浏览文件 @
fef1e63c
...
...
@@ -649,6 +649,8 @@ int REDISMODULE_API_FUNC(RedisModule_CommandFilterArgDelete)(RedisModuleCommandF
int
REDISMODULE_API_FUNC
(
RedisModule_Fork
)(
RedisModuleForkDoneHandler
cb
,
void
*
user_data
);
int
REDISMODULE_API_FUNC
(
RedisModule_ExitFromChild
)(
int
retcode
);
int
REDISMODULE_API_FUNC
(
RedisModule_KillForkChild
)(
int
child_pid
);
float
REDISMODULE_API_FUNC
(
RedisModule_GetUsedMemoryRatio
)();
size_t
REDISMODULE_API_FUNC
(
RedisModule_MallocSize
)(
void
*
ptr
);
#endif
#define RedisModule_IsAOFClient(id) ((id) == UINT64_MAX)
...
...
@@ -871,6 +873,8 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API
(
Fork
);
REDISMODULE_GET_API
(
ExitFromChild
);
REDISMODULE_GET_API
(
KillForkChild
);
REDISMODULE_GET_API
(
GetUsedMemoryRatio
);
REDISMODULE_GET_API
(
MallocSize
);
#endif
if
(
RedisModule_IsModuleNameBusy
&&
RedisModule_IsModuleNameBusy
(
name
))
return
REDISMODULE_ERR
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录