Lines Matching refs:ctx

48 int HelloSimple_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {  in HelloSimple_RedisCommand()  argument
51 RedisModule_ReplyWithLongLong(ctx,RedisModule_GetSelectedDb(ctx)); in HelloSimple_RedisCommand()
61 int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) in HelloPushNative_RedisCommand() argument
63 if (argc != 3) return RedisModule_WrongArity(ctx); in HelloPushNative_RedisCommand()
65 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloPushNative_RedisCommand()
71 RedisModule_ReplyWithLongLong(ctx,newlen); in HelloPushNative_RedisCommand()
80 int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) in HelloPushCall_RedisCommand() argument
82 if (argc != 3) return RedisModule_WrongArity(ctx); in HelloPushCall_RedisCommand()
86 reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); in HelloPushCall_RedisCommand()
89 RedisModule_ReplyWithLongLong(ctx,len); in HelloPushCall_RedisCommand()
96 int HelloPushCall2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) in HelloPushCall2_RedisCommand() argument
98 if (argc != 3) return RedisModule_WrongArity(ctx); in HelloPushCall2_RedisCommand()
102 reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); in HelloPushCall2_RedisCommand()
103 RedisModule_ReplyWithCallReply(ctx,reply); in HelloPushCall2_RedisCommand()
111 int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) in HelloListSumLen_RedisCommand() argument
113 if (argc != 2) return RedisModule_WrongArity(ctx); in HelloListSumLen_RedisCommand()
117 reply = RedisModule_Call(ctx,"LRANGE","sll",argv[1],(long long)0,(long long)-1); in HelloListSumLen_RedisCommand()
126 RedisModule_ReplyWithLongLong(ctx,strlen); in HelloListSumLen_RedisCommand()
134 int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloListSplice_RedisCommand() argument
135 if (argc != 4) return RedisModule_WrongArity(ctx); in HelloListSplice_RedisCommand()
137 RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], in HelloListSplice_RedisCommand()
139 RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], in HelloListSplice_RedisCommand()
150 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloListSplice_RedisCommand()
158 return RedisModule_ReplyWithError(ctx,"ERR invalid count"); in HelloListSplice_RedisCommand()
167 RedisModule_FreeString(ctx,ele); in HelloListSplice_RedisCommand()
173 RedisModule_ReplyWithLongLong(ctx,len); in HelloListSplice_RedisCommand()
179 int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloListSpliceAuto_RedisCommand() argument
180 if (argc != 4) return RedisModule_WrongArity(ctx); in HelloListSpliceAuto_RedisCommand()
182 RedisModule_AutoMemory(ctx); in HelloListSpliceAuto_RedisCommand()
184 RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], in HelloListSpliceAuto_RedisCommand()
186 RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], in HelloListSpliceAuto_RedisCommand()
195 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloListSpliceAuto_RedisCommand()
202 return RedisModule_ReplyWithError(ctx,"ERR invalid count"); in HelloListSpliceAuto_RedisCommand()
214 RedisModule_ReplyWithLongLong(ctx,len); in HelloListSpliceAuto_RedisCommand()
221 int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloRandArray_RedisCommand() argument
222 if (argc != 2) return RedisModule_WrongArity(ctx); in HelloRandArray_RedisCommand()
226 return RedisModule_ReplyWithError(ctx,"ERR invalid count"); in HelloRandArray_RedisCommand()
231 RedisModule_ReplyWithArray(ctx,count); in HelloRandArray_RedisCommand()
232 while(count--) RedisModule_ReplyWithLongLong(ctx,rand()); in HelloRandArray_RedisCommand()
240 int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) in HelloRepl1_RedisCommand() argument
244 RedisModule_AutoMemory(ctx); in HelloRepl1_RedisCommand()
256 RedisModule_Replicate(ctx,"ECHO","c","foo"); in HelloRepl1_RedisCommand()
260 RedisModule_Call(ctx,"INCR","c!","foo"); in HelloRepl1_RedisCommand()
261 RedisModule_Call(ctx,"INCR","c!","bar"); in HelloRepl1_RedisCommand()
263 RedisModule_ReplyWithLongLong(ctx,0); in HelloRepl1_RedisCommand()
278 int HelloRepl2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloRepl2_RedisCommand() argument
279 if (argc != 2) return RedisModule_WrongArity(ctx); in HelloRepl2_RedisCommand()
281 RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ in HelloRepl2_RedisCommand()
282 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloRepl2_RedisCommand()
286 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloRepl2_RedisCommand()
298 RedisModuleString *newele = RedisModule_CreateStringFromLongLong(ctx,val); in HelloRepl2_RedisCommand()
301 RedisModule_ReplyWithLongLong(ctx,sum); in HelloRepl2_RedisCommand()
302 RedisModule_ReplicateVerbatim(ctx); in HelloRepl2_RedisCommand()
314 int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloToggleCase_RedisCommand() argument
315 if (argc != 2) return RedisModule_WrongArity(ctx); in HelloToggleCase_RedisCommand()
317 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloToggleCase_RedisCommand()
325 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloToggleCase_RedisCommand()
341 RedisModule_ReplyWithSimpleString(ctx,"OK"); in HelloToggleCase_RedisCommand()
342 RedisModule_ReplicateVerbatim(ctx); in HelloToggleCase_RedisCommand()
350 int HelloMoreExpire_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloMoreExpire_RedisCommand() argument
351 RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ in HelloMoreExpire_RedisCommand()
352 if (argc != 3) return RedisModule_WrongArity(ctx); in HelloMoreExpire_RedisCommand()
357 return RedisModule_ReplyWithError(ctx,"ERR invalid expire time"); in HelloMoreExpire_RedisCommand()
359 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloMoreExpire_RedisCommand()
366 return RedisModule_ReplyWithSimpleString(ctx,"OK"); in HelloMoreExpire_RedisCommand()
375 int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloZsumRange_RedisCommand() argument
377 if (argc != 4) return RedisModule_WrongArity(ctx); in HelloZsumRange_RedisCommand()
382 return RedisModule_ReplyWithError(ctx,"ERR invalid range"); in HelloZsumRange_RedisCommand()
385 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloZsumRange_RedisCommand()
388 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloZsumRange_RedisCommand()
398 RedisModule_FreeString(ctx,ele); in HelloZsumRange_RedisCommand()
408 RedisModule_FreeString(ctx,ele); in HelloZsumRange_RedisCommand()
417 RedisModule_ReplyWithArray(ctx,2); in HelloZsumRange_RedisCommand()
418 RedisModule_ReplyWithDouble(ctx,scoresum_a); in HelloZsumRange_RedisCommand()
419 RedisModule_ReplyWithDouble(ctx,scoresum_b); in HelloZsumRange_RedisCommand()
430 int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloLexRange_RedisCommand() argument
431 RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ in HelloLexRange_RedisCommand()
433 if (argc != 6) return RedisModule_WrongArity(ctx); in HelloLexRange_RedisCommand()
435 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloLexRange_RedisCommand()
438 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloLexRange_RedisCommand()
442 return RedisModule_ReplyWithError(ctx,"invalid range"); in HelloLexRange_RedisCommand()
446 RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_ARRAY_LEN); in HelloLexRange_RedisCommand()
450 RedisModule_ReplyWithString(ctx,ele); in HelloLexRange_RedisCommand()
451 RedisModule_FreeString(ctx,ele); in HelloLexRange_RedisCommand()
456 RedisModule_ReplySetArrayLength(ctx,arraylen); in HelloLexRange_RedisCommand()
468 int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloHCopy_RedisCommand() argument
469 RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ in HelloHCopy_RedisCommand()
471 if (argc != 4) return RedisModule_WrongArity(ctx); in HelloHCopy_RedisCommand()
472 RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], in HelloHCopy_RedisCommand()
478 return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); in HelloHCopy_RedisCommand()
487 RedisModule_ReplyWithLongLong(ctx,oldval != NULL); in HelloHCopy_RedisCommand()
509 int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in HelloLeftPad_RedisCommand() argument
510 RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ in HelloLeftPad_RedisCommand()
513 if (argc != 4) return RedisModule_WrongArity(ctx); in HelloLeftPad_RedisCommand()
517 return RedisModule_ReplyWithError(ctx,"ERR invalid padding length"); in HelloLeftPad_RedisCommand()
526 return RedisModule_ReplyWithString(ctx,argv[1]); in HelloLeftPad_RedisCommand()
530 return RedisModule_ReplyWithError(ctx, in HelloLeftPad_RedisCommand()
535 char *buf = RedisModule_PoolAlloc(ctx,padlen+strlen); in HelloLeftPad_RedisCommand()
539 RedisModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen); in HelloLeftPad_RedisCommand()
545 int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { in RedisModule_OnLoad() argument
546 if (RedisModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1) in RedisModule_OnLoad()
555 if (RedisModule_CreateCommand(ctx,"hello.simple", in RedisModule_OnLoad()
559 if (RedisModule_CreateCommand(ctx,"hello.push.native", in RedisModule_OnLoad()
563 if (RedisModule_CreateCommand(ctx,"hello.push.call", in RedisModule_OnLoad()
567 if (RedisModule_CreateCommand(ctx,"hello.push.call2", in RedisModule_OnLoad()
571 if (RedisModule_CreateCommand(ctx,"hello.list.sum.len", in RedisModule_OnLoad()
575 if (RedisModule_CreateCommand(ctx,"hello.list.splice", in RedisModule_OnLoad()
579 if (RedisModule_CreateCommand(ctx,"hello.list.splice.auto", in RedisModule_OnLoad()
584 if (RedisModule_CreateCommand(ctx,"hello.rand.array", in RedisModule_OnLoad()
588 if (RedisModule_CreateCommand(ctx,"hello.repl1", in RedisModule_OnLoad()
592 if (RedisModule_CreateCommand(ctx,"hello.repl2", in RedisModule_OnLoad()
596 if (RedisModule_CreateCommand(ctx,"hello.toggle.case", in RedisModule_OnLoad()
600 if (RedisModule_CreateCommand(ctx,"hello.more.expire", in RedisModule_OnLoad()
604 if (RedisModule_CreateCommand(ctx,"hello.zsumrange", in RedisModule_OnLoad()
608 if (RedisModule_CreateCommand(ctx,"hello.lexrange", in RedisModule_OnLoad()
612 if (RedisModule_CreateCommand(ctx,"hello.hcopy", in RedisModule_OnLoad()
616 if (RedisModule_CreateCommand(ctx,"hello.leftpad", in RedisModule_OnLoad()