diff options
author | antirez <antirez@gmail.com> | 2016-04-25 17:09:26 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-05-10 06:40:09 +0200 |
commit | 9b0556cf10dbd646bd011ccffcf619732b9dbef1 (patch) | |
tree | 4abeddae9e2822f103106d1cee13c6b6f1c017a6 /src/modules/helloworld.c | |
parent | 10993ca0d51e21ff2dc68de9dce56ce2becb0e0c (diff) | |
download | redis-9b0556cf10dbd646bd011ccffcf619732b9dbef1.tar.gz |
Modules: Hash type API WIP #2.
Diffstat (limited to 'src/modules/helloworld.c')
-rw-r--r-- | src/modules/helloworld.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index e635d0dfe..2caac16d2 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -438,10 +438,13 @@ int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } - /* XXX modify me. */ - RedisModule_HashSet(key,REDISMODULE_HSET_NONE,argv[2],argv[3],NULL); - RedisModule_HashSet(key,REDISMODULE_HSET_CFIELDS,"foo",argv[3],NULL); - RedisModule_ReplyWithLongLong(ctx,0); + /* Get the old field value. */ + RedisModuleString *oldval; + RedisModule_HashGet(key,REDISMODULE_HGET_NONE,argv[2],&oldval,NULL); + if (oldval) { + RedisModule_HashSet(key,REDISMODULE_HSET_NONE,argv[3],oldval,NULL); + } + RedisModule_ReplyWithLongLong(ctx,oldval != NULL); return REDISMODULE_OK; } |