X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=redismodule%2Fsrc%2Fexstrings.c;h=11102d3ce2b298488adcd0b1012b70b96a80d17b;hb=refs%2Fchanges%2F25%2F3425%2F1;hp=6f57753a1c2229e52fb8b932ba0cfe79dd95303a;hpb=dc8b09a63af0b4cba51b49b758a999aeeac1630e;p=ric-plt%2Fdbaas.git diff --git a/redismodule/src/exstrings.c b/redismodule/src/exstrings.c index 6f57753..11102d3 100755 --- a/redismodule/src/exstrings.c +++ b/redismodule/src/exstrings.c @@ -774,6 +774,8 @@ int Nget_RedisCommand(RedisModuleCtx *ctx, NgetArgs* nget_args, bool using_threa */ void *NGet_NoAtomic_ThreadMain(void *arg) { + pthread_detach(pthread_self()); + RedisModuleBlockedClientArgs *bca = arg; RedisModuleBlockedClient *bc = bca->bc; RedisModuleCtx *ctx = RedisModule_GetThreadSafeContext(bc); @@ -840,6 +842,57 @@ int NGet_Atomic_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int return Nget_RedisCommand(ctx, &nget_args, false); } +int NDel_Atomic_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) +{ + RedisModule_AutoMemory(ctx); + int ret = REDISMODULE_OK; + long long replylen = 0; + RedisModuleCallReply *reply = NULL; + ExstringsStatus status = EXSTRINGS_STATUS_NOT_SET; + ScanSomeState scan_state; + ScannedKeys *scanned_keys = NULL; + + InitStaticVariable(); + if (argc != 2) + return RedisModule_WrongArity(ctx); + + scan_state.key = argv[1]; + scan_state.count = def_count_str; + scan_state.cursor = 0; + + do { + status = EXSTRINGS_STATUS_NOT_SET; + scanned_keys = scanSome(ctx, &scan_state, &status); + + if (status != EXSTRINGS_STATUS_NO_ERRORS) { + ret = REDISMODULE_ERR; + break; + } else if (scanned_keys == NULL) { + continue; + } + + reply = RedisModule_Call(ctx, "UNLINK", "v!", scanned_keys->keys, scanned_keys->len); + + status = EXSTRINGS_STATUS_NOT_SET; + forwardIfError(ctx, reply, &status); + if (status != EXSTRINGS_STATUS_NO_ERRORS) { + freeScannedKeys(ctx, scanned_keys); + ret = REDISMODULE_ERR; + break; + } + + replylen += RedisModule_CallReplyInteger(reply); + RedisModule_FreeCallReply(reply); + freeScannedKeys(ctx, scanned_keys); + } while (scan_state.cursor != 0); + + if (ret == REDISMODULE_OK) { + RedisModule_ReplyWithLongLong(ctx, replylen); + } + + return ret; +} + /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { @@ -873,6 +926,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) NGet_NoAtomic_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_CreateCommand(ctx,"ndel.atomic", + NDel_Atomic_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) + return REDISMODULE_ERR; + if (RedisModule_CreateCommand(ctx,"msetpub", SetPub_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR;