Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
f4e0129f
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
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,发现更多精彩内容 >>
提交
f4e0129f
编写于
4月 11, 2016
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modules: RedisModule_ReplyWithCallReply().
上级
6054089f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
1 deletion
+31
-1
src/module.c
src/module.c
+9
-1
src/modules/API.md
src/modules/API.md
+1
-0
src/modules/helloworld.c
src/modules/helloworld.c
+19
-0
src/redismodule.h
src/redismodule.h
+2
-0
未找到文件。
src/module.c
浏览文件 @
f4e0129f
...
...
@@ -87,7 +87,7 @@ typedef struct RedisModuleCommandProxy RedisModuleCommandProxy;
/* Reply of RM_Call() function. The function is filled in a lazy
* way depending on the function called on the reply structure. By default
* only the type
and proto
are filled. */
* only the type
, proto and protolen
are filled. */
struct
RedisModuleCallReply
{
RedisModuleCtx
*
ctx
;
int
type
;
/* REDISMODULE_REPLY_... */
...
...
@@ -470,6 +470,13 @@ int RM_ReplyWithNull(RedisModuleCtx *ctx) {
return
REDISMODULE_OK
;
}
/* Reply exactly what a Redis command returned us with RM_Call(). */
int
RM_ReplyWithCallReply
(
RedisModuleCtx
*
ctx
,
RedisModuleCallReply
*
reply
)
{
sds
proto
=
sdsnewlen
(
reply
->
proto
,
reply
->
protolen
);
addReplySds
(
ctx
->
client
,
proto
);
return
REDISMODULE_OK
;
}
/* --------------------------------------------------------------------------
* Commands replication API
* -------------------------------------------------------------------------- */
...
...
@@ -1204,6 +1211,7 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API
(
ReplyWithString
);
REGISTER_API
(
ReplyWithStringBuffer
);
REGISTER_API
(
ReplyWithNull
);
REGISTER_API
(
ReplyWithCallReply
);
REGISTER_API
(
GetSelectedDb
);
REGISTER_API
(
SelectDb
);
REGISTER_API
(
OpenKey
);
...
...
src/modules/API.md
浏览文件 @
f4e0129f
...
...
@@ -694,3 +694,4 @@ Command implementations, on keys position request, must reply with
`REDISMODULE_KEYPOS_OK`
to signal the request was processed, otherwise
Cluster returns an error for those module commands that are not able to
describe the position of keys.
src/modules/helloworld.c
浏览文件 @
f4e0129f
...
...
@@ -51,6 +51,21 @@ int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in
return
REDISMODULE_OK
;
}
/* HELLO.PUSH.CALL2
* This is exaxctly as HELLO.PUSH.CALL, but shows how we can reply to the
* client using directly a reply object that Call() returned. */
int
HelloPushCall2_RedisCommand
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
if
(
argc
!=
3
)
return
RedisModule_WrongArity
(
ctx
);
RedisModuleCallReply
*
reply
;
reply
=
RedisModule_Call
(
ctx
,
"RPUSH"
,
"ss"
,
argv
[
1
],
argv
[
2
]);
RedisModule_ReplyWithCallReply
(
ctx
,
reply
);
RedisModule_FreeCallReply
(
reply
);
return
REDISMODULE_OK
;
}
/* HELLO.LIST.SUM.LEN returns the total length of all the items inside
* a Redis list, by using the high level Call() API.
* This command is an example of the array reply access. */
...
...
@@ -306,6 +321,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx) {
HelloPushCall_RedisCommand
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
if
(
RedisModule_CreateCommand
(
ctx
,
"hello.push.call2"
,
HelloPushCall2_RedisCommand
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
if
(
RedisModule_CreateCommand
(
ctx
,
"hello.list.sum.len"
,
HelloListSumLen_RedisCommand
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
...
...
src/redismodule.h
浏览文件 @
f4e0129f
...
...
@@ -86,6 +86,7 @@ int REDISMODULE_API_FUNC(RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, int le
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithStringBuffer
)(
RedisModuleCtx
*
ctx
,
const
char
*
buf
,
size_t
len
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithString
)(
RedisModuleCtx
*
ctx
,
RedisModuleString
*
str
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithNull
)(
RedisModuleCtx
*
ctx
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithCallReply
)(
RedisModuleCtx
*
ctx
,
RedisModuleCallReply
*
reply
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToLongLong
)(
RedisModuleString
*
str
,
long
long
*
ll
);
void
REDISMODULE_API_FUNC
(
RedisModule_AutoMemory
)(
RedisModuleCtx
*
ctx
);
int
REDISMODULE_API_FUNC
(
RedisModule_Replicate
)(
RedisModuleCtx
*
ctx
,
const
char
*
cmdname
,
const
char
*
fmt
,
...);
...
...
@@ -111,6 +112,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API
(
ReplyWithStringBuffer
);
REDISMODULE_GET_API
(
ReplyWithString
);
REDISMODULE_GET_API
(
ReplyWithNull
);
REDISMODULE_GET_API
(
ReplyWithCallReply
);
REDISMODULE_GET_API
(
GetSelectedDb
);
REDISMODULE_GET_API
(
SelectDb
);
REDISMODULE_GET_API
(
OpenKey
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录