diff options
author | antirez <antirez@gmail.com> | 2016-04-11 12:23:04 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-05-10 06:40:07 +0200 |
commit | f4e0129fa9c127700bd2193b696d9051f391b2ef (patch) | |
tree | 5b2cfebfddff8edc9505530ccbd185a7bc83ee84 /src/modules/helloworld.c | |
parent | 6054089fa8f030cb6e43c2dbb6d486d2ad195013 (diff) | |
download | redis-f4e0129fa9c127700bd2193b696d9051f391b2ef.tar.gz |
Modules: RedisModule_ReplyWithCallReply().
Diffstat (limited to 'src/modules/helloworld.c')
-rw-r--r-- | src/modules/helloworld.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index 09e2f1b24..477a12727 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -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; |