From 1fa8da3359c76ef713a46e47933cbe2ce4309249 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Fri, 29 Mar 2024 10:34:07 +0800 Subject: [PATCH 01/98] Rename functionsLibMataData to functionsLibMetaData (#71) Signed-off-by: John Vandenberg --- src/functions.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/functions.c b/src/functions.c index 646ef63084..bee5ce232b 100644 --- a/src/functions.c +++ b/src/functions.c @@ -59,11 +59,11 @@ struct functionsLibCtx { dict *engines_stats; /* Per engine statistics */ }; -typedef struct functionsLibMataData { +typedef struct functionsLibMetaData { sds engine; sds name; sds code; -} functionsLibMataData; +} functionsLibMetaData; dictType engineDictType = { dictSdsCaseHash, /* hash function */ @@ -886,7 +886,7 @@ static int functionsVerifyName(sds name) { return C_OK; } -int functionExtractLibMetaData(sds payload, functionsLibMataData *md, sds *err) { +int functionExtractLibMetaData(sds payload, functionsLibMetaData *md, sds *err) { sds name = NULL; sds engine = NULL; if (strncmp(payload, "#!", 2) != 0) { @@ -945,7 +945,7 @@ int functionExtractLibMetaData(sds payload, functionsLibMataData *md, sds *err) return C_ERR; } -void functionFreeLibMetaData(functionsLibMataData *md) { +void functionFreeLibMetaData(functionsLibMetaData *md) { if (md->code) sdsfree(md->code); if (md->name) sdsfree(md->name); if (md->engine) sdsfree(md->engine); @@ -958,7 +958,7 @@ sds functionsCreateWithLibraryCtx(sds code, int replace, sds* err, functionsLibC dictEntry *entry = NULL; functionLibInfo *new_li = NULL; functionLibInfo *old_li = NULL; - functionsLibMataData md = {0}; + functionsLibMetaData md = {0}; if (functionExtractLibMetaData(code, &md, err) != C_OK) { return NULL; } From 9be3a1d5aba7cff8fa7561188504a5d070bdf720 Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Fri, 29 Mar 2024 23:25:51 +0800 Subject: [PATCH 02/98] Fix renameing names in SECURITY.md (#74) Signed-off-by: Vitah Lin --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index 79437a9bfc..285b6d3d62 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,6 +1,6 @@ # Security Policy -PlaceHolderKV is under development, more information will become available. +Valkey is under development, more information will become available. ## Reporting a Vulnerability From 1950acd1e2b8c2282d51e528377f6e564eb447cd Mon Sep 17 00:00:00 2001 From: Ping Xie Date: Fri, 29 Mar 2024 10:38:13 -0700 Subject: [PATCH 03/98] Fix remaining names in CONTRIBUTING.md (#70) Signed-off-by: Ping Xie --- .gitignore | 1 + CONTRIBUTING.md | 35 ++++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index c9ea5d33c4..fa53b69d67 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ Makefile.dep .ccls-cache/* compile_commands.json redis.code-workspace +.cache diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 548204eb83..ad257664c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,14 @@ -Note: by contributing code to the Redis project in any form, including sending +Note: by contributing code to the Valkey project in any form, including sending a pull request via GitHub, a code fragment or patch via private email or public discussion groups, you agree to release your code under the terms -of the Redis license that you can find in the COPYING file included in the Redis +of the Valkey license that you can find in the COPYING file included in the Valkey source distribution. -# IMPORTANT: HOW TO USE REDIS GITHUB ISSUES +# IMPORTANT: HOW TO USE VALKEY GITHUB ISSUES GitHub issues SHOULD ONLY BE USED to report bugs and for DETAILED feature requests. Everything else should be asked on Discord: - + https://discord.gg/zbcPa5umUB PLEASE DO NOT POST GENERAL QUESTIONS that are not about bugs or suspected @@ -27,9 +27,14 @@ If you are reporting a security bug or vulnerability, see SECURITY.md. ## Developer Certificate of Origin -We respect the intellectual property rights of others and we want to make sure all incoming contributions are correctly attributed and licensed. A Developer Certificate of Origin (DCO) is a lightweight mechanism to do that. The DCO is a declaration attached to every commit. In the commit message of the contribution, the developer simply adds a `Signed-off-by` statement and thereby agrees to the DCO, which you can find below or at [DeveloperCertificate.org](http://developercertificate.org/). +We respect the intellectual property rights of others and we want to make sure +all incoming contributions are correctly attributed and licensed. A Developer +Certificate of Origin (DCO) is a lightweight mechanism to do that. The DCO is +a declaration attached to every commit. In the commit message of the contribution, +the developer simply adds a `Signed-off-by` statement and thereby agrees to the DCO, +which you can find below or at [DeveloperCertificate.org](http://developercertificate.org/). -``` +```text Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: @@ -56,14 +61,21 @@ By making a contribution to this project, I certify that: sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. - ``` +``` -We require that every contribution to Valkey to be signed with a DCO. We require the usage of known identity (such as a real or preferred name). We do not accept anonymous contributors nor those utilizing pseudonyms. A DCO signed commit will contain a line like: +We require that every contribution to Valkey to be signed with a DCO. We require the +usage of known identity (such as a real or preferred name). We do not accept anonymous +contributors nor those utilizing pseudonyms. A DCO signed commit will contain a line like: -``` + +```text Signed-off-by: Jane Smith ``` -You may type this line on your own when writing your commit messages. However, if your user.name and user.email are set in your git configs, you can use `git commit` with `-s` or `--signoff` to add the `Signed-off-by` line to the end of the commit message. We also require revert commits to include a DCO. + +You may type this line on your own when writing your commit messages. However, if your +user.name and user.email are set in your git configs, you can use `git commit` with `-s` +or `--signoff` to add the `Signed-off-by` line to the end of the commit message. We also +require revert commits to include a DCO. # How to provide a patch for a new feature @@ -74,7 +86,8 @@ and creating an issue at Github with the description of, exactly, what you want to accomplish and why. Use cases are important for features to be accepted. Here you can see if there is consensus about your idea. -2. If in step 1 you get an acknowledgment from the project leaders, use the following procedure to submit a patch: +2. If in step 1 you get an acknowledgment from the project leaders, use the following +procedure to submit a patch: 1. Fork Valkey on GitHub ( https://docs.github.com/en/github/getting-started-with-github/fork-a-repo ) 1. Create a topic branch (git checkout -b my_branch) 1. Make the needed changes and commit with a DCO. (git commit -s) From 289eb47eb96d30f08543d721880fe99b623abd48 Mon Sep 17 00:00:00 2001 From: Mikel Olasagasti Uranga Date: Sat, 30 Mar 2024 14:23:50 +0100 Subject: [PATCH 04/98] Replace offensive term (#86) Signed-off-by: Mikel Olasagasti Uranga --- Makefile | 2 +- deps/linenoise/linenoise.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e614ede891..5c16c36eba 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Top level makefile, the real shit is at src/Makefile +# Top level makefile, the real magic is at src/Makefile default: all diff --git a/deps/linenoise/linenoise.c b/deps/linenoise/linenoise.c index 75306390ec..36d266f891 100644 --- a/deps/linenoise/linenoise.c +++ b/deps/linenoise/linenoise.c @@ -233,7 +233,7 @@ static int isUnsupportedTerm(void) { return 0; } -/* Raw mode: 1960 magic shit. */ +/* Raw mode: 1960's magic. */ static int enableRawMode(int fd) { struct termios raw; From 3ab066f71002de28025a7b28af4e90310294e40e Mon Sep 17 00:00:00 2001 From: Roshan Khatri <117414976+roshkhatri@users.noreply.github.com> Date: Sat, 30 Mar 2024 07:42:00 -0700 Subject: [PATCH 05/98] For additional compatibility this adds REDIS_CFLAGS and REDIS_LDFLAGS support to MAKEFILE (#66) This resolves (1.viii) from https://github.com/valkey-io/valkey/issues/43 > REDIS_FLAGS will be updated to SERVER_FLAGS. Maybe we should also allow REDIS_FLAGS -> SERVER_FLAGS as well, for an extra layer of compatibility. --------- Signed-off-by: Roshan Khatri --- src/Makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index f762e2912c..e8d6fcca37 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,12 +1,12 @@ -# Redis Makefile +# Valkey Makefile # Copyright (C) 2009 Salvatore Sanfilippo # This file is released under the BSD license, see the COPYING file # # The Makefile composes the final FINAL_CFLAGS and FINAL_LDFLAGS using -# what is needed for Redis plus the standard CFLAGS and LDFLAGS passed. +# what is needed for Valkey plus the standard CFLAGS and LDFLAGS passed. # However when building the dependencies (Jemalloc, Lua, Hiredis, ...) # CFLAGS and LDFLAGS are propagated to the dependencies, so to pass -# flags only to be used when compiling / linking Redis itself SERVER_CFLAGS +# flags only to be used when compiling / linking Valkey itself SERVER_CFLAGS # and SERVER_LDFLAGS are used instead (this is the case of 'make gcov'). # # Dependencies are stored in the Makefile.dep file. To rebuild this file @@ -76,7 +76,7 @@ ifeq ($(uname_S),Linux) MALLOC=jemalloc endif -# To get ARM stack traces if Redis crashes we need a special C flag. +# To get ARM stack traces if Valkey crashes we need a special C flag. ifneq (,$(filter aarch64 armv%,$(uname_M))) CFLAGS+=-funwind-tables endif @@ -122,6 +122,14 @@ endif # Override default settings if possible -include .make-settings +# For added compatibility REDIS_CFLAGS and REDIS_LDFLAGS are also supported. +ifdef REDIS_CFLAGS + SERVER_CFLAGS := $(REDIS_CFLAGS) +endif +ifdef REDIS_LDFLAGS + SERVER_LDFLAGS := $(REDIS_LDFLAGS) +endif + FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(SERVER_CFLAGS) FINAL_LDFLAGS=$(LDFLAGS) $(OPT) $(SERVER_LDFLAGS) $(DEBUG) FINAL_LIBS=-lm From de311aea53fa2fd039ae4f7652150e2166dfbaea Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Sat, 30 Mar 2024 23:24:21 +0800 Subject: [PATCH 06/98] Doc add SECURITY.md link inside CONTRIBUTING.md (#96) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vitah Lin Signed-off-by: Viktor Söderqvist --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ad257664c5..5969bce874 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,7 @@ Issues and pull requests for documentation belong on the valkey-doc repo: https://github.com/valkey-io/valkey-doc -If you are reporting a security bug or vulnerability, see SECURITY.md. +If you are reporting a security bug or vulnerability, see [SECURITY.md](SECURITY.md). ## Developer Certificate of Origin From b2a397366b1704b03f5042395ff620cd2096f598 Mon Sep 17 00:00:00 2001 From: ranshid <88133677+ranshid@users.noreply.github.com> Date: Sat, 30 Mar 2024 21:50:16 +0300 Subject: [PATCH 07/98] Change ascii logo with temporal valkey logo (#77) --- src/asciilogo.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/asciilogo.h b/src/asciilogo.h index a62f68cf94..baa55e3fb2 100644 --- a/src/asciilogo.h +++ b/src/asciilogo.h @@ -28,20 +28,20 @@ */ const char *ascii_logo = -" _._ \n" -" _.-``__ ''-._ \n" -" _.-`` `. `_. ''-._ Redis %s (%s/%d) %s bit\n" -" .-`` .-```. ```\\/ _.,_ ''-._ \n" -" ( ' , .-` | `, ) Running in %s mode\n" -" |`-._`-...-` __...-.``-._|'` _.-'| Port: %d\n" -" | `-._ `._ / _.-' | PID: %ld\n" -" `-._ `-._ `-./ _.-' _.-' \n" -" |`-._`-._ `-.__.-' _.-'_.-'| \n" -" | `-._`-._ _.-'_.-' | https://redis.io \n" -" `-._ `-._`-.__.-'_.-' _.-' \n" -" |`-._`-._ `-.__.-' _.-'_.-'| \n" -" | `-._`-._ _.-'_.-' | \n" -" `-._ `-._`-.__.-'_.-' _.-' \n" -" `-._ `-.__.-' _.-' \n" -" `-._ _.-' \n" -" `-.__.-' \n\n"; +" ___ ___ \n" +" ( ) ( ) \n" +" ___ ___ .---. | | | | ___ .--. ___ ___ \n" +"( )( ) / .-, \\ | | | | ( ) / \\ ( )( ) Valkey %s (%s/%d) %s bit \n" +" | | | | (__) ; | | | | | ' / | .-. ; | | | | \n" +" | | | | .'` | | | | |,' / | | | | | | | | Running in %s mode \n" +" | | | | / .'| | | | | . '. | |/ | | ' | | Port: %d \n" +" | | | | | / | | | | | | `. \\ | ' _.' ' `-' | PID: %ld \n" +" ' ' ; ' ; | ; | | | | | \\ \\ | .'.-. `.__. | \n" +" \\ `' / ' `-' | | | | | \\ . ' `-' / ___ | | \n" +" '_.' `.__.'_. (___) (___ ) (___) `.__.' ( )' | https://valkey.io\n" +" ; `-' ' \n" +" .__.' \n" +" \n" +" \n\n"; + + From af1b0de92de2ace4a01e74cf9ed7d7d6f3dedf70 Mon Sep 17 00:00:00 2001 From: Cong Chen Date: Sun, 31 Mar 2024 13:11:13 +0800 Subject: [PATCH 08/98] Fix typo (#84) A simple PR to fix a typo. Signed-off-by: Cong Chen --- src/acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/acl.c b/src/acl.c index 26827f97a0..81f8b38499 100644 --- a/src/acl.c +++ b/src/acl.c @@ -635,7 +635,7 @@ void ACLSelectorRemoveCommandRule(aclSelector *selector, sds new_rule) { sdsupdatelen(selector->command_rules); } -/* This function is resopnsible for updating the command_rules struct so that relative ordering of +/* This function is responsible for updating the command_rules struct so that relative ordering of * commands and categories is maintained and can be reproduced without loss. */ void ACLUpdateCommandRules(aclSelector *selector, const char *rule, int allow) { sds new_rule = sdsnew(rule); From 253fe9dcedbab88bd2f3d85b3be7a5d037c4a4a5 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 1 Apr 2024 03:38:22 +0800 Subject: [PATCH 09/98] Fix typos and replace 'codespell' with 'typos' (#72) Uses https://github.com/taiki-e/install-action to install https://github.com/crate-ci/typos in CI This finds many more/different typos than https://github.com/codespell-project/codespell , while having very few false positives. Signed-off-by: John Vandenberg --- .codespell/.codespellrc | 5 -- .codespell/requirements.txt | 1 - .codespell/wordlist.txt | 21 --------- .config/typos.toml | 61 +++++++++++++++++++++++++ .github/dependabot.yml | 6 +-- .github/workflows/spell-check.yml | 13 ++---- src/atomicvar.h | 2 +- src/script_lua.h | 2 +- src/server.c | 4 +- src/server.h | 4 +- src/util.c | 2 +- tests/assets/test_cli_hint_suite.txt | 2 +- tests/integration/rdb.tcl | 2 +- tests/modules/fork.c | 8 ++-- tests/support/response_transformers.tcl | 52 ++++++++++----------- tests/unit/acl.tcl | 6 +-- tests/unit/moduleapi/misc.tcl | 2 +- tests/unit/multi.tcl | 6 +-- tests/unit/type/stream-cgroups.tcl | 2 +- tests/unit/type/zset.tcl | 2 +- 20 files changed, 114 insertions(+), 89 deletions(-) delete mode 100644 .codespell/.codespellrc delete mode 100644 .codespell/requirements.txt delete mode 100644 .codespell/wordlist.txt create mode 100644 .config/typos.toml diff --git a/.codespell/.codespellrc b/.codespell/.codespellrc deleted file mode 100644 index 75b9257429..0000000000 --- a/.codespell/.codespellrc +++ /dev/null @@ -1,5 +0,0 @@ -[codespell] -quiet-level = 2 -count = -skip = ./deps,./src/crc16_slottable.h,tmp*,./.git,./lcov-html -ignore-words = ./.codespell/wordlist.txt diff --git a/.codespell/requirements.txt b/.codespell/requirements.txt deleted file mode 100644 index ddff454685..0000000000 --- a/.codespell/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -codespell==2.2.5 diff --git a/.codespell/wordlist.txt b/.codespell/wordlist.txt deleted file mode 100644 index 0bc0beb1ee..0000000000 --- a/.codespell/wordlist.txt +++ /dev/null @@ -1,21 +0,0 @@ -ake -bale -fle -fo -gameboy -mutli -nd -nees -oll -optin -ot -smove -te -tre -cancelability -ist -statics -filetest -ro -exat -clen \ No newline at end of file diff --git a/.config/typos.toml b/.config/typos.toml new file mode 100644 index 0000000000..e810af9a14 --- /dev/null +++ b/.config/typos.toml @@ -0,0 +1,61 @@ +# See https://github.com/crate-ci/typos/blob/master/docs/reference.md to configure typos + +[files] +extend-exclude = [ + "deps/", + # crc16_slottable is primarily pre-generated random strings. + "src/crc16_slottable.h", +] + +[default.extend-words] +exat = "exat" +optin = "optin" +smove = "smove" + +[type.c] +extend-ignore-re = [ + "BA3E2571", # sha1.c + "D4C4DAA4", # sha1.c + "Georg Nees", + "\\[l\\]ist", # eval.c +] + +[type.tcl] +extend-ignore-re = [ + "DUMPed", +] + +[type.sv.extend-identifiers] +# sv = .h +module_gil_acquring = "module_gil_acquring" + +[type.c.extend-identifiers] +clen = "clen" +fle = "fle" +module_gil_acquring = "module_gil_acquring" +nd = "nd" +ot = "ot" + +[type.tcl.extend-identifiers] +fo = "fo" +oll = "oll" +stressers = "stressers" + +[type.sv.extend-words] +# sv = .h +fo = "fo" +seeked = "seeked" + +[type.c.extend-words] +fo = "fo" +limite = "limite" +seeked = "seeked" +tre = "tre" + +[type.systemd.extend-words] +# systemd = .conf +ake = "ake" + +[type.tcl.extend-words] +fo = "fo" +tre = "tre" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f00019d2ec..376c4171a6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,14 +2,10 @@ # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - +--- version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: weekly - - package-ecosystem: pip - directory: /.codespell - schedule: - interval: weekly diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 77f5437ca2..dfbb33008d 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -18,15 +18,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: pip cache - uses: actions/cache@v4 + - name: Install typos + uses: taiki-e/install-action@v2 with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: ${{ runner.os }}-pip- - - - name: Install prerequisites - run: sudo pip install -r ./.codespell/requirements.txt + tool: typos - name: Spell check - run: codespell --config=./.codespell/.codespellrc + run: typos --config=./.config/typos.toml diff --git a/src/atomicvar.h b/src/atomicvar.h index 1cbfd5b9df..bcabdccc58 100644 --- a/src/atomicvar.h +++ b/src/atomicvar.h @@ -32,7 +32,7 @@ * (if the flag was 0 -> set to 1, if it's already 1 -> do nothing, but the final result is that the flag is set), * and also it has a full barrier (__sync_lock_test_and_set has acquire barrier). * - * NOTE2: Unlike other atomic type, which aren't guaranteed to be lock free, c11 atmoic_flag does. + * NOTE2: Unlike other atomic type, which aren't guaranteed to be lock free, c11 atomic_flag does. * To check whether a type is lock free, atomic_is_lock_free() can be used. * It can be considered to limit the flag type to atomic_flag to improve performance. * diff --git a/src/script_lua.h b/src/script_lua.h index 4c2b34804e..fc665a1c65 100644 --- a/src/script_lua.h +++ b/src/script_lua.h @@ -36,7 +36,7 @@ * * * Execute Lua code, assuming that the code is located on * the top of the Lua stack. In addition, parsing the execution - * result and convert it to the resp and reply ot the client. + * result and convert it to the resp and reply to the client. * * * Run Redis commands from within the Lua code (Including * parsing the reply and create a Lua object out of it). diff --git a/src/server.c b/src/server.c index 221ab00365..999d799cab 100644 --- a/src/server.c +++ b/src/server.c @@ -2575,7 +2575,7 @@ void resetServerStats(void) { } /* Make the thread killable at any time, so that kill threads functions - * can work reliably (default cancelability type is PTHREAD_CANCEL_DEFERRED). + * can work reliably (default cancellability type is PTHREAD_CANCEL_DEFERRED). * Needed for pthread_cancel used by the fast memory test used by the crash report. */ void makeThreadKillable(void) { pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); @@ -6580,7 +6580,7 @@ void dismissClientMemory(client *c) { /* In the child process, we don't need some buffers anymore, and these are * likely to change in the parent when there's heavy write traffic. * We dismiss them right away, to avoid CoW. - * see dismissMemeory(). */ + * see dismissMemory(). */ void dismissMemoryInChild(void) { /* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */ if (server.thp_enabled) return; diff --git a/src/server.h b/src/server.h index 411edadec4..b9dbd65e7e 100644 --- a/src/server.h +++ b/src/server.h @@ -1989,7 +1989,7 @@ struct redisServer { xor of NOTIFY_... flags. */ kvstore *pubsubshard_channels; /* Map shard channels in every slot to list of subscribed clients */ unsigned int pubsub_clients; /* # of clients in Pub/Sub mode */ - unsigned int watching_clients; /* # of clients are wathcing keys */ + unsigned int watching_clients; /* # of clients are watching keys */ /* Cluster */ int cluster_enabled; /* Is cluster enabled? */ int cluster_port; /* Set the cluster port for a node. */ @@ -3432,7 +3432,7 @@ void blockForAofFsync(client *c, mstime_t timeout, long long offset, int numloca void signalDeletedKeyAsReady(redisDb *db, robj *key, int type); void updateStatsOnUnblock(client *c, long blocked_us, long reply_us, int had_errors); void scanDatabaseForDeletedKeys(redisDb *emptied, redisDb *replaced_with); -void totalNumberOfStatefulKeys(unsigned long *blocking_keys, unsigned long *bloking_keys_on_nokey, unsigned long *watched_keys); +void totalNumberOfStatefulKeys(unsigned long *blocking_keys, unsigned long *blocking_keys_on_nokey, unsigned long *watched_keys); void blockedBeforeSleep(void); /* timeout.c -- Blocked clients timeout and connections timeout. */ diff --git a/src/util.c b/src/util.c index 47de1c8d1a..ac17cd187b 100644 --- a/src/util.c +++ b/src/util.c @@ -1631,7 +1631,7 @@ static void test_reclaimFilePageCache(void) { assert(!cache_exist(fd)); unlink(tmpfile); - printf("reclaimFilePageCach test is ok\n"); + printf("reclaimFilePageCache test is ok\n"); } #endif diff --git a/tests/assets/test_cli_hint_suite.txt b/tests/assets/test_cli_hint_suite.txt index 18c1fe07a4..b4a20163fb 100644 --- a/tests/assets/test_cli_hint_suite.txt +++ b/tests/assets/test_cli_hint_suite.txt @@ -36,7 +36,7 @@ # Two-word command with multiple non-token block args: CONFIG SET parameter value [parameter value ...] "CONFIG SET param " "value [parameter value ...]" "CONFIG SET param val " "[parameter value ...]" -"CONFIG SET param val parm2 val2 " "[parameter value ...]" +"CONFIG SET param val param2 val2 " "[parameter value ...]" # Command with nested optional args: ZRANDMEMBER key [count [WITHSCORES]] "ZRANDMEMBER k " "[count [WITHSCORES]]" diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index cce21671f8..106fc0b50c 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -387,7 +387,7 @@ start_server {} { # make sure a write command fails assert_error {MISCONF *} {r set x y} - # repeate with script + # repeat with script assert_error {MISCONF *} {r eval { return redis.call('set','x',1) } 1 x diff --git a/tests/modules/fork.c b/tests/modules/fork.c index d7a0d154f1..cad09d5bb5 100644 --- a/tests/modules/fork.c +++ b/tests/modules/fork.c @@ -11,11 +11,11 @@ #define UNUSED(V) ((void) V) int child_pid = -1; -int exitted_with_code = -1; +int exited_with_code = -1; void done_handler(int exitcode, int bysignal, void *user_data) { child_pid = -1; - exitted_with_code = exitcode; + exited_with_code = exitcode; assert(user_data==(void*)0xdeadbeef); UNUSED(bysignal); } @@ -36,7 +36,7 @@ int fork_create(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) RedisModule_StringToLongLong(argv[1], &code_to_exit_with); RedisModule_StringToLongLong(argv[2], &usleep_us); - exitted_with_code = -1; + exited_with_code = -1; int fork_child_pid = RedisModule_Fork(done_handler, (void*)0xdeadbeef); if (fork_child_pid < 0) { RedisModule_ReplyWithError(ctx, "Fork failed"); @@ -61,7 +61,7 @@ int fork_exitcode(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { UNUSED(argv); UNUSED(argc); - RedisModule_ReplyWithLongLong(ctx, exitted_with_code); + RedisModule_ReplyWithLongLong(ctx, exited_with_code); return REDISMODULE_OK; } diff --git a/tests/support/response_transformers.tcl b/tests/support/response_transformers.tcl index 45b3cf8f2e..c49bbb15c3 100644 --- a/tests/support/response_transformers.tcl +++ b/tests/support/response_transformers.tcl @@ -20,7 +20,7 @@ namespace eval response_transformers {} # Transform a map response into an array of tuples (tuple = array with 2 elements) # Used for XREAD[GROUP] -proc transfrom_map_to_tupple_array {argv response} { +proc transform_map_to_tuple_array {argv response} { set tuparray {} foreach {key val} $response { set tmp {} @@ -32,7 +32,7 @@ proc transfrom_map_to_tupple_array {argv response} { } # Transform an array of tuples to a flat array -proc transfrom_tuple_array_to_flat_array {argv response} { +proc transform_tuple_array_to_flat_array {argv response} { set flatarray {} foreach pair $response { lappend flatarray {*}$pair @@ -42,10 +42,10 @@ proc transfrom_tuple_array_to_flat_array {argv response} { # With HRANDFIELD, we only need to transform the response if the request had WITHVALUES # (otherwise the returned response is a flat array in both RESPs) -proc transfrom_hrandfield_command {argv response} { +proc transform_hrandfield_command {argv response} { foreach ele $argv { if {[string compare -nocase $ele "WITHVALUES"] == 0} { - return [transfrom_tuple_array_to_flat_array $argv $response] + return [transform_tuple_array_to_flat_array $argv $response] } } return $response @@ -53,10 +53,10 @@ proc transfrom_hrandfield_command {argv response} { # With some zset commands, we only need to transform the response if the request had WITHSCORES # (otherwise the returned response is a flat array in both RESPs) -proc transfrom_zset_withscores_command {argv response} { +proc transform_zset_withscores_command {argv response} { foreach ele $argv { if {[string compare -nocase $ele "WITHSCORES"] == 0} { - return [transfrom_tuple_array_to_flat_array $argv $response] + return [transform_tuple_array_to_flat_array $argv $response] } } return $response @@ -64,29 +64,29 @@ proc transfrom_zset_withscores_command {argv response} { # With ZPOPMIN/ZPOPMAX, we only need to transform the response if the request had COUNT (3rd arg) # (otherwise the returned response is a flat array in both RESPs) -proc transfrom_zpopmin_zpopmax {argv response} { +proc transform_zpopmin_zpopmax {argv response} { if {[llength $argv] == 3} { - return [transfrom_tuple_array_to_flat_array $argv $response] + return [transform_tuple_array_to_flat_array $argv $response] } return $response } -set ::trasformer_funcs { - XREAD transfrom_map_to_tupple_array - XREADGROUP transfrom_map_to_tupple_array - HRANDFIELD transfrom_hrandfield_command - ZRANDMEMBER transfrom_zset_withscores_command - ZRANGE transfrom_zset_withscores_command - ZRANGEBYSCORE transfrom_zset_withscores_command - ZRANGEBYLEX transfrom_zset_withscores_command - ZREVRANGE transfrom_zset_withscores_command - ZREVRANGEBYSCORE transfrom_zset_withscores_command - ZREVRANGEBYLEX transfrom_zset_withscores_command - ZUNION transfrom_zset_withscores_command - ZDIFF transfrom_zset_withscores_command - ZINTER transfrom_zset_withscores_command - ZPOPMIN transfrom_zpopmin_zpopmax - ZPOPMAX transfrom_zpopmin_zpopmax +set ::transformer_funcs { + XREAD transform_map_to_tuple_array + XREADGROUP transform_map_to_tuple_array + HRANDFIELD transform_hrandfield_command + ZRANDMEMBER transform_zset_withscores_command + ZRANGE transform_zset_withscores_command + ZRANGEBYSCORE transform_zset_withscores_command + ZRANGEBYLEX transform_zset_withscores_command + ZREVRANGE transform_zset_withscores_command + ZREVRANGEBYSCORE transform_zset_withscores_command + ZREVRANGEBYLEX transform_zset_withscores_command + ZUNION transform_zset_withscores_command + ZDIFF transform_zset_withscores_command + ZINTER transform_zset_withscores_command + ZPOPMIN transform_zpopmin_zpopmax + ZPOPMAX transform_zpopmin_zpopmax } proc ::response_transformers::transform_response_if_needed {id argv response} { @@ -95,11 +95,11 @@ proc ::response_transformers::transform_response_if_needed {id argv response} { } set key [string toupper [lindex $argv 0]] - if {![dict exists $::trasformer_funcs $key]} { + if {![dict exists $::transformer_funcs $key]} { return $response } - set transform [dict get $::trasformer_funcs $key] + set transform [dict get $::transformer_funcs $key] return [$transform $argv $response] } diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index 95b8a376ef..1457b57b77 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -666,16 +666,16 @@ start_server {tags {"acl external:skip"}} { for {set j 0} {$j < 10} {incr j} { assert_error "*WRONGPASS*" {r AUTH user1 doo} } - set entry_id_lastest_error [dict get [lindex [r ACL LOG] 0] entry-id] + set entry_id_latest_error [dict get [lindex [r ACL LOG] 0] entry-id] set timestamp_created_updated [dict get [lindex [r ACL LOG] 0] timestamp-created] set timestamp_last_updated_after_update [dict get [lindex [r ACL LOG] 0] timestamp-last-updated] - assert {$entry_id_lastest_error eq $entry_id_initial_error} + assert {$entry_id_latest_error eq $entry_id_initial_error} assert {$timestamp_last_update_original < $timestamp_last_updated_after_update} assert {$timestamp_created_original eq $timestamp_created_updated} r ACL setuser user2 >doo assert_error "*WRONGPASS*" {r AUTH user2 foo} set new_error_entry_id [dict get [lindex [r ACL LOG] 0] entry-id] - assert {$new_error_entry_id eq $entry_id_lastest_error + 1 } + assert {$new_error_entry_id eq $entry_id_latest_error + 1 } } test {ACL LOG shows failed command executions at toplevel} { diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index 78def54772..41f9dd3fa1 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -466,7 +466,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # rm_call in script mode assert_error {MISCONF *} {r test.rm_call_flags S set x 1} - # repeate with script + # repeat with script assert_error {MISCONF *} {r test.rm_call eval { return redis.call('set','x',1) } 1 x diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 4e8e807256..85d20ddf38 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -553,7 +553,7 @@ start_server {tags {"multi"}} { catch { $r2 exec; } e assert_match {EXECABORT*previous errors*} $e set xx [r get xx] - # make sure that either the whole transcation passed or none of it (we actually expect none) + # make sure that either the whole transaction passed or none of it (we actually expect none) assert { $xx == 1 || $xx == 3} # check that the connection is no longer in multi state set pong [$r2 ping asdf] @@ -578,7 +578,7 @@ start_server {tags {"multi"}} { r script kill after 200 ; # Give some time to Lua to call the hook again... set xx [r get xx] - # make sure that either the whole transcation passed or none of it (we actually expect none) + # make sure that either the whole transaction passed or none of it (we actually expect none) assert { $xx == 1 || $xx == 3} # check that the connection is no longer in multi state set pong [$r2 ping asdf] @@ -603,7 +603,7 @@ start_server {tags {"multi"}} { catch { $r2 exec; } e assert_match {EXECABORT*previous errors*} $e set xx [r get xx] - # make sure that either the whole transcation passed or none of it (we actually expect none) + # make sure that either the whole transaction passed or none of it (we actually expect none) assert { $xx == 1 || $xx == 3} # check that the connection is no longer in multi state set pong [$r2 ping asdf] diff --git a/tests/unit/type/stream-cgroups.tcl b/tests/unit/type/stream-cgroups.tcl index 9b457dc676..a86488a78c 100644 --- a/tests/unit/type/stream-cgroups.tcl +++ b/tests/unit/type/stream-cgroups.tcl @@ -1051,7 +1051,7 @@ start_server { set n_consumers [lindex $grpinfo 3] # All consumers are created via XREADGROUP, regardless of whether they managed - # to read any entries ot not + # to read any entries or not assert_equal $n_consumers 3 $rd close } diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index dc0554d841..03f451c797 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -289,7 +289,7 @@ start_server {tags {"zset"}} { assert {[r zscore ztmp x] == 25} } - test "ZADD INCR works with a single score-elemenet pair - $encoding" { + test "ZADD INCR works with a single score-element pair - $encoding" { r del ztmp r zadd ztmp 10 x 20 y 30 z catch {r zadd ztmp INCR 15 x 10 y} err From bdd7314f419e07e5ad0b21b0d3e801aef280f902 Mon Sep 17 00:00:00 2001 From: Ping Xie Date: Sun, 31 Mar 2024 19:56:24 -0700 Subject: [PATCH 10/98] Fine-tune ASCII art (#103) --- src/asciilogo.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/asciilogo.h b/src/asciilogo.h index baa55e3fb2..b291ca76bb 100644 --- a/src/asciilogo.h +++ b/src/asciilogo.h @@ -28,17 +28,17 @@ */ const char *ascii_logo = -" ___ ___ \n" +" ___ ___ \n" " ( ) ( ) \n" " ___ ___ .---. | | | | ___ .--. ___ ___ \n" -"( )( ) / .-, \\ | | | | ( ) / \\ ( )( ) Valkey %s (%s/%d) %s bit \n" +"( )( ) / .-, \\ | | | | ( ) / \\ ( )( ) Valkey %s (%s/%d) %s bit \n" " | | | | (__) ; | | | | | ' / | .-. ; | | | | \n" " | | | | .'` | | | | |,' / | | | | | | | | Running in %s mode \n" " | | | | / .'| | | | | . '. | |/ | | ' | | Port: %d \n" " | | | | | / | | | | | | `. \\ | ' _.' ' `-' | PID: %ld \n" -" ' ' ; ' ; | ; | | | | | \\ \\ | .'.-. `.__. | \n" -" \\ `' / ' `-' | | | | | \\ . ' `-' / ___ | | \n" -" '_.' `.__.'_. (___) (___ ) (___) `.__.' ( )' | https://valkey.io\n" +" ' ' ; ' ; | ; | | | | | \\ \\ | .'.-. `.__. | \n" +" \\ `' / ' `-' | | | | | \\ . ' `-' / ___ | | \n" +" \\__/ `.__.'_. (___) (___ ) (___) `.__.' ( )' | https://valkey.io\n" " ; `-' ' \n" " .__.' \n" " \n" From 3630dd08a6d3a7449cef738f965ae2c781f6b29b Mon Sep 17 00:00:00 2001 From: Roshan Khatri <117414976+roshkhatri@users.noreply.github.com> Date: Mon, 1 Apr 2024 09:55:01 -0700 Subject: [PATCH 11/98] Restore all tests state prior to fork (#117) Related to https://github.com/valkey-io/valkey/pull/11#issuecomment-2028930612 Restore all tests state prior to fork and re-enables Daily tests on PRs on release branches. Reverts https://github.com/valkey-io/valkey/commit/2aa820f945a7db9a09203b1f60dfb70662cdd3a6 --------- Signed-off-by: Roshan Khatri --- .github/workflows/daily.yml | 4 ++++ .github/workflows/external.yml | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index f67540b1c1..85ee899bac 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -1,6 +1,10 @@ name: Daily on: + pull_request: + branches: + # any PR to a release branch. + - '[0-9].[0-9]' schedule: - cron: '0 0 * * *' workflow_dispatch: diff --git a/.github/workflows/external.yml b/.github/workflows/external.yml index 0113858fec..8c35d5c88c 100644 --- a/.github/workflows/external.yml +++ b/.github/workflows/external.yml @@ -1,10 +1,10 @@ name: External Server Tests on: - pull_request: - push: - schedule: - - cron: '* * * * *' + pull_request: + push: + schedule: + - cron: '0 0 * * *' jobs: test-external-standalone: From 0a51ceca88ac1951c51fa901f228b58c9a386a5b Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Tue, 2 Apr 2024 10:44:21 +0900 Subject: [PATCH 12/98] bump actions/checkout v4 (#87) Node.js 16 actions are deprecated. To result them we are updating to actions/checkout@v4. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/. e.g. failure https://github.com/valkey-io/valkey/actions/runs/8482578610 --------- Signed-off-by: ICHINOSE Shogo --- .github/workflows/ci.yml | 15 ++++--- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/daily.yml | 52 +++++++++++----------- .github/workflows/external.yml | 6 +-- .github/workflows/reply-schemas-linter.yml | 2 +- .github/workflows/spell-check.yml | 2 +- 6 files changed, 41 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf50c31e32..7bd01183f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: test-ubuntu-latest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: make # Fail build if there are warnings # build with TLS just for compilation coverage @@ -28,7 +28,7 @@ jobs: test-sanitizer-address: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: make # build with TLS module just for compilation coverage run: make SANITIZER=address SERVER_CFLAGS='-Werror -DDEBUG_ASSERTIONS' BUILD_TLS=module @@ -46,7 +46,7 @@ jobs: runs-on: ubuntu-latest container: debian:buster steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: make run: | apt-get update && apt-get install -y build-essential @@ -55,14 +55,14 @@ jobs: build-macos-latest: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: make run: make SERVER_CFLAGS='-Werror' build-32bit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: make run: | sudo apt-get update && sudo apt-get install libc6-dev-i386 @@ -71,7 +71,7 @@ jobs: build-libc-malloc: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: make run: make SERVER_CFLAGS='-Werror' MALLOC=libc @@ -79,7 +79,10 @@ jobs: runs-on: ubuntu-latest container: centos:7 steps: + # on centos7, actions/checkout@v4 does not work, so we use v3 + # ref. https://github.com/actions/checkout/issues/1487 - uses: actions/checkout@v3 + - name: make run: | yum -y install gcc make diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 34e18674f2..4c7484b99b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 85ee899bac..bb0a7daf07 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -47,7 +47,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -88,7 +88,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -131,7 +131,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -168,7 +168,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -205,7 +205,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -249,7 +249,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -293,7 +293,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -337,7 +337,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -369,7 +369,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -447,7 +447,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -477,7 +477,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -512,7 +512,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -542,7 +542,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -582,7 +582,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -631,7 +631,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -674,7 +674,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -714,7 +714,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -761,7 +761,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -807,7 +807,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -836,7 +836,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -862,7 +862,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -894,7 +894,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -913,7 +913,7 @@ jobs: run: | echo "GITHUB_REPOSITORY=${{github.event.inputs.use_repo}}" >> $GITHUB_ENV echo "GITHUB_HEAD_REF=${{github.event.inputs.use_git_ref}}" >> $GITHUB_ENV - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -945,7 +945,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -984,7 +984,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -1023,7 +1023,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} diff --git a/.github/workflows/external.yml b/.github/workflows/external.yml index 8c35d5c88c..bd6b438394 100644 --- a/.github/workflows/external.yml +++ b/.github/workflows/external.yml @@ -12,7 +12,7 @@ jobs: if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey' timeout-minutes: 14400 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build run: make SERVER_CFLAGS=-Werror - name: Start valkey-server @@ -37,7 +37,7 @@ jobs: if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey' timeout-minutes: 14400 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build run: make SERVER_CFLAGS=-Werror - name: Start valkey-server @@ -65,7 +65,7 @@ jobs: if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey' timeout-minutes: 14400 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build run: make SERVER_CFLAGS=-Werror - name: Start valkey-server diff --git a/.github/workflows/reply-schemas-linter.yml b/.github/workflows/reply-schemas-linter.yml index 6893bb3dca..a57a97ab3d 100644 --- a/.github/workflows/reply-schemas-linter.yml +++ b/.github/workflows/reply-schemas-linter.yml @@ -12,7 +12,7 @@ jobs: reply-schemas-linter: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup nodejs uses: actions/setup-node@v4 - name: Install packages diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index dfbb33008d..1e6f58aacb 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install typos uses: taiki-e/install-action@v2 From 0ba2f1b14e03172f51c0b6ec2fed6af0d8378191 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Mon, 1 Apr 2024 21:31:17 -0700 Subject: [PATCH 13/98] Update coverity to reflect project name (#127) Fix the coverity name to reflect the actual name in coverity. See successful build here: https://github.com/valkey-io/valkey/actions/runs/8516329554. Also removed unnecessary TCL dependency from the install. Signed-off-by: Madelyn Olson --- .github/workflows/coverity.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 36d7cf7ae3..791bb275b2 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -14,19 +14,18 @@ jobs: - uses: actions/checkout@main - name: Download and extract the Coverity Build Tool run: | - wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=valkey-unstable" -O cov-analysis-linux64.tar.gz + wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=valkey-io%2Fvalkey" -O cov-analysis-linux64.tar.gz mkdir cov-analysis-linux64 tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64 - name: Install Valkey dependencies - run: sudo apt install -y gcc tcl8.6 tclx procps libssl-dev + run: sudo apt install -y gcc procps libssl-dev - name: Build with cov-build run: cov-analysis-linux64/bin/cov-build --dir cov-int make - name: Upload the result run: | tar czvf cov-int.tgz cov-int curl \ - --form project=valkey-unstable \ --form email=${{ secrets.COVERITY_SCAN_EMAIL }} \ --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \ --form file=@cov-int.tgz \ - https://scan.coverity.com/builds + https://scan.coverity.com/builds?project=valkey-io%2Fvalkey From 4d7fff9abacab3c8c7618caea419aebeb71f266e Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:37:19 +0700 Subject: [PATCH 14/98] Remove unused var desc in luaRegisterFunctionReadPositionalArgs (#130) desc is set to NULL, never set to anything, and then checked if it should be freed on the error path if it's NULL. This can be cleaned up, since it's really unused. Fixes #129 Signed-off-by: 0del --- src/function_lua.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/function_lua.c b/src/function_lua.c index be79dc1638..8b334fcd24 100644 --- a/src/function_lua.c +++ b/src/function_lua.c @@ -354,7 +354,6 @@ static int luaRegisterFunctionReadNamedArgs(lua_State *lua, registerFunctionArgs static int luaRegisterFunctionReadPositionalArgs(lua_State *lua, registerFunctionArgs *register_f_args) { char *err = NULL; sds name = NULL; - sds desc = NULL; luaFunctionCtx *lua_f_ctx = NULL; if (!(name = luaGetStringSds(lua, 1))) { err = "first argument to redis.register_function must be a string"; @@ -377,7 +376,6 @@ static int luaRegisterFunctionReadPositionalArgs(lua_State *lua, registerFunctio error: if (name) sdsfree(name); - if (desc) sdsfree(desc); luaPushError(lua, err); return C_ERR; } From e35d86f2a28bd39fc883132c361a2def7a463094 Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Tue, 2 Apr 2024 15:43:37 +0800 Subject: [PATCH 15/98] Fix rename REDIS_TEST to SERVER_TEST to pass the Daily workflow (#131) The test flag `REDIS_TEST` has already be changed to `SERVER_TEST` in `.github/workflows/daily.yml`, the name in the src directory need to be changed as well. ```shell run: | sudo apt-get update && sudo apt-get install libc6-dev-i386 make 32bit SERVER_CFLAGS='-Werror -DSERVER_TEST' ``` Signed-off-by: Vitah Lin --- deps/hiredis/sds.h | 2 +- src/crc64.c | 2 +- src/crc64.h | 2 +- src/dict.c | 2 +- src/dict.h | 2 +- src/endianconv.c | 2 +- src/endianconv.h | 2 +- src/intset.c | 2 +- src/intset.h | 2 +- src/kvstore.c | 2 +- src/kvstore.h | 2 +- src/listpack.c | 2 +- src/listpack.h | 2 +- src/quicklist.c | 6 +++--- src/quicklist.h | 2 +- src/sds.c | 2 +- src/sds.h | 2 +- src/server.c | 4 ++-- src/sha1.c | 2 +- src/sha1.h | 2 +- src/util.c | 2 +- src/util.h | 2 +- src/ziplist.c | 2 +- src/ziplist.h | 2 +- src/zipmap.c | 2 +- src/zipmap.h | 2 +- src/zmalloc.c | 2 +- src/zmalloc.h | 2 +- 28 files changed, 31 insertions(+), 31 deletions(-) diff --git a/deps/hiredis/sds.h b/deps/hiredis/sds.h index 80784bc838..7f0ca5dfa5 100644 --- a/deps/hiredis/sds.h +++ b/deps/hiredis/sds.h @@ -273,7 +273,7 @@ void *hi_sds_malloc(size_t size); void *hi_sds_realloc(void *ptr, size_t size); void hi_sds_free(void *ptr); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int hi_sdsTest(int argc, char *argv[]); #endif diff --git a/src/crc64.c b/src/crc64.c index 73e0391453..f51d6819c6 100644 --- a/src/crc64.c +++ b/src/crc64.c @@ -123,7 +123,7 @@ uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l) { } /* Test main */ -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #define UNUSED(x) (void)(x) diff --git a/src/crc64.h b/src/crc64.h index e0fccd98bb..3debc3295a 100644 --- a/src/crc64.h +++ b/src/crc64.h @@ -6,7 +6,7 @@ void crc64_init(void); uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int crc64Test(int argc, char *argv[], int flags); #endif diff --git a/src/dict.c b/src/dict.c index d04f9e1231..7e584f079a 100644 --- a/src/dict.c +++ b/src/dict.c @@ -1755,7 +1755,7 @@ void dictGetStats(char *buf, size_t bufsize, dict *d, int full) { /* ------------------------------- Benchmark ---------------------------------*/ -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include "testhelp.h" #define UNUSED(V) ((void) V) diff --git a/src/dict.h b/src/dict.h index b5dc1f19a2..8aaacd41e3 100644 --- a/src/dict.h +++ b/src/dict.h @@ -249,7 +249,7 @@ dictStats* dictGetStatsHt(dict *d, int htidx, int full); void dictCombineStats(dictStats *from, dictStats *into); void dictFreeStats(dictStats *stats); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int dictTest(int argc, char *argv[], int flags); #endif diff --git a/src/endianconv.c b/src/endianconv.c index 8eb6b22288..9344c39ad6 100644 --- a/src/endianconv.c +++ b/src/endianconv.c @@ -101,7 +101,7 @@ uint64_t intrev64(uint64_t v) { return v; } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #define UNUSED(x) (void)(x) diff --git a/src/endianconv.h b/src/endianconv.h index bfe9b7d0ac..0a7ad2a12d 100644 --- a/src/endianconv.h +++ b/src/endianconv.h @@ -71,7 +71,7 @@ uint64_t intrev64(uint64_t v); #define ntohu64(v) intrev64(v) #endif -#ifdef REDIS_TEST +#ifdef SERVER_TEST int endianconvTest(int argc, char *argv[], int flags); #endif diff --git a/src/intset.c b/src/intset.c index 621a74283a..221278fc49 100644 --- a/src/intset.c +++ b/src/intset.c @@ -342,7 +342,7 @@ int intsetValidateIntegrity(const unsigned char *p, size_t size, int deep) { return 1; } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include diff --git a/src/intset.h b/src/intset.h index 41cc7b8222..2da0e9bf1d 100644 --- a/src/intset.h +++ b/src/intset.h @@ -50,7 +50,7 @@ uint32_t intsetLen(const intset *is); size_t intsetBlobLen(intset *is); int intsetValidateIntegrity(const unsigned char *is, size_t size, int deep); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int intsetTest(int argc, char *argv[], int flags); #endif diff --git a/src/kvstore.c b/src/kvstore.c index 62b799dddc..1195db67b8 100644 --- a/src/kvstore.c +++ b/src/kvstore.c @@ -866,7 +866,7 @@ int kvstoreDictDelete(kvstore *kvs, int didx, const void *key) { return ret; } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include "testhelp.h" diff --git a/src/kvstore.h b/src/kvstore.h index bce45fe4c1..b3d8a0e4aa 100644 --- a/src/kvstore.h +++ b/src/kvstore.h @@ -72,7 +72,7 @@ dictEntry *kvstoreDictTwoPhaseUnlinkFind(kvstore *kvs, int didx, const void *key void kvstoreDictTwoPhaseUnlinkFree(kvstore *kvs, int didx, dictEntry *he, dictEntry **plink, int table_index); int kvstoreDictDelete(kvstore *kvs, int didx, const void *key); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int kvstoreTest(int argc, char *argv[], int flags); #endif diff --git a/src/listpack.c b/src/listpack.c index ecc7e9f6fb..470a8f9920 100644 --- a/src/listpack.c +++ b/src/listpack.c @@ -1679,7 +1679,7 @@ void lpRepr(unsigned char *lp) { printf("{end}\n\n"); } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include "adlist.h" diff --git a/src/listpack.h b/src/listpack.h index a60f089f9c..9e51704178 100644 --- a/src/listpack.h +++ b/src/listpack.h @@ -99,7 +99,7 @@ unsigned char *lpNextRandom(unsigned char *lp, unsigned char *p, unsigned int *i int lpSafeToAdd(unsigned char* lp, size_t add); void lpRepr(unsigned char *lp); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int listpackTest(int argc, char *argv[], int flags); #endif diff --git a/src/quicklist.c b/src/quicklist.c index 7fe3430fce..b9f6911700 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -212,7 +212,7 @@ void quicklistRelease(quicklist *quicklist) { * Returns 1 if listpack compressed successfully. * Returns 0 if compression failed or if listpack too small to compress. */ REDIS_STATIC int __quicklistCompressNode(quicklistNode *node) { -#ifdef REDIS_TEST +#ifdef SERVER_TEST node->attempted_compress = 1; #endif if (node->dont_compress) return 0; @@ -254,7 +254,7 @@ REDIS_STATIC int __quicklistCompressNode(quicklistNode *node) { /* Uncompress the listpack in 'node' and update encoding details. * Returns 1 on successful decode, 0 on failure to decode. */ REDIS_STATIC int __quicklistDecompressNode(quicklistNode *node) { -#ifdef REDIS_TEST +#ifdef SERVER_TEST node->attempted_compress = 0; #endif node->recompress = 0; @@ -1791,7 +1791,7 @@ void quicklistBookmarksClear(quicklist *ql) { } /* The rest of this file is test cases and test helpers. */ -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include #include "testhelp.h" diff --git a/src/quicklist.h b/src/quicklist.h index c4b07e0c00..4658ba8271 100644 --- a/src/quicklist.h +++ b/src/quicklist.h @@ -204,7 +204,7 @@ quicklistNode *quicklistBookmarkFind(quicklist *ql, const char *name); void quicklistBookmarksClear(quicklist *ql); int quicklistSetPackedThreshold(size_t sz); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int quicklistTest(int argc, char *argv[], int flags); #endif diff --git a/src/sds.c b/src/sds.c index 4ed792e5cd..84edef97d7 100644 --- a/src/sds.c +++ b/src/sds.c @@ -1229,7 +1229,7 @@ sds sdstemplate(const char *template, sdstemplate_callback_t cb_func, void *cb_a return NULL; } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include #include "testhelp.h" diff --git a/src/sds.h b/src/sds.h index 208eaa210d..e65d7a139f 100644 --- a/src/sds.h +++ b/src/sds.h @@ -280,7 +280,7 @@ void *sds_malloc(size_t size); void *sds_realloc(void *ptr, size_t size); void sds_free(void *ptr); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int sdsTest(int argc, char *argv[], int flags); #endif diff --git a/src/server.c b/src/server.c index 999d799cab..1605938d0e 100644 --- a/src/server.c +++ b/src/server.c @@ -6855,7 +6855,7 @@ int iAmMaster(void) { (server.cluster_enabled && clusterNodeIsMaster(getMyClusterNode()))); } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include "testhelp.h" #include "intset.h" /* Compact integer set structure */ @@ -6901,7 +6901,7 @@ int main(int argc, char **argv) { int j; char config_from_stdin = 0; -#ifdef REDIS_TEST +#ifdef SERVER_TEST monotonicInit(); /* Required for dict tests, that are relying on monotime during dict rehashing. */ if (argc >= 3 && !strcasecmp(argv[1], "test")) { int flags = 0; diff --git a/src/sha1.c b/src/sha1.c index 4d8c14094d..3a722933fc 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -208,7 +208,7 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context) } /* ================ end of sha1.c ================ */ -#ifdef REDIS_TEST +#ifdef SERVER_TEST #define BUFSIZE 4096 #define UNUSED(x) (void)(x) diff --git a/src/sha1.h b/src/sha1.h index a6cb6e8857..1765117967 100644 --- a/src/sha1.h +++ b/src/sha1.h @@ -21,7 +21,7 @@ void SHA1Init(SHA1_CTX* context); __attribute__((noinline)) void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); void SHA1Final(unsigned char digest[20], SHA1_CTX* context); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int sha1Test(int argc, char **argv, int flags); #endif #endif diff --git a/src/util.c b/src/util.c index ac17cd187b..3f9533369b 100644 --- a/src/util.c +++ b/src/util.c @@ -1375,7 +1375,7 @@ int snprintf_async_signal_safe(char *to, size_t n, const char *fmt, ...) { return result; } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include #include "testhelp.h" diff --git a/src/util.h b/src/util.h index 8a47f96acf..e924ba8cf6 100644 --- a/src/util.h +++ b/src/util.h @@ -100,7 +100,7 @@ int snprintf_async_signal_safe(char *to, size_t n, const char *fmt, ...); size_t redis_strlcpy(char *dst, const char *src, size_t dsize); size_t redis_strlcat(char *dst, const char *src, size_t dsize); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int utilTest(int argc, char **argv, int flags); #endif diff --git a/src/ziplist.c b/src/ziplist.c index c891625a93..490d5e3931 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -1686,7 +1686,7 @@ unsigned int ziplistRandomPairsUnique(unsigned char *zl, unsigned int count, zip return picked; } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include #include "adlist.h" #include "sds.h" diff --git a/src/ziplist.h b/src/ziplist.h index f210ba6c92..73cff214d3 100644 --- a/src/ziplist.h +++ b/src/ziplist.h @@ -67,7 +67,7 @@ void ziplistRandomPairs(unsigned char *zl, unsigned int count, ziplistEntry *key unsigned int ziplistRandomPairsUnique(unsigned char *zl, unsigned int count, ziplistEntry *keys, ziplistEntry *vals); int ziplistSafeToAdd(unsigned char* zl, size_t add); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int ziplistTest(int argc, char *argv[], int flags); #endif diff --git a/src/zipmap.c b/src/zipmap.c index 4e984ba6d9..214c49d2fc 100644 --- a/src/zipmap.c +++ b/src/zipmap.c @@ -441,7 +441,7 @@ int zipmapValidateIntegrity(unsigned char *zm, size_t size, int deep) { #undef OUT_OF_RANGE } -#ifdef REDIS_TEST +#ifdef SERVER_TEST static void zipmapRepr(unsigned char *p) { unsigned int l; diff --git a/src/zipmap.h b/src/zipmap.h index 482c96ddd8..d95c48ec55 100644 --- a/src/zipmap.h +++ b/src/zipmap.h @@ -47,7 +47,7 @@ size_t zipmapBlobLen(unsigned char *zm); void zipmapRepr(unsigned char *p); int zipmapValidateIntegrity(unsigned char *zm, size_t size, int deep); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int zipmapTest(int argc, char *argv[], int flags); #endif diff --git a/src/zmalloc.c b/src/zmalloc.c index 56330ff1cc..c1d10a5f0f 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -908,7 +908,7 @@ size_t zmalloc_get_memory_size(void) { #endif } -#ifdef REDIS_TEST +#ifdef SERVER_TEST #include "testhelp.h" #include "redisassert.h" diff --git a/src/zmalloc.h b/src/zmalloc.h index 461d0d1ac7..9baa36b3de 100644 --- a/src/zmalloc.h +++ b/src/zmalloc.h @@ -168,7 +168,7 @@ __attribute__((alloc_size(2),noinline)) void *extend_to_usable(void *ptr, size_t int get_proc_stat_ll(int i, long long *res); -#ifdef REDIS_TEST +#ifdef SERVER_TEST int zmalloc_test(int argc, char **argv, int flags); #endif From 83507d74b8588d2d8561a263466d34ee669d9812 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 2 Apr 2024 20:51:14 +0800 Subject: [PATCH 16/98] Update for latest 'typos' (#139) Signed-off-by: john vandenberg Co-authored-by: john vandenberg --- .config/typos.toml | 8 ++++++++ tests/unit/acl.tcl | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.config/typos.toml b/.config/typos.toml index e810af9a14..d378b5655a 100644 --- a/.config/typos.toml +++ b/.config/typos.toml @@ -8,8 +8,10 @@ extend-exclude = [ ] [default.extend-words] +advices = "advices" exat = "exat" optin = "optin" +ro = "ro" smove = "smove" [type.c] @@ -30,6 +32,7 @@ extend-ignore-re = [ module_gil_acquring = "module_gil_acquring" [type.c.extend-identifiers] +ang = "ang" clen = "clen" fle = "fle" module_gil_acquring = "module_gil_acquring" @@ -47,10 +50,14 @@ fo = "fo" seeked = "seeked" [type.c.extend-words] +arange = "arange" fo = "fo" +frst = "frst" limite = "limite" +pn = "pn" seeked = "seeked" tre = "tre" +ws = "ws" [type.systemd.extend-words] # systemd = .conf @@ -58,4 +65,5 @@ ake = "ake" [type.tcl.extend-words] fo = "fo" +lst = "lst" tre = "tre" diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index 1457b57b77..cdd12511e2 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -612,7 +612,7 @@ start_server {tags {"acl external:skip"}} { r ACL SETUSER adv-test -@all +select|0 +select|0 +debug|segfault +debug assert_equal "-@all +select|0 +debug" [dict get [r ACL getuser adv-test] commands] - # Unnecessary categories are retained for potentional future compatibility + # Unnecessary categories are retained for potential future compatibility r ACL SETUSER adv-test -@all -@dangerous assert_equal "-@all -@dangerous" [dict get [r ACL getuser adv-test] commands] From ba8bda9cffe80345cd4a74dfd98ab96b3bd52fb0 Mon Sep 17 00:00:00 2001 From: LiiNen Date: Tue, 2 Apr 2024 22:36:53 +0900 Subject: [PATCH 17/98] Fix shutdown syntax hint, following intention (#116) Change syntax hint from SHUTDOWN [NOSAVE | SAVE] [NOW] [FORCE] [ABORT] to SHUTDOWN [[NOSAVE | SAVE] [NOW] [FORCE] | ABORT] It's not that important for docs, but the latter is preferred for valkey-cli's automatic syntax hints. Signed-off-by: LiiNen --- src/commands.def | 24 ++++++++++---- src/commands/shutdown.json | 66 ++++++++++++++++++++++---------------- src/db.c | 1 + 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/commands.def b/src/commands.def index 0a86f44bab..2d68e36d77 100644 --- a/src/commands.def +++ b/src/commands.def @@ -7431,18 +7431,28 @@ commandHistory SHUTDOWN_History[] = { #define SHUTDOWN_Keyspecs NULL #endif -/* SHUTDOWN save_selector argument table */ -struct COMMAND_ARG SHUTDOWN_save_selector_Subargs[] = { +/* SHUTDOWN abort_selector save_selector_block save_selector argument table */ +struct COMMAND_ARG SHUTDOWN_abort_selector_save_selector_block_save_selector_Subargs[] = { {MAKE_ARG("nosave",ARG_TYPE_PURE_TOKEN,-1,"NOSAVE",NULL,NULL,CMD_ARG_NONE,0,NULL)}, {MAKE_ARG("save",ARG_TYPE_PURE_TOKEN,-1,"SAVE",NULL,NULL,CMD_ARG_NONE,0,NULL)}, }; -/* SHUTDOWN argument table */ -struct COMMAND_ARG SHUTDOWN_Args[] = { -{MAKE_ARG("save-selector",ARG_TYPE_ONEOF,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL,2,NULL),.subargs=SHUTDOWN_save_selector_Subargs}, +/* SHUTDOWN abort_selector save_selector_block argument table */ +struct COMMAND_ARG SHUTDOWN_abort_selector_save_selector_block_Subargs[] = { +{MAKE_ARG("save-selector",ARG_TYPE_ONEOF,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL,2,NULL),.subargs=SHUTDOWN_abort_selector_save_selector_block_save_selector_Subargs}, {MAKE_ARG("now",ARG_TYPE_PURE_TOKEN,-1,"NOW",NULL,"7.0.0",CMD_ARG_OPTIONAL,0,NULL)}, {MAKE_ARG("force",ARG_TYPE_PURE_TOKEN,-1,"FORCE",NULL,"7.0.0",CMD_ARG_OPTIONAL,0,NULL)}, -{MAKE_ARG("abort",ARG_TYPE_PURE_TOKEN,-1,"ABORT",NULL,"7.0.0",CMD_ARG_OPTIONAL,0,NULL)}, +}; + +/* SHUTDOWN abort_selector argument table */ +struct COMMAND_ARG SHUTDOWN_abort_selector_Subargs[] = { +{MAKE_ARG("save-selector-block",ARG_TYPE_BLOCK,-1,NULL,NULL,NULL,CMD_ARG_NONE,3,NULL),.subargs=SHUTDOWN_abort_selector_save_selector_block_Subargs}, +{MAKE_ARG("abort",ARG_TYPE_PURE_TOKEN,-1,"ABORT",NULL,"7.0.0",CMD_ARG_NONE,0,NULL)}, +}; + +/* SHUTDOWN argument table */ +struct COMMAND_ARG SHUTDOWN_Args[] = { +{MAKE_ARG("abort-selector",ARG_TYPE_ONEOF,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL,2,NULL),.subargs=SHUTDOWN_abort_selector_Subargs}, }; /********** SLAVEOF ********************/ @@ -10798,7 +10808,7 @@ struct COMMAND_STRUCT redisCommandTable[] = { {MAKE_CMD("restore-asking","An internal command for migrating keys in a cluster.","O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,RESTORE_ASKING_History,3,RESTORE_ASKING_Tips,0,restoreCommand,-4,CMD_WRITE|CMD_DENYOOM|CMD_ASKING,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,RESTORE_ASKING_Keyspecs,1,NULL,7),.args=RESTORE_ASKING_Args}, {MAKE_CMD("role","Returns the replication role.","O(1)","2.8.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ROLE_History,0,ROLE_Tips,0,roleCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_SENTINEL,ACL_CATEGORY_ADMIN|ACL_CATEGORY_DANGEROUS,ROLE_Keyspecs,0,NULL,0)}, {MAKE_CMD("save","Synchronously saves the database(s) to disk.","O(N) where N is the total number of keys in all databases","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SAVE_History,0,SAVE_Tips,0,saveCommand,1,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_NO_MULTI,0,SAVE_Keyspecs,0,NULL,0)}, -{MAKE_CMD("shutdown","Synchronously saves the database(s) to disk and shuts down the server.","O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SHUTDOWN_History,1,SHUTDOWN_Tips,0,shutdownCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_NO_MULTI|CMD_SENTINEL|CMD_ALLOW_BUSY,0,SHUTDOWN_Keyspecs,0,NULL,4),.args=SHUTDOWN_Args}, +{MAKE_CMD("shutdown","Synchronously saves the database(s) to disk and shuts down the server.","O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SHUTDOWN_History,1,SHUTDOWN_Tips,0,shutdownCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_NO_MULTI|CMD_SENTINEL|CMD_ALLOW_BUSY,0,SHUTDOWN_Keyspecs,0,NULL,1),.args=SHUTDOWN_Args}, {MAKE_CMD("slaveof","Sets a server as a replica of another, or promotes it to being a master.","O(1)","1.0.0",CMD_DOC_DEPRECATED,"`REPLICAOF`","5.0.0","server",COMMAND_GROUP_SERVER,SLAVEOF_History,0,SLAVEOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,SLAVEOF_Keyspecs,0,NULL,1),.args=SLAVEOF_Args}, {MAKE_CMD("slowlog","A container for slow log commands.","Depends on subcommand.","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_History,0,SLOWLOG_Tips,0,NULL,-2,0,0,SLOWLOG_Keyspecs,0,NULL,0),.subcommands=SLOWLOG_Subcommands}, {MAKE_CMD("swapdb","Swaps two databases.","O(N) where N is the count of clients watching or blocking on keys from both databases.","4.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SWAPDB_History,0,SWAPDB_Tips,0,swapdbCommand,3,CMD_WRITE|CMD_FAST,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,SWAPDB_Keyspecs,0,NULL,2),.args=SWAPDB_Args}, diff --git a/src/commands/shutdown.json b/src/commands/shutdown.json index f47f067535..8c88da34a0 100644 --- a/src/commands/shutdown.json +++ b/src/commands/shutdown.json @@ -23,42 +23,54 @@ ], "arguments": [ { - "name": "save-selector", + "name": "abort-selector", "type": "oneof", "optional": true, "arguments": [ { - "name": "nosave", - "type": "pure-token", - "token": "NOSAVE" + "name": "save-selector-block", + "type": "block", + "arguments": [ + { + "name": "save-selector", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "nosave", + "type": "pure-token", + "token": "NOSAVE" + }, + { + "name": "save", + "type": "pure-token", + "token": "SAVE" + } + ] + }, + { + "name": "now", + "type": "pure-token", + "token": "NOW", + "optional": true, + "since": "7.0.0" + }, + { + "name": "force", + "type": "pure-token", + "token": "FORCE", + "optional": true, + "since": "7.0.0" + } + ] }, { - "name": "save", + "name": "abort", "type": "pure-token", - "token": "SAVE" + "token": "ABORT", + "since": "7.0.0" } ] - }, - { - "name": "now", - "type": "pure-token", - "token": "NOW", - "optional": true, - "since": "7.0.0" - }, - { - "name": "force", - "type": "pure-token", - "token": "FORCE", - "optional": true, - "since": "7.0.0" - }, - { - "name": "abort", - "type": "pure-token", - "token": "ABORT", - "optional": true, - "since": "7.0.0" } ], "reply_schema": { diff --git a/src/db.c b/src/db.c index 82e61b496b..43b1ba5586 100644 --- a/src/db.c +++ b/src/db.c @@ -1234,6 +1234,7 @@ void typeCommand(client *c) { addReplyStatus(c, getObjectTypeName(o)); } +/* SHUTDOWN [[NOSAVE | SAVE] [NOW] [FORCE] | ABORT] */ void shutdownCommand(client *c) { int flags = SHUTDOWN_NOFLAGS; int abort = 0; From 98e7b41b8504f02aa2f30ef2a2690bf05cb53d54 Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Tue, 2 Apr 2024 21:42:50 +0800 Subject: [PATCH 18/98] Fix rename redis to valkey to pass reply-schemas-validator job (#133) Signed-off-by: Vitah Lin --- utils/req-res-log-validator.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/utils/req-res-log-validator.py b/utils/req-res-log-validator.py index 46c110019f..e2d471370c 100755 --- a/utils/req-res-log-validator.py +++ b/utils/req-res-log-validator.py @@ -26,7 +26,7 @@ 1. Goes over req-res files, generated by redis-servers, spawned by the testsuite (see logreqres.c) 2. For each request-response pair, it validates the response against the request's reply_schema (obtained from COMMAND DOCS) -This script spins up a redis-server and a redis-cli in order to obtain COMMAND DOCS. +This script spins up a valkey-server and a valkey-cli in order to obtain COMMAND DOCS. In order to use this file you must run the redis testsuite with the following flags: ./runtest --dont-clean --force-resp3 --log-req-res @@ -241,7 +241,7 @@ def fetch_schemas(cli, port, args, docs): while True: try: - print('Connecting to Redis...') + print('Connecting to Valkey...') r = redis.Redis(port=port) r.ping() break @@ -271,9 +271,9 @@ def fetch_schemas(cli, port, args, docs): testdir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../tests") parser = argparse.ArgumentParser() - parser.add_argument('--server', type=str, default='%s/redis-server' % srcdir) + parser.add_argument('--server', type=str, default='%s/valkey-server' % srcdir) parser.add_argument('--port', type=int, default=6534) - parser.add_argument('--cli', type=str, default='%s/redis-cli' % srcdir) + parser.add_argument('--cli', type=str, default='%s/valkey-cli' % srcdir) parser.add_argument('--module', type=str, action='append', default=[]) parser.add_argument('--verbose', action='store_true') parser.add_argument('--fail-commands-not-all-hit', action='store_true') @@ -282,8 +282,8 @@ def fetch_schemas(cli, port, args, docs): docs = dict() - # Fetch schemas from a Redis instance - print('Starting Redis server') + # Fetch schemas from a Valkey instance + print('Starting Valkey server') redis_args = [args.server, '--port', str(args.port)] for module in args.module: redis_args += ['--loadmodule', 'tests/modules/%s.so' % module] @@ -291,7 +291,7 @@ def fetch_schemas(cli, port, args, docs): fetch_schemas(args.cli, args.port, redis_args, docs) # Fetch schemas from a sentinel - print('Starting Redis sentinel') + print('Starting Valkey sentinel') # Sentinel needs a config file to start config_file = "tmpsentinel.conf" @@ -347,4 +347,3 @@ def fetch_schemas(cli, port, args, docs): if args.fail_commands_not_all_hit: print("ERROR! at least one command was not hit by the tests") sys.exit(1) - From a1516d53defdad5cf5f65a4080b44e6a9fbdd889 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:56:17 +0700 Subject: [PATCH 19/98] Rename files redisassert to serverassert (#138) Signed-off-by: 0del --- src/Makefile | 4 ++-- src/ae.c | 2 +- src/dict.c | 2 +- src/intset.c | 2 +- src/kvstore.c | 2 +- src/listpack.c | 2 +- src/memtest.c | 2 +- src/monotonic.c | 2 +- src/quicklist.c | 2 +- src/rax.c | 2 +- src/sds.c | 2 +- src/{redisassert.c => serverassert.c} | 0 src/{redisassert.h => serverassert.h} | 0 src/ziplist.c | 2 +- src/zmalloc.c | 4 ++-- 15 files changed, 15 insertions(+), 15 deletions(-) rename src/{redisassert.c => serverassert.c} (100%) rename src/{redisassert.h => serverassert.h} (100%) diff --git a/src/Makefile b/src/Makefile index e8d6fcca37..83255feee7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -362,9 +362,9 @@ SERVER_NAME=$(ENGINE_NAME)-server$(PROG_SUFFIX) ENGINE_SENTINEL_NAME=$(ENGINE_NAME)-sentinel$(PROG_SUFFIX) ENGINE_SERVER_OBJ=threads_mngr.o adlist.o quicklist.o ae.o anet.o dict.o kvstore.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o cluster_legacy.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o ENGINE_CLI_NAME=$(ENGINE_NAME)-cli$(PROG_SUFFIX) -ENGINE_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o redisassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o +ENGINE_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o serverassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o ENGINE_BENCHMARK_NAME=$(ENGINE_NAME)-benchmark$(PROG_SUFFIX) -ENGINE_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o +ENGINE_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o serverassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o ENGINE_CHECK_RDB_NAME=$(ENGINE_NAME)-check-rdb$(PROG_SUFFIX) ENGINE_CHECK_AOF_NAME=$(ENGINE_NAME)-check-aof$(PROG_SUFFIX) ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(ENGINE_SERVER_OBJ) $(ENGINE_CLI_OBJ) $(ENGINE_BENCHMARK_OBJ))) diff --git a/src/ae.c b/src/ae.c index 99c0b86004..839d23b51d 100644 --- a/src/ae.c +++ b/src/ae.c @@ -32,7 +32,7 @@ #include "ae.h" #include "anet.h" -#include "redisassert.h" +#include "serverassert.h" #include #include diff --git a/src/dict.c b/src/dict.c index 7e584f079a..d2767939bc 100644 --- a/src/dict.c +++ b/src/dict.c @@ -45,7 +45,7 @@ #include "dict.h" #include "zmalloc.h" -#include "redisassert.h" +#include "serverassert.h" #include "monotonic.h" /* Using dictSetResizeEnabled() we make possible to disable diff --git a/src/intset.c b/src/intset.c index 221278fc49..fea4173b43 100644 --- a/src/intset.c +++ b/src/intset.c @@ -34,7 +34,7 @@ #include "intset.h" #include "zmalloc.h" #include "endianconv.h" -#include "redisassert.h" +#include "serverassert.h" /* Note that these encodings are ordered, so: * INTSET_ENC_INT16 < INTSET_ENC_INT32 < INTSET_ENC_INT64. */ diff --git a/src/kvstore.c b/src/kvstore.c index 1195db67b8..acfe62bb85 100644 --- a/src/kvstore.c +++ b/src/kvstore.c @@ -43,7 +43,7 @@ #include "zmalloc.h" #include "kvstore.h" -#include "redisassert.h" +#include "serverassert.h" #include "monotonic.h" #define UNUSED(V) ((void) V) diff --git a/src/listpack.c b/src/listpack.c index 470a8f9920..27becc9faa 100644 --- a/src/listpack.c +++ b/src/listpack.c @@ -42,7 +42,7 @@ #include "listpack.h" #include "listpack_malloc.h" -#include "redisassert.h" +#include "serverassert.h" #include "util.h" #define LP_HDR_SIZE 6 /* 32 bit total len + 16 bit number of elements. */ diff --git a/src/memtest.c b/src/memtest.c index ee1ba92f1a..47e65a9048 100644 --- a/src/memtest.c +++ b/src/memtest.c @@ -38,7 +38,7 @@ #include #endif #include "config.h" -#include "redisassert.h" +#include "serverassert.h" #if (ULONG_MAX == 4294967295UL) #define MEMTEST_32BIT diff --git a/src/monotonic.c b/src/monotonic.c index 6da03677bd..e55b5eb0c0 100644 --- a/src/monotonic.c +++ b/src/monotonic.c @@ -3,7 +3,7 @@ #include #include #include -#include "redisassert.h" +#include "serverassert.h" /* The function pointer for clock retrieval. */ monotime (*getMonotonicUs)(void) = NULL; diff --git a/src/quicklist.c b/src/quicklist.c index b9f6911700..06c699af66 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -37,7 +37,7 @@ #include "listpack.h" #include "util.h" /* for ll2string */ #include "lzf.h" -#include "redisassert.h" +#include "serverassert.h" #ifndef REDIS_STATIC #define REDIS_STATIC static diff --git a/src/rax.c b/src/rax.c index 100744d790..27a5756538 100644 --- a/src/rax.c +++ b/src/rax.c @@ -36,7 +36,7 @@ #include #include #include "rax.h" -#include "redisassert.h" +#include "serverassert.h" #ifndef RAX_MALLOC_INCLUDE #define RAX_MALLOC_INCLUDE "rax_malloc.h" diff --git a/src/sds.c b/src/sds.c index 84edef97d7..b8457ae0f7 100644 --- a/src/sds.c +++ b/src/sds.c @@ -35,7 +35,7 @@ #include #include #include -#include "redisassert.h" +#include "serverassert.h" #include "sds.h" #include "sdsalloc.h" #include "util.h" diff --git a/src/redisassert.c b/src/serverassert.c similarity index 100% rename from src/redisassert.c rename to src/serverassert.c diff --git a/src/redisassert.h b/src/serverassert.h similarity index 100% rename from src/redisassert.h rename to src/serverassert.h diff --git a/src/ziplist.c b/src/ziplist.c index 490d5e3931..1a16945852 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -190,7 +190,7 @@ #include "ziplist.h" #include "config.h" #include "endianconv.h" -#include "redisassert.h" +#include "serverassert.h" #define ZIP_END 255 /* Special "end of ziplist" entry. */ #define ZIP_BIG_PREVLEN 254 /* ZIP_BIG_PREVLEN - 1 is the max number of bytes of diff --git a/src/zmalloc.c b/src/zmalloc.c index c1d10a5f0f..27b64dc0d7 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -628,7 +628,7 @@ size_t zmalloc_get_rss(void) { #if defined(USE_JEMALLOC) -#include "redisassert.h" +#include "serverassert.h" #define STRINGIFY_(x) #x #define STRINGIFY(x) STRINGIFY_(x) @@ -910,7 +910,7 @@ size_t zmalloc_get_memory_size(void) { #ifdef SERVER_TEST #include "testhelp.h" -#include "redisassert.h" +#include "serverassert.h" #define TEST(name) printf("test — %s\n", name); From 621edbafba74c2d6211bf81d54be8b1da8543d4e Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Tue, 2 Apr 2024 22:44:00 +0700 Subject: [PATCH 20/98] Rename redisassert to serverassert in comment (#142) Signed-off-by: 0del --- src/serverassert.c | 4 ++-- src/serverassert.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serverassert.c b/src/serverassert.c index 9f7402e748..7d6ab8ed68 100644 --- a/src/serverassert.c +++ b/src/serverassert.c @@ -1,8 +1,8 @@ -/* redisassert.c -- Implement the default _serverAssert and _serverPanic which +/* serverassert.c -- Implement the default _serverAssert and _serverPanic which * simply print stack trace to standard error stream. * * This file is shared by those modules that try to print some logs about stack trace - * but don't have their own implementations of functions in redisassert.h. + * but don't have their own implementations of functions in serverassert.h. * * ---------------------------------------------------------------------------- * diff --git a/src/serverassert.h b/src/serverassert.h index a3f95da091..1cbc9fb6cf 100644 --- a/src/serverassert.h +++ b/src/serverassert.h @@ -1,4 +1,4 @@ -/* redisassert.h -- Drop in replacements assert.h that prints the stack trace +/* serverassert.h -- Drop in replacements assert.h that prints the stack trace * in the Redis logs. * * This file should be included instead of "assert.h" inside libraries used by From 42e00635af0717b79a6d214889fe2cdd883928d4 Mon Sep 17 00:00:00 2001 From: pragnesh Date: Tue, 2 Apr 2024 22:45:23 +0530 Subject: [PATCH 21/98] Fix inconsistencies in the json command file descriptions (#63) Grammar. Use full sentences. Signed-off-by: Pragnesh --- src/commands/acl-cat.json | 2 +- src/commands/acl-deluser.json | 2 +- src/commands/acl-getuser.json | 8 +- src/commands/acl-help.json | 2 +- src/commands/acl-list.json | 2 +- src/commands/acl-users.json | 2 +- src/commands/bitop.json | 2 +- src/commands/bitpos.json | 4 +- src/commands/client-info.json | 2 +- src/commands/client-kill.json | 4 +- src/commands/client-tracking.json | 2 +- src/commands/client-unblock.json | 4 +- src/commands/cluster-bumpepoch.json | 4 +- .../cluster-count-failure-reports.json | 2 +- src/commands/cluster-countkeysinslot.json | 2 +- src/commands/cluster-getkeysinslot.json | 4 +- src/commands/cluster-links.json | 16 ++-- src/commands/cluster-myid.json | 2 +- src/commands/cluster-myshardid.json | 2 +- src/commands/cluster-nodes.json | 2 +- src/commands/cluster-replicas.json | 4 +- src/commands/cluster-shards.json | 6 +- src/commands/cluster-slaves.json | 4 +- src/commands/cluster-slots.json | 34 ++++---- src/commands/command-docs.json | 26 +++--- src/commands/command-info.json | 42 +++++----- src/commands/command-list.json | 2 +- src/commands/copy.json | 4 +- src/commands/del.json | 2 +- src/commands/function-dump.json | 2 +- src/commands/function-list.json | 14 ++-- src/commands/function-stats.json | 18 ++-- src/commands/geodist.json | 4 +- src/commands/georadius.json | 20 ++--- src/commands/georadius_ro.json | 18 ++-- src/commands/georadiusbymember.json | 20 ++--- src/commands/georadiusbymember_ro.json | 18 ++-- src/commands/geosearch.json | 18 ++-- src/commands/geosearchstore.json | 2 +- src/commands/hscan.json | 6 +- src/commands/keys.json | 2 +- src/commands/latency-history.json | 4 +- src/commands/linsert.json | 4 +- src/commands/lpushx.json | 2 +- src/commands/memory-doctor.json | 2 +- src/commands/memory-stats.json | 2 +- src/commands/move.json | 4 +- src/commands/object-encoding.json | 4 +- src/commands/object-freq.json | 2 +- src/commands/object-idletime.json | 2 +- src/commands/object-refcount.json | 2 +- src/commands/pfadd.json | 4 +- src/commands/publish.json | 2 +- src/commands/pubsub-channels.json | 2 +- src/commands/pubsub-numpat.json | 2 +- src/commands/pubsub-numsub.json | 2 +- src/commands/pubsub-shardchannels.json | 2 +- src/commands/pubsub-shardnumsub.json | 2 +- src/commands/randomkey.json | 4 +- src/commands/renamenx.json | 4 +- src/commands/replicaof.json | 2 +- src/commands/role.json | 34 ++++---- src/commands/scan.json | 6 +- src/commands/script-exists.json | 4 +- src/commands/slaveof.json | 2 +- src/commands/sort.json | 6 +- src/commands/sort_ro.json | 4 +- src/commands/spublish.json | 2 +- src/commands/sscan.json | 6 +- src/commands/touch.json | 2 +- src/commands/unlink.json | 2 +- src/commands/xclaim.json | 10 +-- src/commands/xinfo-stream.json | 84 +++++++++---------- src/commands/xread.json | 10 +-- src/commands/zrangebyscore.json | 12 +-- src/commands/zrevrange.json | 4 +- src/commands/zrevrangebyscore.json | 12 +-- src/commands/zscan.json | 6 +- 78 files changed, 298 insertions(+), 298 deletions(-) diff --git a/src/commands/acl-cat.json b/src/commands/acl-cat.json index dfbe4c43ef..cf86106773 100644 --- a/src/commands/acl-cat.json +++ b/src/commands/acl-cat.json @@ -24,7 +24,7 @@ }, { "type": "array", - "description": "In case `category` was given, list of commands that fall under the provided ACL category", + "description": "In case `category` was given, list of commands that fall under the provided ACL category.", "items": { "type": "string" } diff --git a/src/commands/acl-deluser.json b/src/commands/acl-deluser.json index 80e8a7ad51..d300f88cec 100644 --- a/src/commands/acl-deluser.json +++ b/src/commands/acl-deluser.json @@ -20,7 +20,7 @@ ], "reply_schema": { "type": "integer", - "description": "The number of users that were deleted" + "description": "The number of users that were deleted." }, "arguments": [ { diff --git a/src/commands/acl-getuser.json b/src/commands/acl-getuser.json index 535389bc53..cedd35f5cc 100644 --- a/src/commands/acl-getuser.json +++ b/src/commands/acl-getuser.json @@ -33,7 +33,7 @@ "reply_schema": { "oneOf": [ { - "description": "a set of ACL rule definitions for the user", + "description": "A set of ACL rule definitions for the user.", "type": "object", "additionalProperties": false, "properties": { @@ -50,15 +50,15 @@ } }, "commands": { - "description": "root selector's commands", + "description": "Root selector's commands.", "type": "string" }, "keys": { - "description": "root selector's keys", + "description": "Root selector's keys.", "type": "string" }, "channels": { - "description": "root selector's channels", + "description": "Root selector's channels.", "type": "string" }, "selectors": { diff --git a/src/commands/acl-help.json b/src/commands/acl-help.json index 3c95914dbd..e31024327f 100644 --- a/src/commands/acl-help.json +++ b/src/commands/acl-help.json @@ -14,7 +14,7 @@ ], "reply_schema": { "type": "array", - "description": "A list of subcommands and their description", + "description": "A list of subcommands and their description.", "items": { "type": "string" } diff --git a/src/commands/acl-list.json b/src/commands/acl-list.json index 0d75b137f3..415cdf59b7 100644 --- a/src/commands/acl-list.json +++ b/src/commands/acl-list.json @@ -16,7 +16,7 @@ ], "reply_schema": { "type": "array", - "description": "A list of currently active ACL rules", + "description": "A list of currently active ACL rules.", "items": { "type": "string" } diff --git a/src/commands/acl-users.json b/src/commands/acl-users.json index 1a6bc75579..98ab53d0d3 100644 --- a/src/commands/acl-users.json +++ b/src/commands/acl-users.json @@ -16,7 +16,7 @@ ], "reply_schema": { "type": "array", - "description": "List of existing ACL users", + "description": "List of existing ACL users.", "items": { "type": "string" } diff --git a/src/commands/bitop.json b/src/commands/bitop.json index d9e1ff9ef7..8d60cffa59 100644 --- a/src/commands/bitop.json +++ b/src/commands/bitop.json @@ -91,7 +91,7 @@ } ], "reply_schema": { - "description": "the size of the string stored in the destination key, that is equal to the size of the longest input string", + "description": "The size of the string stored in the destination key, that is equal to the size of the longest input string.", "type": "integer", "minimum": 0 } diff --git a/src/commands/bitpos.json b/src/commands/bitpos.json index 11b0851e85..b0834dd5dc 100644 --- a/src/commands/bitpos.json +++ b/src/commands/bitpos.json @@ -92,12 +92,12 @@ "reply_schema": { "oneOf": [ { - "description": "the position of the first bit set to 1 or 0 according to the request", + "description": "The position of the first bit set to 1 or 0 according to the request.", "type": "integer", "minimum": 0 }, { - "description": "In case the `bit` argument is 1 and the string is empty or composed of just zero bytes", + "description": "In case the `bit` argument is 1 and the string is empty or composed of just zero bytes.", "const": -1 } ] diff --git a/src/commands/client-info.json b/src/commands/client-info.json index 93fa008f52..f974da437b 100644 --- a/src/commands/client-info.json +++ b/src/commands/client-info.json @@ -20,7 +20,7 @@ "NONDETERMINISTIC_OUTPUT" ], "reply_schema": { - "description": "a unique string, as described at the CLIENT LIST page, for the current client", + "description": "A unique string, as described at the CLIENT LIST page, for the current client.", "type": "string" } } diff --git a/src/commands/client-kill.json b/src/commands/client-kill.json index 7efd805081..01079ad993 100644 --- a/src/commands/client-kill.json +++ b/src/commands/client-kill.json @@ -156,11 +156,11 @@ "reply_schema": { "oneOf": [ { - "description": "when called in 3 argument format", + "description": "When called in 3 argument format.", "const": "OK" }, { - "description": "when called in filter/value format, the number of clients killed", + "description": "When called in filter/value format, the number of clients killed.", "type": "integer", "minimum": 0 } diff --git a/src/commands/client-tracking.json b/src/commands/client-tracking.json index 28e84eceb1..2c3768c2fb 100644 --- a/src/commands/client-tracking.json +++ b/src/commands/client-tracking.json @@ -73,7 +73,7 @@ } ], "reply_schema": { - "description": "if the client was successfully put into or taken out of tracking mode", + "description": "If the client was successfully put into or taken out of tracking mode.", "const": "OK" } } diff --git a/src/commands/client-unblock.json b/src/commands/client-unblock.json index d028f47149..d391ede9e9 100644 --- a/src/commands/client-unblock.json +++ b/src/commands/client-unblock.json @@ -21,11 +21,11 @@ "oneOf": [ { "const": 0, - "description": "if the client was unblocked successfully" + "description": "If the client was unblocked successfully." }, { "const": 1, - "description": "if the client wasn't unblocked" + "description": "If the client wasn't unblocked." } ] }, diff --git a/src/commands/cluster-bumpepoch.json b/src/commands/cluster-bumpepoch.json index 786723c5c2..03a8370334 100644 --- a/src/commands/cluster-bumpepoch.json +++ b/src/commands/cluster-bumpepoch.json @@ -18,12 +18,12 @@ "reply_schema": { "oneOf": [ { - "description": "if the epoch was incremented", + "description": "If the epoch was incremented.", "type": "string", "pattern": "^BUMPED [0-9]*$" }, { - "description": "if the node already has the greatest config epoch in the cluster", + "description": "If the node already has the greatest config epoch in the cluster.", "type": "string", "pattern": "^STILL [0-9]*$" } diff --git a/src/commands/cluster-count-failure-reports.json b/src/commands/cluster-count-failure-reports.json index b80632d0fa..ad185dafc6 100644 --- a/src/commands/cluster-count-failure-reports.json +++ b/src/commands/cluster-count-failure-reports.json @@ -21,7 +21,7 @@ } ], "reply_schema": { - "description": "the number of active failure reports for the node", + "description": "The number of active failure reports for the node.", "type": "integer", "minimum": 0 } diff --git a/src/commands/cluster-countkeysinslot.json b/src/commands/cluster-countkeysinslot.json index caeec51320..e270990b15 100644 --- a/src/commands/cluster-countkeysinslot.json +++ b/src/commands/cluster-countkeysinslot.json @@ -17,7 +17,7 @@ } ], "reply_schema": { - "description": "The number of keys in the specified hash slot", + "description": "The number of keys in the specified hash slot.", "type": "integer", "minimum": 0 } diff --git a/src/commands/cluster-getkeysinslot.json b/src/commands/cluster-getkeysinslot.json index 039dfeabf6..6444a761fd 100644 --- a/src/commands/cluster-getkeysinslot.json +++ b/src/commands/cluster-getkeysinslot.json @@ -24,10 +24,10 @@ } ], "reply_schema": { - "description": "an array with up to count elements", + "description": "An array with up to count elements.", "type": "array", "items": { - "description": "key name", + "description": "Key name.", "type": "string" } } diff --git a/src/commands/cluster-links.json b/src/commands/cluster-links.json index 07b2e833b3..6f81e1a9e6 100644 --- a/src/commands/cluster-links.json +++ b/src/commands/cluster-links.json @@ -14,7 +14,7 @@ "NONDETERMINISTIC_OUTPUT" ], "reply_schema": { - "description": "an array of cluster links and their attributes", + "description": "An array of cluster links and their attributes.", "type": "array", "items": { "type": "object", @@ -23,33 +23,33 @@ "description": "This link is established by the local node _to_ the peer, or accepted by the local node _from_ the peer.", "oneOf": [ { - "description": "connection initiated from peer", + "description": "Connection initiated from peer.", "const": "from" }, { - "description": "connection initiated to peer", + "description": "Connection initiated to peer.", "const": "to" } ] }, "node": { - "description": "the node id of the peer", + "description": "The node id of the peer.", "type": "string" }, "create-time": { - "description": "unix time creation time of the link. (In the case of a _to_ link, this is the time when the TCP link is created by the local node, not the time when it is actually established.)", + "description": "Unix time creation time of the link. (In the case of a _to_ link, this is the time when the TCP link is created by the local node, not the time when it is actually established.)", "type": "integer" }, "events": { - "description": "events currently registered for the link. r means readable event, w means writable event", + "description": "Events currently registered for the link. r means readable event, w means writable event.", "type": "string" }, "send-buffer-allocated": { - "description": "allocated size of the link's send buffer, which is used to buffer outgoing messages toward the peer", + "description": "Allocated size of the link's send buffer, which is used to buffer outgoing messages toward the peer.", "type": "integer" }, "send-buffer-used": { - "description": "size of the portion of the link's send buffer that is currently holding data(messages)", + "description": "Size of the portion of the link's send buffer that is currently holding data(messages).", "type": "integer" } }, diff --git a/src/commands/cluster-myid.json b/src/commands/cluster-myid.json index 340d425fd3..caa62de756 100644 --- a/src/commands/cluster-myid.json +++ b/src/commands/cluster-myid.json @@ -11,7 +11,7 @@ "STALE" ], "reply_schema": { - "description": "the node id", + "description": "The node id.", "type": "string" } } diff --git a/src/commands/cluster-myshardid.json b/src/commands/cluster-myshardid.json index 7db63fd190..88a7107309 100644 --- a/src/commands/cluster-myshardid.json +++ b/src/commands/cluster-myshardid.json @@ -15,7 +15,7 @@ "NONDETERMINISTIC_OUTPUT" ], "reply_schema": { - "description": "the node's shard id", + "description": "The node's shard id.", "type": "string" } } diff --git a/src/commands/cluster-nodes.json b/src/commands/cluster-nodes.json index ce34944e19..9c5fcbe9a4 100644 --- a/src/commands/cluster-nodes.json +++ b/src/commands/cluster-nodes.json @@ -14,7 +14,7 @@ "NONDETERMINISTIC_OUTPUT" ], "reply_schema": { - "description": "the serialized cluster configuration", + "description": "The serialized cluster configuration.", "type": "string" } } diff --git a/src/commands/cluster-replicas.json b/src/commands/cluster-replicas.json index e01617feeb..4e8bd4204c 100644 --- a/src/commands/cluster-replicas.json +++ b/src/commands/cluster-replicas.json @@ -21,11 +21,11 @@ } ], "reply_schema": { - "description": "a list of replica nodes replicating from the specified master node provided in the same format used by CLUSTER NODES", + "description": "A list of replica nodes replicating from the specified master node provided in the same format used by CLUSTER NODES.", "type": "array", "items": { "type": "string", - "description": "the serialized cluster configuration" + "description": "The serialized cluster configuration." } } } diff --git a/src/commands/cluster-shards.json b/src/commands/cluster-shards.json index e7a0829534..472e957ea5 100644 --- a/src/commands/cluster-shards.json +++ b/src/commands/cluster-shards.json @@ -16,21 +16,21 @@ "NONDETERMINISTIC_OUTPUT" ], "reply_schema": { - "description": "a nested list of a map of hash ranges and shard nodes describing individual shards", + "description": "A nested list of a map of hash ranges and shard nodes describing individual shards.", "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "slots": { - "description": "an even number element array specifying the start and end slot numbers for slot ranges owned by this shard", + "description": "An even number element array specifying the start and end slot numbers for slot ranges owned by this shard.", "type": "array", "items": { "type": "integer" } }, "nodes": { - "description": "nodes that handle these slot ranges", + "description": "Nodes that handle these slot ranges.", "type": "array", "items": { "type": "object", diff --git a/src/commands/cluster-slaves.json b/src/commands/cluster-slaves.json index a736088e4c..db66a1c1db 100644 --- a/src/commands/cluster-slaves.json +++ b/src/commands/cluster-slaves.json @@ -26,11 +26,11 @@ } ], "reply_schema": { - "description": "a list of replica nodes replicating from the specified master node provided in the same format used by CLUSTER NODES", + "description": "A list of replica nodes replicating from the specified master node provided in the same format used by CLUSTER NODES.", "type": "array", "items": { "type": "string", - "description": "the serialized cluster configuration" + "description": "The serialized cluster configuration." } } } diff --git a/src/commands/cluster-slots.json b/src/commands/cluster-slots.json index b00cc60f47..13f8c26612 100644 --- a/src/commands/cluster-slots.json +++ b/src/commands/cluster-slots.json @@ -30,7 +30,7 @@ "NONDETERMINISTIC_OUTPUT" ], "reply_schema": { - "description": "nested list of slot ranges with networking information", + "description": "Nested list of slot ranges with networking information.", "type": "array", "items": { "type": "array", @@ -38,42 +38,42 @@ "maxItems": 4294967295, "items": [ { - "description": "start slot number", + "description": "Start slot number.", "type": "integer" }, { - "description": "end slot number", + "description": "End slot number.", "type": "integer" }, { "type": "array", - "description": "Master node for the slot range", + "description": "Master node for the slot range.", "minItems": 4, "maxItems": 4, "items": [ { - "description": "endpoint description", + "description": "Endpoint description.", "oneOf": [ { - "description": "hostname or ip", + "description": "Hostname or ip.", "type": "string" }, { - "description": "unknown type", + "description": "Unknown type.", "type": "null" } ] }, { - "description": "port", + "description": "Port.", "type": "integer" }, { - "description": "node name", + "description": "Node name.", "type": "string" }, { - "description": "array of node descriptions", + "description": "Array of node descriptions.", "type": "object", "additionalProperties": false, "properties": { @@ -90,33 +90,33 @@ ], "additionalItems": { "type": "array", - "description": "Replica node for the slot range", + "description": "Replica node for the slot range.", "minItems": 4, "maxItems": 4, "items": [ { - "description": "endpoint description", + "description": "Endpoint description.", "oneOf": [ { - "description": "hostname or ip", + "description": "Hostname or ip.", "type": "string" }, { - "description": "unknown type", + "description": "Unknown type.", "type": "null" } ] }, { - "description": "port", + "description": "Port.", "type": "integer" }, { - "description": "node name", + "description": "Node name.", "type": "string" }, { - "description": "array of node descriptions", + "description": "Array of node descriptions.", "type": "object", "additionalProperties": false, "properties": { diff --git a/src/commands/command-docs.json b/src/commands/command-docs.json index ea575b0437..60a7ee423f 100644 --- a/src/commands/command-docs.json +++ b/src/commands/command-docs.json @@ -28,15 +28,15 @@ "additionalProperties": false, "properties": { "summary": { - "description": "short command description", + "description": "Short command description.", "type": "string" }, "since": { - "description": "the server version that added the command (or for module commands, the module version).", + "description": "The server version that added the command (or for module commands, the module version).", "type": "string" }, "group": { - "description": "the functional group to which the command belongs", + "description": "The functional group to which the command belongs.", "oneOf": [ { "const": "bitmap" @@ -95,38 +95,38 @@ ] }, "complexity": { - "description": "a short explanation about the command's time complexity.", + "description": "A short explanation about the command's time complexity.", "type": "string" }, "module": { "type": "string" }, "doc_flags": { - "description": "an array of documentation flags", + "description": "An array of documentation flags.", "type": "array", "items": { "oneOf": [ { - "description": "the command is deprecated.", + "description": "The command is deprecated.", "const": "deprecated" }, { - "description": "a system command that isn't meant to be called by users.", + "description": "A system command that isn't meant to be called by users.", "const": "syscmd" } ] } }, "deprecated_since": { - "description": "the server version that deprecated the command (or for module commands, the module version)", + "description": "The server version that deprecated the command (or for module commands, the module version).", "type": "string" }, "replaced_by": { - "description": "the alternative for a deprecated command.", + "description": "The alternative for a deprecated command.", "type": "string" }, "history": { - "description": "an array of historical notes describing changes to the command's behavior or arguments.", + "description": "An array of historical notes describing changes to the command's behavior or arguments.", "type": "array", "items": { "type": "array", @@ -145,7 +145,7 @@ } }, "arguments": { - "description": "an array of maps that describe the command's arguments.", + "description": "An array of maps that describe the command's arguments.", "type": "array", "items": { "type": "object", @@ -188,11 +188,11 @@ } }, "reply_schema": { - "description": "command reply schema", + "description": "Command reply schema.", "type": "object" }, "subcommands": { - "description": "A map where each key is a subcommand, and each value is the documentary information", + "description": "A map where each key is a subcommand, and each value is the documentary information.", "$ref": "#" } } diff --git a/src/commands/command-info.json b/src/commands/command-info.json index 8c69060959..d37d140e1e 100644 --- a/src/commands/command-info.json +++ b/src/commands/command-info.json @@ -37,61 +37,61 @@ "items": { "oneOf": [ { - "description": "command does not exist", + "description": "Command does not exist.", "type": "null" }, { - "description": "command info array output", + "description": "Command info array output.", "type": "array", "minItems": 10, "maxItems": 10, "items": [ { - "description": "command name", + "description": "Command name.", "type": "string" }, { - "description": "command arity", + "description": "Command arity.", "type": "integer" }, { - "description": "command flags", + "description": "Command flags.", "type": "array", "items": { - "description": "command flag", + "description": "Command flag.", "type": "string" } }, { - "description": "command first key index", + "description": "Command first key index.", "type": "integer" }, { - "description": "command last key index", + "description": "Command last key index.", "type": "integer" }, { - "description": "command key step index", + "description": "Command key step index.", "type": "integer" }, { - "description": "command categories", + "description": "Command categories.", "type": "array", "items": { - "description": "command category", + "description": "Command category.", "type": "string" } }, { - "description": "command tips", + "description": "Command tips.", "type": "array", "items": { - "description": "command tip", + "description": "Command tip.", "type": "string" } }, { - "description": "command key specs", + "description": "Command key specs.", "type": "array", "items": { "type": "object", @@ -116,12 +116,12 @@ "spec": { "anyOf": [ { - "description": "unknown type, empty map", + "description": "Unknown type, empty map.", "type": "object", "additionalProperties": false }, { - "description": "index type", + "description": "Index type.", "type": "object", "additionalProperties": false, "properties": { @@ -131,7 +131,7 @@ } }, { - "description": "keyword type", + "description": "Keyword type.", "type": "object", "additionalProperties": false, "properties": { @@ -157,12 +157,12 @@ "spec": { "anyOf": [ { - "description": "unknown type", + "description": "Unknown type.", "type": "object", "additionalProperties": false }, { - "description": "range type", + "description": "Range type.", "type": "object", "additionalProperties": false, "properties": { @@ -178,7 +178,7 @@ } }, { - "description": "keynum type", + "description": "Keynum type.", "type": "object", "additionalProperties": false, "properties": { @@ -202,7 +202,7 @@ }, { "type": "array", - "description": "subcommands" + "description": "Subcommands." } ] } diff --git a/src/commands/command-list.json b/src/commands/command-list.json index 7f4e3f5da0..e050968517 100644 --- a/src/commands/command-list.json +++ b/src/commands/command-list.json @@ -46,7 +46,7 @@ "reply_schema": { "type": "array", "items": { - "description": "command name", + "description": "Command name.", "type": "string" }, "uniqueItems": true diff --git a/src/commands/copy.json b/src/commands/copy.json index b30ddaeae7..7774782f45 100644 --- a/src/commands/copy.json +++ b/src/commands/copy.json @@ -78,11 +78,11 @@ "reply_schema": { "oneOf": [ { - "description": "source was copied", + "description": "Source was copied.", "const": 1 }, { - "description": "source was not copied", + "description": "Source was not copied.", "const": 0 } ] diff --git a/src/commands/del.json b/src/commands/del.json index 2727b536c2..c8c7524f5f 100644 --- a/src/commands/del.json +++ b/src/commands/del.json @@ -37,7 +37,7 @@ } ], "reply_schema": { - "description": "the number of keys that were removed", + "description": "The number of keys that were removed.", "type": "integer", "minimum": 0 }, diff --git a/src/commands/function-dump.json b/src/commands/function-dump.json index d117241de3..da95fcd2fb 100644 --- a/src/commands/function-dump.json +++ b/src/commands/function-dump.json @@ -14,7 +14,7 @@ "SCRIPTING" ], "reply_schema": { - "description": "the serialized payload", + "description": "The serialized payload.", "type": "string" } } diff --git a/src/commands/function-list.json b/src/commands/function-list.json index 2ab1cf510c..d34176bca6 100644 --- a/src/commands/function-list.json +++ b/src/commands/function-list.json @@ -23,26 +23,26 @@ "additionalProperties": false, "properties": { "library_name": { - "description": " the name of the library", + "description": "The name of the library.", "type": "string" }, "engine": { - "description": "the engine of the library", + "description": "The engine of the library.", "type": "string" }, "functions": { - "description": "the list of functions in the library", + "description": "The list of functions in the library.", "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "name": { - "description": "the name of the function", + "description": "The name of the function.", "type": "string" }, "description": { - "description": "the function's description", + "description": "The function's description.", "oneOf": [ { "type": "null" @@ -53,7 +53,7 @@ ] }, "flags": { - "description": "an array of function flags", + "description": "An array of function flags.", "type": "array", "items": { "type": "string" @@ -63,7 +63,7 @@ } }, "library_code": { - "description": "the library's source code (when given the WITHCODE modifier)", + "description": "The library's source code (when given the WITHCODE modifier).", "type": "string" } } diff --git a/src/commands/function-stats.json b/src/commands/function-stats.json index 65519db1c3..42a3c032eb 100644 --- a/src/commands/function-stats.json +++ b/src/commands/function-stats.json @@ -24,30 +24,30 @@ "additionalProperties": false, "properties": { "running_script": { - "description": "information about the running script.", + "description": "Information about the running script.", "oneOf": [ { - "description": "If there's no in-flight function", + "description": "If there's no in-flight function.", "type": "null" }, { - "description": "a map with the information about the running script", + "description": "A map with the information about the running script.", "type": "object", "additionalProperties": false, "properties": { "name": { - "description": "the name of the function.", + "description": "The name of the function.", "type": "string" }, "command": { - "description": "the command and arguments used for invoking the function.", + "description": "The command and arguments used for invoking the function.", "type": "array", "items": { "type": "string" } }, "duration_ms": { - "description": "the function's runtime duration in milliseconds.", + "description": "The function's runtime duration in milliseconds.", "type": "integer" } } @@ -59,16 +59,16 @@ "type": "object", "patternProperties": { "^.*$": { - "description": "Engine map contains statistics about the engine", + "description": "Engine map contains statistics about the engine.", "type": "object", "additionalProperties": false, "properties": { "libraries_count": { - "description": "number of libraries", + "description": "Number of libraries.", "type": "integer" }, "functions_count": { - "description": "number of functions", + "description": "Number of functions.", "type": "integer" } } diff --git a/src/commands/geodist.json b/src/commands/geodist.json index 145ca718a8..b49705d0cd 100644 --- a/src/commands/geodist.json +++ b/src/commands/geodist.json @@ -77,11 +77,11 @@ "reply_schema": { "oneOf": [ { - "description": "one or both of elements are missing", + "description": "One or both of elements are missing.", "type": "null" }, { - "description": "distance as a double (represented as a string) in the specified units", + "description": "Distance as a double (represented as a string) in the specified units.", "type": "string", "pattern": "^[0-9]*(.[0-9]*)?$" } diff --git a/src/commands/georadius.json b/src/commands/georadius.json index 6ced9049ce..2e01b2b3d8 100644 --- a/src/commands/georadius.json +++ b/src/commands/georadius.json @@ -208,13 +208,13 @@ } ], "reply_schema": { - "description": "Array of matched members information", + "description": "Array of matched members information.", "anyOf": [ { - "description": "If no WITH* option is specified, array of matched members names", + "description": "If no WITH* option is specified, array of matched members names.", "type": "array", "items": { - "description": "name", + "description": "Name.", "type": "string" } }, @@ -226,32 +226,32 @@ "maxItems": 4, "items": [ { - "description": "Matched member name", + "description": "Matched member name.", "type": "string" } ], "additionalItems": { "oneOf": [ { - "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius", + "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius.", "type": "string" }, { - "description": "If WITHHASH option is specified, the geohash integer", + "description": "If WITHHASH option is specified, the geohash integer.", "type": "integer" }, { - "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude)", + "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude).", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "latitude (x)", + "description": "Latitude (x).", "type": "number" }, { - "description": "longitude (y)", + "description": "Longitude (y).", "type": "number" } ] @@ -261,7 +261,7 @@ } }, { - "description": "number of items stored in key", + "description": "Number of items stored in key.", "type": "integer" } ] diff --git a/src/commands/georadius_ro.json b/src/commands/georadius_ro.json index b3d335d4a1..ac6dcba510 100644 --- a/src/commands/georadius_ro.json +++ b/src/commands/georadius_ro.json @@ -147,13 +147,13 @@ } ], "reply_schema": { - "description": "Array of matched members information", + "description": "Array of matched members information.", "anyOf": [ { - "description": "If no WITH* option is specified, array of matched members names", + "description": "If no WITH* option is specified, array of matched members names.", "type": "array", "items": { - "description": "name", + "description": "Name.", "type": "string" } }, @@ -165,32 +165,32 @@ "maxItems": 4, "items": [ { - "description": "Matched member name", + "description": "Matched member name.", "type": "string" } ], "additionalItems": { "oneOf": [ { - "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius", + "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius.", "type": "string" }, { - "description": "If WITHHASH option is specified, the geohash integer", + "description": "If WITHHASH option is specified, the geohash integer.", "type": "integer" }, { - "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude)", + "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude).", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "latitude (x)", + "description": "Latitude (x).", "type": "number" }, { - "description": "longitude (y)", + "description": "Longitude (y).", "type": "number" } ] diff --git a/src/commands/georadiusbymember.json b/src/commands/georadiusbymember.json index 6102a1b163..7600b4da39 100644 --- a/src/commands/georadiusbymember.json +++ b/src/commands/georadiusbymember.json @@ -203,13 +203,13 @@ } ], "reply_schema": { - "description": "Array of matched members information", + "description": "Array of matched members information.", "anyOf": [ { - "description": "If no WITH* option is specified, array of matched members names", + "description": "If no WITH* option is specified, array of matched members names.", "type": "array", "items": { - "description": "name", + "description": "Name", "type": "string" } }, @@ -221,32 +221,32 @@ "maxItems": 4, "items": [ { - "description": "Matched member name", + "description": "Matched member name.", "type": "string" } ], "additionalItems": { "oneOf": [ { - "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius", + "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius.", "type": "string" }, { - "description": "If WITHHASH option is specified, the geohash integer", + "description": "If WITHHASH option is specified, the geohash integer.", "type": "integer" }, { - "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude)", + "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude).", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "latitude (x)", + "description": "Latitude (x).", "type": "number" }, { - "description": "longitude (y)", + "description": "Longitude (y).", "type": "number" } ] @@ -256,7 +256,7 @@ } }, { - "description": "number of items stored in key", + "description": "Number of items stored in key.", "type": "integer" } ] diff --git a/src/commands/georadiusbymember_ro.json b/src/commands/georadiusbymember_ro.json index 0cc599feff..ea4f94bddb 100644 --- a/src/commands/georadiusbymember_ro.json +++ b/src/commands/georadiusbymember_ro.json @@ -142,13 +142,13 @@ } ], "reply_schema": { - "description": "Array of matched members information", + "description": "Array of matched members information.", "anyOf": [ { - "description": "If no WITH* option is specified, array of matched members names", + "description": "If no WITH* option is specified, array of matched members names.", "type": "array", "items": { - "description": "name", + "description": "Name.", "type": "string" } }, @@ -160,32 +160,32 @@ "maxItems": 4, "items": [ { - "description": "Matched member name", + "description": "Matched member name.", "type": "string" } ], "additionalItems": { "oneOf": [ { - "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius", + "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius.", "type": "string" }, { - "description": "If WITHHASH option is specified, the geohash integer", + "description": "If WITHHASH option is specified, the geohash integer.", "type": "integer" }, { - "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude)", + "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude).", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "latitude (x)", + "description": "Latitude (x).", "type": "number" }, { - "description": "longitude (y)", + "description": "Longitude (y).", "type": "number" } ] diff --git a/src/commands/geosearch.json b/src/commands/geosearch.json index b2e2825d96..2214c4a8a6 100644 --- a/src/commands/geosearch.json +++ b/src/commands/geosearch.json @@ -209,13 +209,13 @@ } ], "reply_schema": { - "description": "Array of matched members information", + "description": "Array of matched members information.", "anyOf": [ { - "description": "If no WITH* option is specified, array of matched members names", + "description": "If no WITH* option is specified, array of matched members names.", "type": "array", "items": { - "description": "name", + "description": "Name.", "type": "string" } }, @@ -227,32 +227,32 @@ "maxItems": 4, "items": [ { - "description": "Matched member name", + "description": "Matched member name.", "type": "string" } ], "additionalItems": { "oneOf": [ { - "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius", + "description": "If WITHDIST option is specified, the distance from the center as a floating point number, in the same unit specified in the radius.", "type": "string" }, { - "description": "If WITHHASH option is specified, the geohash integer", + "description": "If WITHHASH option is specified, the geohash integer.", "type": "integer" }, { - "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude)", + "description": "If WITHCOORD option is specified, the coordinates as a two items x,y array (longitude,latitude).", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "latitude (x)", + "description": "Latitude (x).", "type": "number" }, { - "description": "longitude (y)", + "description": "Longitude (y).", "type": "number" } ] diff --git a/src/commands/geosearchstore.json b/src/commands/geosearchstore.json index dfbdaaaeca..0e7f61a8f8 100644 --- a/src/commands/geosearchstore.json +++ b/src/commands/geosearchstore.json @@ -221,7 +221,7 @@ } ], "reply_schema": { - "description": "the number of elements in the resulting set", + "description": "The number of elements in the resulting set.", "type": "integer" } } diff --git a/src/commands/hscan.json b/src/commands/hscan.json index 99e916574f..9e6099c2f2 100644 --- a/src/commands/hscan.json +++ b/src/commands/hscan.json @@ -65,17 +65,17 @@ } ], "reply_schema": { - "description": "cursor and scan response in array form", + "description": "Cursor and scan response in array form.", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "cursor", + "description": "Cursor.", "type": "string" }, { - "description": "list of key/value pairs from the hash where each even element is the key, and each odd element is the value, or when novalues option is on, a list of keys from the hash", + "description": "List of key/value pairs from the hash where each even element is the key, and each odd element is the value, or when novalues option is on, a list of keys from the hash.", "type": "array", "items": { "type": "string" diff --git a/src/commands/keys.json b/src/commands/keys.json index 9dd4e1101b..2aa9c280fd 100644 --- a/src/commands/keys.json +++ b/src/commands/keys.json @@ -24,7 +24,7 @@ } ], "reply_schema": { - "description": "list of keys matching pattern", + "description": "List of keys matching pattern.", "type": "array", "items": { "type": "string" diff --git a/src/commands/latency-history.json b/src/commands/latency-history.json index 7c3591aa2d..0c825004eb 100644 --- a/src/commands/latency-history.json +++ b/src/commands/latency-history.json @@ -27,12 +27,12 @@ "maxItems": 2, "items": [ { - "description": "timestamp of the event", + "description": "Timestamp of the event.", "type": "integer", "minimum": 0 }, { - "description": "latency of the event", + "description": "Latency of the event.", "type": "integer", "minimum": 0 } diff --git a/src/commands/linsert.json b/src/commands/linsert.json index 8059dc50d4..f26e679f8c 100644 --- a/src/commands/linsert.json +++ b/src/commands/linsert.json @@ -41,11 +41,11 @@ "minimum": 1 }, { - "description": "in case key doesn't exist.", + "description": "In case key doesn't exist.", "const": 0 }, { - "description": "when the pivot wasn't found.", + "description": "When the pivot wasn't found.", "const": -1 } ] diff --git a/src/commands/lpushx.json b/src/commands/lpushx.json index 5f6d17cbc7..59a31539c9 100644 --- a/src/commands/lpushx.json +++ b/src/commands/lpushx.json @@ -42,7 +42,7 @@ ], "reply_schema": { "type": "integer", - "description": "the length of the list after the push operation", + "description": "The length of the list after the push operation.", "minimum": 0 }, "arguments": [ diff --git a/src/commands/memory-doctor.json b/src/commands/memory-doctor.json index c0c8c22a8e..7bc0e1e6e2 100644 --- a/src/commands/memory-doctor.json +++ b/src/commands/memory-doctor.json @@ -13,7 +13,7 @@ "RESPONSE_POLICY:SPECIAL" ], "reply_schema": { - "description": "memory problems report", + "description": "Memory problems report.", "type": "string" } } diff --git a/src/commands/memory-stats.json b/src/commands/memory-stats.json index 98e49b7d27..e32f5a291b 100644 --- a/src/commands/memory-stats.json +++ b/src/commands/memory-stats.json @@ -13,7 +13,7 @@ "RESPONSE_POLICY:SPECIAL" ], "reply_schema": { - "description": "memory usage details", + "description": "Memory usage details.", "type": "object", "additionalProperties": false, "properties": { diff --git a/src/commands/move.json b/src/commands/move.json index 203068067f..54ec2f21ec 100644 --- a/src/commands/move.json +++ b/src/commands/move.json @@ -48,11 +48,11 @@ "reply_schema": { "oneOf": [ { - "description": "key was moved", + "description": "Key was moved.", "const": 1 }, { - "description": "key wasn't moved", + "description": "Key wasn't moved.", "const": 0 } ] diff --git a/src/commands/object-encoding.json b/src/commands/object-encoding.json index 3fab4aadb5..4ccf3f04b6 100644 --- a/src/commands/object-encoding.json +++ b/src/commands/object-encoding.json @@ -45,11 +45,11 @@ "reply_schema": { "oneOf": [ { - "description": "key doesn't exist", + "description": "Key doesn't exist.", "type": "null" }, { - "description": "encoding of the object", + "description": "Encoding of the object.", "type": "string" } ] diff --git a/src/commands/object-freq.json b/src/commands/object-freq.json index 7a7553b188..7e1b2e24e1 100644 --- a/src/commands/object-freq.json +++ b/src/commands/object-freq.json @@ -43,7 +43,7 @@ } ], "reply_schema": { - "description": "the counter's value", + "description": "The counter's value.", "type": "integer" } } diff --git a/src/commands/object-idletime.json b/src/commands/object-idletime.json index dc1d254c8e..372ff3ad00 100644 --- a/src/commands/object-idletime.json +++ b/src/commands/object-idletime.json @@ -43,7 +43,7 @@ } ], "reply_schema": { - "description": "the idle time in seconds", + "description": "The idle time in seconds.", "type": "integer" } } diff --git a/src/commands/object-refcount.json b/src/commands/object-refcount.json index 48009bbf75..3586f85a0f 100644 --- a/src/commands/object-refcount.json +++ b/src/commands/object-refcount.json @@ -43,7 +43,7 @@ } ], "reply_schema": { - "description": "the number of references", + "description": "The number of references.", "type": "integer" } } diff --git a/src/commands/pfadd.json b/src/commands/pfadd.json index 7d8448ad89..769a2f010c 100644 --- a/src/commands/pfadd.json +++ b/src/commands/pfadd.json @@ -50,11 +50,11 @@ "reply_schema": { "oneOf": [ { - "description": "if at least 1 HyperLogLog internal register was altered", + "description": "If at least 1 HyperLogLog internal register was altered.", "const": 1 }, { - "description": "if no HyperLogLog internal register were altered", + "description": "If no HyperLogLog internal register were altered.", "const": 0 } ] diff --git a/src/commands/publish.json b/src/commands/publish.json index 51890bf9c7..0dade72064 100644 --- a/src/commands/publish.json +++ b/src/commands/publish.json @@ -25,7 +25,7 @@ } ], "reply_schema": { - "description": "the number of clients that received the message. Note that in a Cluster, only clients that are connected to the same node as the publishing client are included in the count", + "description": "The number of clients that received the message. Note that in a Cluster, only clients that are connected to the same node as the publishing client are included in the count.", "type": "integer", "minimum": 0 } diff --git a/src/commands/pubsub-channels.json b/src/commands/pubsub-channels.json index 08505b3eba..1060131620 100644 --- a/src/commands/pubsub-channels.json +++ b/src/commands/pubsub-channels.json @@ -20,7 +20,7 @@ } ], "reply_schema": { - "description": "a list of active channels, optionally matching the specified pattern", + "description": "A list of active channels, optionally matching the specified pattern.", "type": "array", "uniqueItems": true, "items": { diff --git a/src/commands/pubsub-numpat.json b/src/commands/pubsub-numpat.json index ae653b74f6..8d3114f2e6 100644 --- a/src/commands/pubsub-numpat.json +++ b/src/commands/pubsub-numpat.json @@ -13,7 +13,7 @@ "STALE" ], "reply_schema": { - "description": "the number of patterns all the clients are subscribed to", + "description": "The number of patterns all the clients are subscribed to.", "type": "integer", "minimum": 0 } diff --git a/src/commands/pubsub-numsub.json b/src/commands/pubsub-numsub.json index 1cfe8e2ef1..e4b4ccdce4 100644 --- a/src/commands/pubsub-numsub.json +++ b/src/commands/pubsub-numsub.json @@ -21,7 +21,7 @@ } ], "reply_schema": { - "description": "the number of subscribers per channel, each even element (including 0th) is channel name, each odd element is the number of subscribers", + "description": "The number of subscribers per channel, each even element (including 0th) is channel name, each odd element is the number of subscribers.", "type": "array" } } diff --git a/src/commands/pubsub-shardchannels.json b/src/commands/pubsub-shardchannels.json index 7aa0a7a878..921a4a4327 100644 --- a/src/commands/pubsub-shardchannels.json +++ b/src/commands/pubsub-shardchannels.json @@ -20,7 +20,7 @@ } ], "reply_schema": { - "description": "a list of active channels, optionally matching the specified pattern", + "description": "A list of active channels, optionally matching the specified pattern.", "type": "array", "items": { "type": "string" diff --git a/src/commands/pubsub-shardnumsub.json b/src/commands/pubsub-shardnumsub.json index 43675340fa..8eeca4e31b 100644 --- a/src/commands/pubsub-shardnumsub.json +++ b/src/commands/pubsub-shardnumsub.json @@ -21,7 +21,7 @@ } ], "reply_schema": { - "description": "the number of subscribers per shard channel, each even element (including 0th) is channel name, each odd element is the number of subscribers", + "description": "The number of subscribers per shard channel, each even element (including 0th) is channel name, each odd element is the number of subscribers.", "type": "array" } } diff --git a/src/commands/randomkey.json b/src/commands/randomkey.json index eeef61aef1..29e54f6e24 100644 --- a/src/commands/randomkey.json +++ b/src/commands/randomkey.json @@ -21,11 +21,11 @@ "reply_schema": { "oneOf": [ { - "description": "when the database is empty", + "description": "When the database is empty.", "type": "null" }, { - "description": "random key in db", + "description": "Random key in db.", "type": "string" } ] diff --git a/src/commands/renamenx.json b/src/commands/renamenx.json index 72f0569d8e..e59c53bfcc 100644 --- a/src/commands/renamenx.json +++ b/src/commands/renamenx.json @@ -73,11 +73,11 @@ "reply_schema": { "oneOf": [ { - "description": "key was renamed to newkey", + "description": "Key was renamed to newkey.", "const": 1 }, { - "description": "new key already exists", + "description": "New key already exists.", "const": 0 } ] diff --git a/src/commands/replicaof.json b/src/commands/replicaof.json index 95e5cb400b..6ddedf2d68 100644 --- a/src/commands/replicaof.json +++ b/src/commands/replicaof.json @@ -51,7 +51,7 @@ } ], "reply_schema": { - "description": "replicaOf status", + "description": "ReplicaOf status.", "type": "string", "pattern": "OK*" } diff --git a/src/commands/role.json b/src/commands/role.json index a0299fa73e..1c3a4490ca 100644 --- a/src/commands/role.json +++ b/src/commands/role.json @@ -28,11 +28,11 @@ "const": "master" }, { - "description": "current replication master offset", + "description": "Current replication master offset.", "type": "integer" }, { - "description": "connected replicas", + "description": "Connected replicas.", "type": "array", "items": { "type": "array", @@ -40,15 +40,15 @@ "maxItems": 3, "items": [ { - "description": "replica ip", + "description": "Replica IP.", "type": "string" }, { - "description": "replica port", + "description": "Replica port.", "type": "string" }, { - "description": "last acknowledged replication offset", + "description": "Last acknowledged replication offset.", "type": "string" } ] @@ -65,48 +65,48 @@ "const": "slave" }, { - "description": "ip of master", + "description": "IP of master.", "type": "string" }, { - "description": "port number of master", + "description": "Port number of master.", "type": "integer" }, { - "description": "state of the replication from the point of view of the master", + "description": "State of the replication from the point of view of the master.", "oneOf": [ { - "description": "the instance is in handshake with its master", + "description": "The instance is in handshake with its master.", "const": "handshake" }, { - "description": "the instance in not active", + "description": "The instance in not active.", "const": "none" }, { - "description": "the instance needs to connect to its master", + "description": "The instance needs to connect to its master.", "const": "connect" }, { - "description": "the master-replica connection is in progress", + "description": "The master-replica connection is in progress.", "const": "connecting" }, { - "description": "the master and replica are trying to perform the synchronization", + "description": "The master and replica are trying to perform the synchronization.", "const": "sync" }, { - "description": "the replica is online", + "description": "The replica is online.", "const": "connected" }, { - "description": "instance state is unknown", + "description": "Instance state is unknown.", "const": "unknown" } ] }, { - "description": "the amount of data received from the replica so far in terms of master replication offset", + "description": "The amount of data received from the replica so far in terms of master replication offset.", "type": "integer" } ] @@ -120,7 +120,7 @@ "const": "sentinel" }, { - "description": "list of master names monitored by this sentinel instance", + "description": "List of master names monitored by this sentinel instance.", "type": "array", "items": { "type": "string" diff --git a/src/commands/scan.json b/src/commands/scan.json index a7df78a218..2b43c98056 100644 --- a/src/commands/scan.json +++ b/src/commands/scan.json @@ -50,17 +50,17 @@ } ], "reply_schema": { - "description": "cursor and scan response in array form", + "description": "Cursor and scan response in array form.", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "cursor", + "description": "Cursor.", "type": "string" }, { - "description": "list of keys", + "description": "List of keys.", "type": "array", "items": { "type": "string" diff --git a/src/commands/script-exists.json b/src/commands/script-exists.json index d8c47e4824..6c98fd78be 100644 --- a/src/commands/script-exists.json +++ b/src/commands/script-exists.json @@ -30,11 +30,11 @@ "items": { "oneOf": [ { - "description": "sha1 hash exists in script cache", + "description": "Sha1 hash exists in script cache.", "const": 1 }, { - "description": "sha1 hash does not exist in script cache", + "description": "Sha1 hash does not exist in script cache.", "const": 0 } ] diff --git a/src/commands/slaveof.json b/src/commands/slaveof.json index af5b54fae0..ca30982887 100644 --- a/src/commands/slaveof.json +++ b/src/commands/slaveof.json @@ -56,7 +56,7 @@ } ], "reply_schema": { - "description": "slaveOf status", + "description": "SlaveOf status.", "type": "string", "pattern": "OK*" } diff --git a/src/commands/sort.json b/src/commands/sort.json index d5f6511142..f2bd187e36 100644 --- a/src/commands/sort.json +++ b/src/commands/sort.json @@ -137,12 +137,12 @@ "reply_schema": { "oneOf": [ { - "description": "when the store option is specified the command returns the number of sorted elements in the destination list", + "description": "When the store option is specified the command returns the number of sorted elements in the destination list.", "type": "integer", "minimum": 0 }, { - "description": "when not passing the store option the command returns a list of sorted elements", + "description": "When not passing the store option the command returns a list of sorted elements.", "type": "array", "items": { "oneOf": [ @@ -150,7 +150,7 @@ "type": "string" }, { - "description": "GET option is specified, but no object was found", + "description": "GET option is specified, but no object was found.", "type": "null" } ] diff --git a/src/commands/sort_ro.json b/src/commands/sort_ro.json index 04cc3c8417..668888cfcc 100644 --- a/src/commands/sort_ro.json +++ b/src/commands/sort_ro.json @@ -114,7 +114,7 @@ } ], "reply_schema": { - "description": "a list of sorted elements", + "description": "A list of sorted elements.", "type": "array", "items": { "oneOf": [ @@ -122,7 +122,7 @@ "type": "string" }, { - "description": "GET option is specified, but no object was found", + "description": "GET option is specified, but no object was found.", "type": "null" } ] diff --git a/src/commands/spublish.json b/src/commands/spublish.json index 1016bd2826..da1360de7c 100644 --- a/src/commands/spublish.json +++ b/src/commands/spublish.json @@ -43,7 +43,7 @@ } ], "reply_schema": { - "description": "the number of clients that received the message. Note that in a Cluster, only clients that are connected to the same node as the publishing client are included in the count", + "description": "The number of clients that received the message. Note that in a Cluster, only clients that are connected to the same node as the publishing client are included in the count.", "type": "integer", "minimum": 0 } diff --git a/src/commands/sscan.json b/src/commands/sscan.json index b221c94cf1..1b78ee3db3 100644 --- a/src/commands/sscan.json +++ b/src/commands/sscan.json @@ -59,17 +59,17 @@ } ], "reply_schema": { - "description": "cursor and scan response in array form", + "description": "Cursor and scan response in array form.", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "cursor", + "description": "Cursor.", "type": "string" }, { - "description": "list of set members", + "description": "List of set members.", "type": "array", "items": { "type": "string" diff --git a/src/commands/touch.json b/src/commands/touch.json index fd1dc61c3b..03fc7b8de3 100644 --- a/src/commands/touch.json +++ b/src/commands/touch.json @@ -45,7 +45,7 @@ } ], "reply_schema": { - "description": "the number of touched keys", + "description": "The number of touched keys.", "type": "integer", "minimum": 0 } diff --git a/src/commands/unlink.json b/src/commands/unlink.json index a05704a1b3..81892b35ec 100644 --- a/src/commands/unlink.json +++ b/src/commands/unlink.json @@ -46,7 +46,7 @@ } ], "reply_schema": { - "description": "the number of keys that were unlinked", + "description": "The number of keys that were unlinked.", "type": "integer", "minimum": 0 } diff --git a/src/commands/xclaim.json b/src/commands/xclaim.json index 5c44746067..a908a0de87 100644 --- a/src/commands/xclaim.json +++ b/src/commands/xclaim.json @@ -100,16 +100,16 @@ "description": "Stream entries with IDs matching the specified range.", "anyOf": [ { - "description": "If JUSTID option is specified, return just an array of IDs of messages successfully claimed", + "description": "If JUSTID option is specified, return just an array of IDs of messages successfully claimed.", "type": "array", "items": { - "description": "Entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" } }, { - "description": "array of stream entries that contains each entry as an array of 2 elements, the Entry ID and the entry data itself", + "description": "Array of stream entries that contains each entry as an array of 2 elements, the Entry ID and the entry data itself.", "type": "array", "uniqueItems": true, "items": { @@ -118,12 +118,12 @@ "maxItems": 2, "items": [ { - "description": "Entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "Data", + "description": "Data.", "type": "array", "items": { "type": "string" diff --git a/src/commands/xinfo-stream.json b/src/commands/xinfo-stream.json index 609dc336d5..f98ea6acdc 100644 --- a/src/commands/xinfo-stream.json +++ b/src/commands/xinfo-stream.json @@ -55,42 +55,42 @@ "additionalProperties": false, "properties": { "length": { - "description": "the number of entries in the stream (see `XLEN`)", + "description": "The number of entries in the stream (see `XLEN`).", "type": "integer" }, "radix-tree-keys": { - "description": "the number of keys in the underlying radix data structure", + "description": "The number of keys in the underlying radix data structure.", "type": "integer" }, "radix-tree-nodes": { - "description": "the number of nodes in the underlying radix data structure", + "description": "The number of nodes in the underlying radix data structure.", "type": "integer" }, "last-generated-id": { - "description": "the ID of the least-recently entry that was added to the stream", + "description": "The ID of the least-recently entry that was added to the stream.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "max-deleted-entry-id": { - "description": "the maximal entry ID that was deleted from the stream", + "description": "The maximal entry ID that was deleted from the stream.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "recorded-first-entry-id": { - "description": "cached copy of the first entry ID", + "description": "Cached copy of the first entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "entries-added": { - "description": "the count of all entries added to the stream during its lifetime", + "description": "The count of all entries added to the stream during its lifetime.", "type": "integer" }, "groups": { - "description": "the number of consumer groups defined for the stream", + "description": "The number of consumer groups defined for the stream.", "type": "integer" }, "first-entry": { - "description": "the first entry of the stream", + "description": "The first entry of the stream.", "oneOf": [ { "type": "null" @@ -101,12 +101,12 @@ "maxItems": 2, "items": [ { - "description": "entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "data", + "description": "Data.", "type": "array", "items": { "type": "string" @@ -117,7 +117,7 @@ ] }, "last-entry": { - "description": "the last entry of the stream", + "description": "The last entry of the stream.", "oneOf": [ { "type": "null" @@ -128,12 +128,12 @@ "maxItems": 2, "items": [ { - "description": "entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "data", + "description": "Data.", "type": "array", "items": { "type": "string" @@ -151,38 +151,38 @@ "additionalProperties": false, "properties": { "length": { - "description": "the number of entries in the stream (see `XLEN`)", + "description": "The number of entries in the stream (see `XLEN`).", "type": "integer" }, "radix-tree-keys": { - "description": "the number of keys in the underlying radix data structure", + "description": "The number of keys in the underlying radix data structure.", "type": "integer" }, "radix-tree-nodes": { - "description": "the number of nodes in the underlying radix data structure", + "description": "The number of nodes in the underlying radix data structure.", "type": "integer" }, "last-generated-id": { - "description": "the ID of the least-recently entry that was added to the stream", + "description": "The ID of the least-recently entry that was added to the stream.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "max-deleted-entry-id": { - "description": "the maximal entry ID that was deleted from the stream", + "description": "The maximal entry ID that was deleted from the stream.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "recorded-first-entry-id": { - "description": "cached copy of the first entry ID", + "description": "Cached copy of the first entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "entries-added": { - "description": "the count of all entries added to the stream during its lifetime", + "description": "The count of all entries added to the stream during its lifetime.", "type": "integer" }, "entries": { - "description": "all the entries of the stream", + "description": "All the entries of the stream.", "type": "array", "uniqueItems": true, "items": { @@ -191,12 +191,12 @@ "maxItems": 2, "items": [ { - "description": "entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "data", + "description": "Data.", "type": "array", "items": { "type": "string" @@ -212,16 +212,16 @@ "additionalProperties": false, "properties": { "name": { - "description": "group name", + "description": "Group name.", "type": "string" }, "last-delivered-id": { - "description": "last entry ID that was delivered to a consumer", + "description": "Last entry ID that was delivered to a consumer.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, "entries-read": { - "description": "total number of entries ever read by consumers in the group", + "description": "Total number of entries ever read by consumers in the group.", "oneOf": [ { "type": "null" @@ -232,7 +232,7 @@ ] }, "lag": { - "description": "number of entries left to be consumed from the stream", + "description": "Number of entries left to be consumed from the stream.", "oneOf": [ { "type": "null" @@ -243,11 +243,11 @@ ] }, "pel-count": { - "description": "total number of unacknowledged entries", + "description": "Total number of unacknowledged entries.", "type": "integer" }, "pending": { - "description": "data about all of the unacknowledged entries", + "description": "Data about all of the unacknowledged entries.", "type": "array", "items": { "type": "array", @@ -255,27 +255,27 @@ "maxItems": 4, "items": [ { - "description": "Entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "Consumer name", + "description": "Consumer name.", "type": "string" }, { - "description": "Delivery timestamp", + "description": "Delivery timestamp.", "type": "integer" }, { - "description": "Delivery count", + "description": "Delivery count.", "type": "integer" } ] } }, "consumers": { - "description": "data about all of the consumers of the group", + "description": "Data about all of the consumers of the group.", "type": "array", "items": { "type": "object", @@ -287,20 +287,20 @@ "minimum": 0 }, "name": { - "description": "consumer name", + "description": "Consumer name.", "type": "string" }, "seen-time": { - "description": "timestamp of the last interaction attempt of the consumer", + "description": "Timestamp of the last interaction attempt of the consumer.", "type": "integer", "minimum": 0 }, "pel-count": { - "description": "number of unacknowledged entries that belong to the consumer", + "description": "Number of unacknowledged entries that belong to the consumer.", "type": "integer" }, "pending": { - "description": "data about the unacknowledged entries", + "description": "Data about the unacknowledged entries.", "type": "array", "items": { "type": "array", @@ -308,16 +308,16 @@ "maxItems": 3, "items": [ { - "description": "Entry ID", + "description": "Entry ID.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "Delivery timestamp", + "description": "Delivery timestamp.", "type": "integer" }, { - "description": "Delivery count", + "description": "Delivery count.", "type": "integer" } ] diff --git a/src/commands/xread.json b/src/commands/xread.json index 95e22c494e..b448903bb6 100644 --- a/src/commands/xread.json +++ b/src/commands/xread.json @@ -69,11 +69,11 @@ "reply_schema": { "oneOf": [ { - "description": "A map of key-value elements when each element composed of key name and the entries reported for that key", + "description": "A map of key-value elements when each element composed of key name and the entries reported for that key.", "type": "object", "patternProperties": { "^.*$": { - "description": "The entries reported for that key", + "description": "The entries reported for that key.", "type": "array", "items": { "type": "array", @@ -81,12 +81,12 @@ "maxItems": 2, "items": [ { - "description": "entry id", + "description": "Entry id.", "type": "string", "pattern": "[0-9]+-[0-9]+" }, { - "description": "array of field-value pairs", + "description": "A map of key-value elements when each element composed of key name and the entries reported for that key.", "type": "array", "items": { "type": "string" @@ -98,7 +98,7 @@ } }, { - "description": "If BLOCK option is given, and a timeout occurs, or there is no stream we can serve", + "description": "If BLOCK option is given, and a timeout occurs, or there is no stream we can serve.", "type": "null" } ] diff --git a/src/commands/zrangebyscore.json b/src/commands/zrangebyscore.json index 557ef1dc62..c89607e104 100644 --- a/src/commands/zrangebyscore.json +++ b/src/commands/zrangebyscore.json @@ -47,29 +47,29 @@ "anyOf": [ { "type": "array", - "description": "List of the elements in the specified score range, as not WITHSCORES", + "description": "List of the elements in the specified score range, as not WITHSCORES.", "uniqueItems": true, "items": { "type": "string", - "description": "Element" + "description": "Element." } }, { "type": "array", - "description": "List of the elements and their scores in the specified score range, as WITHSCORES used", + "description": "List of the elements and their scores in the specified score range, as WITHSCORES used.", "uniqueItems": true, "items": { "type": "array", - "description": "Tuple of element and its score", + "description": "Tuple of element and its score.", "minItems": 2, "maxItems": 2, "items": [ { - "description": "element", + "description": "Element.", "type": "string" }, { - "description": "score", + "description": "Score.", "type": "number" } ] diff --git a/src/commands/zrevrange.json b/src/commands/zrevrange.json index 116fe82b24..a143f72153 100644 --- a/src/commands/zrevrange.json +++ b/src/commands/zrevrange.json @@ -57,11 +57,11 @@ "maxItems": 2, "items": [ { - "description": "member", + "description": "Member.", "type": "string" }, { - "description": "score", + "description": "Score.", "type": "number" } ] diff --git a/src/commands/zrevrangebyscore.json b/src/commands/zrevrangebyscore.json index ab040527e1..0eb9e86956 100644 --- a/src/commands/zrevrangebyscore.json +++ b/src/commands/zrevrangebyscore.json @@ -47,30 +47,30 @@ "anyOf": [ { "type": "array", - "description": "List of the elements in the specified score range, as not WITHSCORES", + "description": "List of the elements in the specified score range, as not WITHSCORES.", "uniqueItems": true, "items": { "type": "string", - "description": "Element" + "description": "Element." } }, { "type": "array", - "description": "List of the elements and their scores in the specified score range, as WITHSCORES used", + "description": "List of the elements and their scores in the specified score range, as WITHSCORES used.", "uniqueItems": true, "items": { "type": "array", - "description": "Tuple of element and its score", + "description": "Tuple of element and its score.", "minItems": 2, "maxItems": 2, "items": [ { "type": "string", - "description": "element" + "description": "Element." }, { "type": "number", - "description": "score" + "description": "Score." } ] } diff --git a/src/commands/zscan.json b/src/commands/zscan.json index 7c69ccf65a..edadb8561b 100644 --- a/src/commands/zscan.json +++ b/src/commands/zscan.json @@ -59,17 +59,17 @@ } ], "reply_schema": { - "description": "cursor and scan response in array form", + "description": "Cursor and scan response in array form.", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { - "description": "cursor", + "description": "Cursor.", "type": "string" }, { - "description": "list of elements of the sorted set, where each even element is the member, and each odd value is its associated score", + "description": "List of elements of the sorted set, where each even element is the member, and each odd value is its associated score.", "type": "array", "items": { "type": "string" From c9fff601789e82dd409a0231eb698c31447b8f61 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 00:48:26 +0700 Subject: [PATCH 22/98] Pin 'typos' spellcheck to fixed version in CI (#151) Pin aiki-e/install-action to v2.32.2 (currently the latest version). Fixes #140. Signed-off-by: 0del --- .github/workflows/spell-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 1e6f58aacb..e146b79c94 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v4 - name: Install typos - uses: taiki-e/install-action@v2 + uses: taiki-e/install-action@v2.32.2 with: tool: typos From c0a83c00583ed2959079ae34ed8ca4cf7f90a264 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Tue, 2 Apr 2024 14:48:12 -0400 Subject: [PATCH 23/98] Fix CI centos issue (#150) Because centos do not support actions/checkout@v4, we need roll back to actions/checkout@v3 Please check the run result https://github.com/hwware/placeholderkv/actions/runs/8526052560/job/23354458574 It looks our CI make happy now Signed-off-by: hwware --- .github/workflows/daily.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index bb0a7daf07..a4ecf31ecf 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -674,7 +674,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -714,7 +714,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} @@ -761,7 +761,7 @@ jobs: echo "skiptests: ${{github.event.inputs.skiptests}}" echo "test_args: ${{github.event.inputs.test_args}}" echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}" - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 with: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} From 7a7288b2922231a38fb02238b299525c074d9dc7 Mon Sep 17 00:00:00 2001 From: Gabi Ganam Date: Wed, 3 Apr 2024 02:03:31 +0300 Subject: [PATCH 24/98] Log unused module configuration entries that cause redis to abort (#132) Log unused module configuration entries that cause redis to abort on startup. Example: ``` 17797:M 31 Mar 2024 12:26:12.146 # Unused Module Configuration: module1.whatever 17797:M 31 Mar 2024 12:26:12.146 # Unused Module Configuration: module2.test 17797:M 31 Mar 2024 12:26:12.146 # Module Configuration detected without loadmodule directive or no ApplyConfig call: aborting ``` Signed-off-by: Gabi Ganam --- src/module.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/module.c b/src/module.c index 416506dc57..4fa96e9526 100644 --- a/src/module.c +++ b/src/module.c @@ -12109,6 +12109,13 @@ void moduleLoadFromQueue(void) { listDelNode(server.loadmodule_queue, ln); } if (dictSize(server.module_configs_queue)) { + dictIterator *di = dictGetSafeIterator(server.module_configs_queue); + dictEntry *de; + while ((de = dictNext(di)) != NULL) { + const char *moduleConfigName = dictGetKey(de); + serverLog(LL_WARNING, "Unused Module Configuration: %s", moduleConfigName); + } + dictReleaseIterator(di); serverLog(LL_WARNING, "Module Configuration detected without loadmodule directive or no ApplyConfig call: aborting"); exit(1); } From 98892bb5c37c181199a66ea7cb85d47f87a357cd Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:29:42 +0700 Subject: [PATCH 25/98] Rename redisMemOverhead to serverMemOverhead (#159) Part of #144. Signed-off-by: 0del --- src/object.c | 12 ++++++------ src/server.c | 2 +- src/server.h | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/object.c b/src/object.c index ee3564657f..6e151f17b3 100644 --- a/src/object.c +++ b/src/object.c @@ -1161,20 +1161,20 @@ size_t objectComputeSize(robj *key, robj *o, size_t sample_size, int dbid) { } /* Release data obtained with getMemoryOverheadData(). */ -void freeMemoryOverheadData(struct redisMemOverhead *mh) { +void freeMemoryOverheadData(struct serverMemOverhead *mh) { zfree(mh->db); zfree(mh); } -/* Return a struct redisMemOverhead filled with memory overhead +/* Return a struct serverMemOverhead filled with memory overhead * information used for the MEMORY OVERHEAD and INFO command. The returned * structure pointer should be freed calling freeMemoryOverheadData(). */ -struct redisMemOverhead *getMemoryOverheadData(void) { +struct serverMemOverhead *getMemoryOverheadData(void) { int j; size_t mem_total = 0; size_t mem = 0; size_t zmalloc_used = zmalloc_used_memory(); - struct redisMemOverhead *mh = zcalloc(sizeof(*mh)); + struct serverMemOverhead *mh = zcalloc(sizeof(*mh)); mh->total_allocated = zmalloc_used; mh->startup_allocated = server.initial_memory_usage; @@ -1309,7 +1309,7 @@ sds getMemoryDoctorReport(void) { int big_client_buf = 0; /* Client buffers are too big. */ int many_scripts = 0; /* Script cache has too many scripts. */ int num_reports = 0; - struct redisMemOverhead *mh = getMemoryOverheadData(); + struct serverMemOverhead *mh = getMemoryOverheadData(); if (mh->total_allocated < (1024*1024*5)) { empty = 1; @@ -1562,7 +1562,7 @@ NULL usage += dictEntryMemUsage(); addReplyLongLong(c,usage); } else if (!strcasecmp(c->argv[1]->ptr,"stats") && c->argc == 2) { - struct redisMemOverhead *mh = getMemoryOverheadData(); + struct serverMemOverhead *mh = getMemoryOverheadData(); addReplyMapLen(c,31+mh->num_dbs); diff --git a/src/server.c b/src/server.c index 1605938d0e..37feaeac73 100644 --- a/src/server.c +++ b/src/server.c @@ -5660,7 +5660,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { const char *evict_policy = evictPolicyToString(); long long memory_lua = evalMemory(); long long memory_functions = functionsMemory(); - struct redisMemOverhead *mh = getMemoryOverheadData(); + struct serverMemOverhead *mh = getMemoryOverheadData(); /* Peak memory is updated from time to time by serverCron() so it * may happen that the instantaneous value is slightly bigger than diff --git a/src/server.h b/src/server.h index b9dbd65e7e..809c6bd29e 100644 --- a/src/server.h +++ b/src/server.h @@ -1396,7 +1396,7 @@ typedef struct redisOpArray { /* This structure is returned by the getMemoryOverheadData() function in * order to return memory overhead information. */ -struct redisMemOverhead { +struct serverMemOverhead { size_t peak_allocated; size_t total_allocated; size_t startup_allocated; @@ -3104,8 +3104,8 @@ void activeDefragCycle(void); unsigned int getLRUClock(void); unsigned int LRU_CLOCK(void); const char *evictPolicyToString(void); -struct redisMemOverhead *getMemoryOverheadData(void); -void freeMemoryOverheadData(struct redisMemOverhead *mh); +struct serverMemOverhead *getMemoryOverheadData(void); +void freeMemoryOverheadData(struct serverMemOverhead *mh); void checkChildrenDone(void); int setOOMScoreAdj(int process_class); void rejectCommandFormat(client *c, const char *fmt, ...); From 717dfe80221463e78cd5033c24ca71c1c582957c Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:02:43 +0700 Subject: [PATCH 26/98] Rename redisDb to serverDb (#156) A task of #144. Signed-off-by: 0del --- src/aof.c | 2 +- src/blocked.c | 6 +-- src/db.c | 94 +++++++++++++++++++++++------------------------ src/debug.c | 4 +- src/defrag.c | 20 +++++----- src/evict.c | 4 +- src/expire.c | 10 ++--- src/lazyfree.c | 2 +- src/module.c | 2 +- src/multi.c | 6 +-- src/object.c | 2 +- src/rdb.c | 4 +- src/replication.c | 8 ++-- src/server.c | 6 +-- src/server.h | 88 ++++++++++++++++++++++---------------------- src/sort.c | 2 +- 16 files changed, 130 insertions(+), 130 deletions(-) diff --git a/src/aof.c b/src/aof.c index 34385f41e7..cfa3df83a9 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2260,7 +2260,7 @@ int rewriteAppendOnlyFileRio(rio *aof) { for (j = 0; j < server.dbnum; j++) { char selectcmd[] = "*2\r\n$6\r\nSELECT\r\n"; - redisDb *db = server.db + j; + serverDb *db = server.db + j; if (kvstoreSize(db->keys) == 0) continue; /* SELECT the new DB */ diff --git a/src/blocked.c b/src/blocked.c index ff915aab06..aeac106706 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -453,7 +453,7 @@ static blocking_type getBlockedTypeByType(int type) { * made by a script or in the context of MULTI/EXEC. * * The list will be finally processed by handleClientsBlockedOnKeys() */ -static void signalKeyAsReadyLogic(redisDb *db, robj *key, int type, int deleted) { +static void signalKeyAsReadyLogic(serverDb *db, robj *key, int type, int deleted) { readyList *rl; /* Quick returns. */ @@ -548,11 +548,11 @@ static void releaseBlockedEntry(client *c, dictEntry *de, int remove_key) { dictDelete(c->bstate.keys, key); } -void signalKeyAsReady(redisDb *db, robj *key, int type) { +void signalKeyAsReady(serverDb *db, robj *key, int type) { signalKeyAsReadyLogic(db, key, type, 0); } -void signalDeletedKeyAsReady(redisDb *db, robj *key, int type) { +void signalDeletedKeyAsReady(serverDb *db, robj *key, int type) { signalKeyAsReadyLogic(db, key, type, 1); } diff --git a/src/db.c b/src/db.c index 43b1ba5586..e54d4e471e 100644 --- a/src/db.c +++ b/src/db.c @@ -52,9 +52,9 @@ typedef enum { KEY_DELETED /* The key was deleted now. */ } keyStatus; -keyStatus expireIfNeeded(redisDb *db, robj *key, int flags); -int keyIsExpired(redisDb *db, robj *key); -static void dbSetValue(redisDb *db, robj *key, robj *val, int overwrite, dictEntry *de); +keyStatus expireIfNeeded(serverDb *db, robj *key, int flags); +int keyIsExpired(serverDb *db, robj *key); +static void dbSetValue(serverDb *db, robj *key, robj *val, int overwrite, dictEntry *de); /* Update LFU when an object is accessed. * Firstly, decrement the counter if the decrement time is reached. @@ -92,7 +92,7 @@ void updateLFU(robj *val) { * Even if the key expiry is master-driven, we can correctly report a key is * expired on replicas even if the master is lagging expiring our key via DELs * in the replication link. */ -robj *lookupKey(redisDb *db, robj *key, int flags) { +robj *lookupKey(serverDb *db, robj *key, int flags) { dictEntry *de = dbFind(db, key->ptr); robj *val = NULL; if (de) { @@ -155,14 +155,14 @@ robj *lookupKey(redisDb *db, robj *key, int flags) { * This function is equivalent to lookupKey(). The point of using this function * rather than lookupKey() directly is to indicate that the purpose is to read * the key. */ -robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) { +robj *lookupKeyReadWithFlags(serverDb *db, robj *key, int flags) { serverAssert(!(flags & LOOKUP_WRITE)); return lookupKey(db, key, flags); } /* Like lookupKeyReadWithFlags(), but does not use any flag, which is the * common case. */ -robj *lookupKeyRead(redisDb *db, robj *key) { +robj *lookupKeyRead(serverDb *db, robj *key) { return lookupKeyReadWithFlags(db,key,LOOKUP_NONE); } @@ -172,11 +172,11 @@ robj *lookupKeyRead(redisDb *db, robj *key) { * * Returns the linked value object if the key exists or NULL if the key * does not exist in the specified DB. */ -robj *lookupKeyWriteWithFlags(redisDb *db, robj *key, int flags) { +robj *lookupKeyWriteWithFlags(serverDb *db, robj *key, int flags) { return lookupKey(db, key, flags | LOOKUP_WRITE); } -robj *lookupKeyWrite(redisDb *db, robj *key) { +robj *lookupKeyWrite(serverDb *db, robj *key) { return lookupKeyWriteWithFlags(db, key, LOOKUP_NONE); } @@ -197,7 +197,7 @@ robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply) { * * If the update_if_existing argument is false, the program is aborted * if the key already exists, otherwise, it can fall back to dbOverwrite. */ -static void dbAddInternal(redisDb *db, robj *key, robj *val, int update_if_existing) { +static void dbAddInternal(serverDb *db, robj *key, robj *val, int update_if_existing) { dictEntry *existing; int slot = getKeySlot(key->ptr); dictEntry *de = kvstoreDictAddRaw(db->keys, slot, key->ptr, &existing); @@ -213,7 +213,7 @@ static void dbAddInternal(redisDb *db, robj *key, robj *val, int update_if_exist notifyKeyspaceEvent(NOTIFY_NEW,"new",key,db->id); } -void dbAdd(redisDb *db, robj *key, robj *val) { +void dbAdd(serverDb *db, robj *key, robj *val) { dbAddInternal(db, key, val, 0); } @@ -251,7 +251,7 @@ int getKeySlot(sds key) { * The function returns 1 if the key was added to the database, taking * ownership of the SDS string, otherwise 0 is returned, and is up to the * caller to free the SDS string. */ -int dbAddRDBLoad(redisDb *db, sds key, robj *val) { +int dbAddRDBLoad(serverDb *db, sds key, robj *val) { int slot = getKeySlot(key); dictEntry *de = kvstoreDictAddRaw(db->keys, slot, key, NULL); if (de == NULL) return 0; @@ -272,7 +272,7 @@ int dbAddRDBLoad(redisDb *db, sds key, robj *val) { * The dictEntry input is optional, can be used if we already have one. * * The program is aborted if the key was not already present. */ -static void dbSetValue(redisDb *db, robj *key, robj *val, int overwrite, dictEntry *de) { +static void dbSetValue(serverDb *db, robj *key, robj *val, int overwrite, dictEntry *de) { int slot = getKeySlot(key->ptr); if (!de) de = kvstoreDictFind(db->keys, slot, key->ptr); serverAssertWithInfo(NULL,key,de != NULL); @@ -304,7 +304,7 @@ static void dbSetValue(redisDb *db, robj *key, robj *val, int overwrite, dictEnt /* Replace an existing key with a new value, we just replace value and don't * emit any events */ -void dbReplaceValue(redisDb *db, robj *key, robj *val) { +void dbReplaceValue(serverDb *db, robj *key, robj *val) { dbSetValue(db, key, val, 0, NULL); } @@ -321,7 +321,7 @@ void dbReplaceValue(redisDb *db, robj *key, robj *val) { * All the new keys in the database should be created via this interface. * The client 'c' argument may be set to NULL if the operation is performed * in a context where there is no clear client performing the operation. */ -void setKey(client *c, redisDb *db, robj *key, robj *val, int flags) { +void setKey(client *c, serverDb *db, robj *key, robj *val, int flags) { int keyfound = 0; if (flags & SETKEY_ALREADY_EXIST) @@ -347,7 +347,7 @@ void setKey(client *c, redisDb *db, robj *key, robj *val, int flags) { * If there are no keys, NULL is returned. * * The function makes sure to return keys not already expired. */ -robj *dbRandomKey(redisDb *db) { +robj *dbRandomKey(serverDb *db) { dictEntry *de; int maxtries = 100; int allvolatile = kvstoreSize(db->keys) == kvstoreSize(db->expires); @@ -383,7 +383,7 @@ robj *dbRandomKey(redisDb *db) { } /* Helper for sync and async delete. */ -int dbGenericDelete(redisDb *db, robj *key, int async, int flags) { +int dbGenericDelete(serverDb *db, robj *key, int async, int flags) { dictEntry **plink; int table; int slot = getKeySlot(key->ptr); @@ -417,19 +417,19 @@ int dbGenericDelete(redisDb *db, robj *key, int async, int flags) { } /* Delete a key, value, and associated expiration entry if any, from the DB */ -int dbSyncDelete(redisDb *db, robj *key) { +int dbSyncDelete(serverDb *db, robj *key) { return dbGenericDelete(db, key, 0, DB_FLAG_KEY_DELETED); } /* Delete a key, value, and associated expiration entry if any, from the DB. If * the value consists of many allocations, it may be freed asynchronously. */ -int dbAsyncDelete(redisDb *db, robj *key) { +int dbAsyncDelete(serverDb *db, robj *key) { return dbGenericDelete(db, key, 1, DB_FLAG_KEY_DELETED); } /* This is a wrapper whose behavior depends on the Redis lazy free * configuration. Deletes the key synchronously or asynchronously. */ -int dbDelete(redisDb *db, robj *key) { +int dbDelete(serverDb *db, robj *key) { return dbGenericDelete(db, key, server.lazyfree_lazy_server_del, DB_FLAG_KEY_DELETED); } @@ -460,7 +460,7 @@ int dbDelete(redisDb *db, robj *key) { * At this point the caller is ready to modify the object, for example * using an sdscat() call to append some data, or anything else. */ -robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) { +robj *dbUnshareStringValue(serverDb *db, robj *key, robj *o) { serverAssert(o->type == OBJ_STRING); if (o->refcount != 1 || o->encoding != OBJ_ENCODING_RAW) { robj *decoded = getDecodedObject(o); @@ -477,7 +477,7 @@ robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) { * The dbnum can be -1 if all the DBs should be emptied, or the specified * DB index if we want to empty only a single database. * The function returns the number of keys removed from the database(s). */ -long long emptyDbStructure(redisDb *dbarray, int dbnum, int async, +long long emptyDbStructure(serverDb *dbarray, int dbnum, int async, void(callback)(dict*)) { long long removed = 0; @@ -562,14 +562,14 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { } /* Initialize temporary db on replica for use during diskless replication. */ -redisDb *initTempDb(void) { +serverDb *initTempDb(void) { int slot_count_bits = 0; int flags = KVSTORE_ALLOCATE_DICTS_ON_DEMAND; if (server.cluster_enabled) { slot_count_bits = CLUSTER_SLOT_MASK_BITS; flags |= KVSTORE_FREE_EMPTY_DICTS; } - redisDb *tempDb = zcalloc(sizeof(redisDb)*server.dbnum); + serverDb *tempDb = zcalloc(sizeof(serverDb)*server.dbnum); for (int i=0; iblocking_keys); while((de = dictNext(di)) != NULL) { @@ -1531,7 +1531,7 @@ void scanDatabaseForReadyKeys(redisDb *db) { /* Since we are unblocking XREADGROUP clients in the event the * key was deleted/overwritten we must do the same in case the * database was flushed/swapped. */ -void scanDatabaseForDeletedKeys(redisDb *emptied, redisDb *replaced_with) { +void scanDatabaseForDeletedKeys(serverDb *emptied, serverDb *replaced_with) { dictEntry *de; dictIterator *di = dictGetSafeIterator(emptied->blocking_keys); while((de = dictNext(di)) != NULL) { @@ -1573,8 +1573,8 @@ int dbSwapDatabases(int id1, int id2) { if (id1 < 0 || id1 >= server.dbnum || id2 < 0 || id2 >= server.dbnum) return C_ERR; if (id1 == id2) return C_OK; - redisDb aux = server.db[id1]; - redisDb *db1 = &server.db[id1], *db2 = &server.db[id2]; + serverDb aux = server.db[id1]; + serverDb *db1 = &server.db[id1], *db2 = &server.db[id2]; /* Swapdb should make transaction fail if there is any * client watching keys */ @@ -1615,10 +1615,10 @@ int dbSwapDatabases(int id1, int id2) { /* Logically, this discards (flushes) the old main database, and apply the newly loaded * database (temp) as the main (active) database, the actual freeing of old database * (which will now be placed in the temp one) is done later. */ -void swapMainDbWithTempDb(redisDb *tempDb) { +void swapMainDbWithTempDb(serverDb *tempDb) { for (int i=0; iexpires, getKeySlot(key->ptr), key->ptr) == DICT_OK; } @@ -1699,7 +1699,7 @@ int removeExpire(redisDb *db, robj *key) { * of an user calling a command 'c' is the client, otherwise 'c' is set * to NULL. The 'when' parameter is the absolute unix time in milliseconds * after which the key will no longer be considered valid. */ -void setExpire(client *c, redisDb *db, robj *key, long long when) { +void setExpire(client *c, serverDb *db, robj *key, long long when) { dictEntry *kde, *de, *existing; /* Reuse the sds from the main dict in the expire dict */ @@ -1720,7 +1720,7 @@ void setExpire(client *c, redisDb *db, robj *key, long long when) { /* Return the expire time of the specified key, or -1 if no expire * is associated with this key (i.e. the key is non volatile) */ -long long getExpire(redisDb *db, robj *key) { +long long getExpire(serverDb *db, robj *key) { dictEntry *de; if ((de = dbFindExpires(db, key->ptr)) == NULL) @@ -1730,7 +1730,7 @@ long long getExpire(redisDb *db, robj *key) { } /* Delete the specified expired key and propagate expire. */ -void deleteExpiredKeyAndPropagate(redisDb *db, robj *keyobj) { +void deleteExpiredKeyAndPropagate(serverDb *db, robj *keyobj) { mstime_t expire_latency; latencyStartMonitor(expire_latency); dbGenericDelete(db,keyobj,server.lazyfree_lazy_expire,DB_FLAG_KEY_EXPIRED); @@ -1761,7 +1761,7 @@ void deleteExpiredKeyAndPropagate(redisDb *db, robj *keyobj) { * postExecutionUnitOperations, preferably just after a * single deletion batch, so that DEL/UNLINK will NOT be wrapped * in MULTI/EXEC */ -void propagateDeletion(redisDb *db, robj *key, int lazy) { +void propagateDeletion(serverDb *db, robj *key, int lazy) { robj *argv[2]; argv[0] = lazy ? shared.unlink : shared.del; @@ -1781,7 +1781,7 @@ void propagateDeletion(redisDb *db, robj *key, int lazy) { } /* Check if the key is expired. */ -int keyIsExpired(redisDb *db, robj *key) { +int keyIsExpired(serverDb *db, robj *key) { /* Don't expire anything while loading. It will be done later. */ if (server.loading) return 0; @@ -1827,7 +1827,7 @@ int keyIsExpired(redisDb *db, robj *key) { * The return value of the function is KEY_VALID if the key is still valid. * The function returns KEY_EXPIRED if the key is expired BUT not deleted, * or returns KEY_DELETED if the key is expired and deleted. */ -keyStatus expireIfNeeded(redisDb *db, robj *key, int flags) { +keyStatus expireIfNeeded(serverDb *db, robj *key, int flags) { if (server.lazy_expire_disabled) return KEY_VALID; if (!keyIsExpired(db,key)) return KEY_VALID; @@ -1905,11 +1905,11 @@ static int dbExpandGeneric(kvstore *kvs, uint64_t db_size, int try_expand) { return ret? C_OK : C_ERR; } -int dbExpand(redisDb *db, uint64_t db_size, int try_expand) { +int dbExpand(serverDb *db, uint64_t db_size, int try_expand) { return dbExpandGeneric(db->keys, db_size, try_expand); } -int dbExpandExpires(redisDb *db, uint64_t db_size, int try_expand) { +int dbExpandExpires(serverDb *db, uint64_t db_size, int try_expand) { return dbExpandGeneric(db->expires, db_size, try_expand); } @@ -1917,19 +1917,19 @@ static dictEntry *dbFindGeneric(kvstore *kvs, void *key) { return kvstoreDictFind(kvs, getKeySlot(key), key); } -dictEntry *dbFind(redisDb *db, void *key) { +dictEntry *dbFind(serverDb *db, void *key) { return dbFindGeneric(db->keys, key); } -dictEntry *dbFindExpires(redisDb *db, void *key) { +dictEntry *dbFindExpires(serverDb *db, void *key) { return dbFindGeneric(db->expires, key); } -unsigned long long dbSize(redisDb *db) { +unsigned long long dbSize(serverDb *db) { return kvstoreSize(db->keys); } -unsigned long long dbScan(redisDb *db, unsigned long long cursor, dictScanFunction *scan_cb, void *privdata) { +unsigned long long dbScan(serverDb *db, unsigned long long cursor, dictScanFunction *scan_cb, void *privdata) { return kvstoreScan(db->keys, cursor, -1, scan_cb, NULL, privdata); } diff --git a/src/debug.c b/src/debug.c index c1327ed48a..676a1c32dd 100644 --- a/src/debug.c +++ b/src/debug.c @@ -142,7 +142,7 @@ void mixStringObjectDigest(unsigned char *digest, robj *o) { * Note that this function does not reset the initial 'digest' passed, it * will continue mixing this object digest to anything that was already * present. */ -void xorObjectDigest(redisDb *db, robj *keyobj, unsigned char *digest, robj *o) { +void xorObjectDigest(serverDb *db, robj *keyobj, unsigned char *digest, robj *o) { uint32_t aux = htonl(o->type); mixDigest(digest,&aux,sizeof(aux)); long long expiretime = getExpire(db,keyobj); @@ -288,7 +288,7 @@ void computeDatasetDigest(unsigned char *final) { memset(final,0,20); /* Start with a clean result */ for (j = 0; j < server.dbnum; j++) { - redisDb *db = server.db+j; + serverDb *db = server.db+j; if (kvstoreSize(db->keys) == 0) continue; kvstoreIterator *kvs_it = kvstoreIteratorInit(db->keys); diff --git a/src/defrag.c b/src/defrag.c index 40bba2d33b..30d72993c0 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -349,7 +349,7 @@ void activeDefragQuickListNodes(quicklist *ql) { /* when the value has lots of elements, we want to handle it later and not as * part of the main dictionary scan. this is needed in order to prevent latency * spikes when handling large items */ -void defragLater(redisDb *db, dictEntry *kde) { +void defragLater(serverDb *db, dictEntry *kde) { sds key = sdsdup(dictGetKey(kde)); listAddNodeTail(db->defrag_later, key); } @@ -449,7 +449,7 @@ void scanLaterHash(robj *ob, unsigned long *cursor) { *cursor = dictScanDefrag(d, *cursor, scanCallbackCountScanned, &defragfns, NULL); } -void defragQuicklist(redisDb *db, dictEntry *kde) { +void defragQuicklist(serverDb *db, dictEntry *kde) { robj *ob = dictGetVal(kde); quicklist *ql = ob->ptr, *newql; serverAssert(ob->type == OBJ_LIST && ob->encoding == OBJ_ENCODING_QUICKLIST); @@ -461,7 +461,7 @@ void defragQuicklist(redisDb *db, dictEntry *kde) { activeDefragQuickListNodes(ql); } -void defragZsetSkiplist(redisDb *db, dictEntry *kde) { +void defragZsetSkiplist(serverDb *db, dictEntry *kde) { robj *ob = dictGetVal(kde); zset *zs = (zset*)ob->ptr; zset *newzs; @@ -490,7 +490,7 @@ void defragZsetSkiplist(redisDb *db, dictEntry *kde) { zs->dict = newdict; } -void defragHash(redisDb *db, dictEntry *kde) { +void defragHash(serverDb *db, dictEntry *kde) { robj *ob = dictGetVal(kde); dict *d, *newd; serverAssert(ob->type == OBJ_HASH && ob->encoding == OBJ_ENCODING_HT); @@ -504,7 +504,7 @@ void defragHash(redisDb *db, dictEntry *kde) { ob->ptr = newd; } -void defragSet(redisDb *db, dictEntry *kde) { +void defragSet(serverDb *db, dictEntry *kde) { robj *ob = dictGetVal(kde); dict *d, *newd; serverAssert(ob->type == OBJ_SET && ob->encoding == OBJ_ENCODING_HT); @@ -657,7 +657,7 @@ void* defragStreamConsumerGroup(raxIterator *ri, void *privdata) { return NULL; } -void defragStream(redisDb *db, dictEntry *kde) { +void defragStream(serverDb *db, dictEntry *kde) { robj *ob = dictGetVal(kde); serverAssert(ob->type == OBJ_STREAM && ob->encoding == OBJ_ENCODING_STREAM); stream *s = ob->ptr, *news; @@ -681,7 +681,7 @@ void defragStream(redisDb *db, dictEntry *kde) { /* Defrag a module key. This is either done immediately or scheduled * for later. Returns then number of pointers defragged. */ -void defragModule(redisDb *db, dictEntry *kde) { +void defragModule(serverDb *db, dictEntry *kde) { robj *obj = dictGetVal(kde); serverAssert(obj->type == OBJ_MODULE); @@ -696,7 +696,7 @@ void defragKey(defragCtx *ctx, dictEntry *de) { robj *newob, *ob; unsigned char *newzl; sds newsds; - redisDb *db = ctx->privdata; + serverDb *db = ctx->privdata; int slot = ctx->slot; /* Try to defrag the key name. */ newsds = activeDefragSds(keysds); @@ -884,7 +884,7 @@ static sds defrag_later_current_key = NULL; static unsigned long defrag_later_cursor = 0; /* returns 0 if no more work needs to be been done, and 1 if time is up and more work is needed. */ -int defragLaterStep(redisDb *db, int slot, long long endtime) { +int defragLaterStep(serverDb *db, int slot, long long endtime) { unsigned int iterations = 0; unsigned long long prev_defragged = server.stat_active_defrag_hits; unsigned long long prev_scanned = server.stat_active_defrag_scanned; @@ -993,7 +993,7 @@ void activeDefragCycle(void) { static int defrag_later_item_in_progress = 0; static int defrag_stage = 0; static unsigned long defrag_cursor = 0; - static redisDb *db = NULL; + static serverDb *db = NULL; static long long start_scan, start_stat; unsigned int iterations = 0; unsigned long long prev_defragged = server.stat_active_defrag_hits; diff --git a/src/evict.c b/src/evict.c index f40612627d..e3b7ebcece 100644 --- a/src/evict.c +++ b/src/evict.c @@ -143,7 +143,7 @@ void evictionPoolAlloc(void) { * We insert keys on place in ascending order, so keys with the smaller * idle time are on the left, and keys with the higher idle time on the * right. */ -int evictionPoolPopulate(redisDb *db, kvstore *samplekvs, struct evictionPoolEntry *pool) { +int evictionPoolPopulate(serverDb *db, kvstore *samplekvs, struct evictionPoolEntry *pool) { int j, k, count; dictEntry *samples[server.maxmemory_samples]; @@ -579,7 +579,7 @@ int performEvictions(void) { static unsigned int next_db = 0; sds bestkey = NULL; int bestdbid; - redisDb *db; + serverDb *db; dictEntry *de; if (server.maxmemory_policy & (MAXMEMORY_FLAG_LRU|MAXMEMORY_FLAG_LFU) || diff --git a/src/expire.c b/src/expire.c index 2092c5a09b..4f0868d715 100644 --- a/src/expire.c +++ b/src/expire.c @@ -55,7 +55,7 @@ static double avg_ttl_factor[16] = {0.98, 0.9604, 0.941192, 0.922368, 0.903921, * * The parameter 'now' is the current time in milliseconds as is passed * to the function to avoid too many gettimeofday() syscalls. */ -int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) { +int activeExpireCycleTryExpire(serverDb *db, dictEntry *de, long long now) { long long t = dictGetSignedIntegerVal(de); if (now > t) { enterExecutionUnit(1, 0); @@ -118,7 +118,7 @@ int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) { /* Data used by the expire dict scan callback. */ typedef struct { - redisDb *db; + serverDb *db; long long now; unsigned long sampled; /* num keys checked */ unsigned long expired; /* num keys expired */ @@ -242,7 +242,7 @@ void activeExpireCycle(int type) { data.ttl_sum = 0; data.ttl_samples = 0; - redisDb *db = server.db+(current_db % server.dbnum); + serverDb *db = server.db+(current_db % server.dbnum); data.db = db; int db_done = 0; /* The scan of the current DB is done? */ @@ -429,7 +429,7 @@ void expireSlaveKeys(void) { int dbid = 0; while(dbids && dbid < server.dbnum) { if ((dbids & 1) != 0) { - redisDb *db = server.db+dbid; + serverDb *db = server.db+dbid; dictEntry *expire = dbFindExpires(db, keyname); int expired = 0; @@ -474,7 +474,7 @@ void expireSlaveKeys(void) { /* Track keys that received an EXPIRE or similar command in the context * of a writable slave. */ -void rememberSlaveKeyWithExpire(redisDb *db, robj *key) { +void rememberSlaveKeyWithExpire(serverDb *db, robj *key) { if (slaveKeysWithExpire == NULL) { static dictType dt = { dictSdsHash, /* hash function */ diff --git a/src/lazyfree.c b/src/lazyfree.c index 80c4607d3e..cd220fca15 100644 --- a/src/lazyfree.c +++ b/src/lazyfree.c @@ -185,7 +185,7 @@ void freeObjAsync(robj *key, robj *obj, int dbid) { /* Empty a Redis DB asynchronously. What the function does actually is to * create a new empty set of hash tables and scheduling the old ones for * lazy freeing. */ -void emptyDbAsync(redisDb *db) { +void emptyDbAsync(serverDb *db) { int slot_count_bits = 0; int flags = KVSTORE_ALLOCATE_DICTS_ON_DEMAND; if (server.cluster_enabled) { diff --git a/src/module.c b/src/module.c index 4fa96e9526..f06952df74 100644 --- a/src/module.c +++ b/src/module.c @@ -189,7 +189,7 @@ typedef struct RedisModuleCtx RedisModuleCtx; /* This represents a Redis key opened with RM_OpenKey(). */ struct RedisModuleKey { RedisModuleCtx *ctx; - redisDb *db; + serverDb *db; robj *key; /* Key name object. */ robj *value; /* Value object, or NULL if the key was not found. */ void *iter; /* Iterator. */ diff --git a/src/multi.c b/src/multi.c index a51687363e..c3adf82b7a 100644 --- a/src/multi.c +++ b/src/multi.c @@ -274,7 +274,7 @@ void execCommand(client *c) { typedef struct watchedKey { listNode node; robj *key; - redisDb *db; + serverDb *db; client *client; unsigned expired:1; /* Flag that we're watching an already expired key. */ } watchedKey; @@ -377,7 +377,7 @@ int isWatchedKeyExpired(client *c) { /* "Touch" a key, so that if this key is being WATCHed by some client the * next EXEC will fail. */ -void touchWatchedKey(redisDb *db, robj *key) { +void touchWatchedKey(serverDb *db, robj *key) { list *clients; listIter li; listNode *ln; @@ -425,7 +425,7 @@ void touchWatchedKey(redisDb *db, robj *key) { * replaced_with: for SWAPDB, the WATCH should be invalidated if * the key exists in either of them, and skipped only if it * doesn't exist in both. */ -void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with) { +void touchAllWatchedKeysInDb(serverDb *emptied, serverDb *replaced_with) { listIter li; listNode *ln; dictEntry *de; diff --git a/src/object.c b/src/object.c index 6e151f17b3..8c00adbcba 100644 --- a/src/object.c +++ b/src/object.c @@ -1245,7 +1245,7 @@ struct serverMemOverhead *getMemoryOverheadData(void) { mem_total+=mh->functions_caches; for (j = 0; j < server.dbnum; j++) { - redisDb *db = server.db+j; + serverDb *db = server.db+j; if (!kvstoreNumAllocatedDicts(db->keys)) continue; unsigned long long keyscount = kvstoreSize(db->keys); diff --git a/src/rdb.c b/src/rdb.c index a633a49615..688437ddd5 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1305,7 +1305,7 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) { static long long info_updated_time = 0; char *pname = (rdbflags & RDBFLAGS_AOF_PREAMBLE) ? "AOF rewrite" : "RDB"; - redisDb *db = server.db + dbid; + serverDb *db = server.db + dbid; unsigned long long int db_size = kvstoreSize(db->keys); if (db_size == 0) return 0; @@ -3033,7 +3033,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin int type, rdbver; uint64_t db_size = 0, expires_size = 0; int should_expand_db = 0; - redisDb *db = rdb_loading_ctx->dbarray+0; + serverDb *db = rdb_loading_ctx->dbarray+0; char buf[1024]; int error; long long empty_keys_skipped = 0; diff --git a/src/replication.c b/src/replication.c index 28c4b14111..d2ea5bbf23 100644 --- a/src/replication.c +++ b/src/replication.c @@ -1840,13 +1840,13 @@ static int useDisklessLoad(void) { /* Helper function for readSyncBulkPayload() to initialize tempDb * before socket-loading the new db from master. The tempDb may be populated * by swapMainDbWithTempDb or freed by disklessLoadDiscardTempDb later. */ -redisDb *disklessLoadInitTempDb(void) { +serverDb *disklessLoadInitTempDb(void) { return initTempDb(); } /* Helper function for readSyncBulkPayload() to discard our tempDb * when the loading succeeded or failed. */ -void disklessLoadDiscardTempDb(redisDb *tempDb) { +void disklessLoadDiscardTempDb(serverDb *tempDb) { discardTempDb(tempDb, replicationEmptyDbCallback); } @@ -1870,7 +1870,7 @@ void readSyncBulkPayload(connection *conn) { char buf[PROTO_IOBUF_LEN]; ssize_t nread, readlen, nwritten; int use_diskless_load = useDisklessLoad(); - redisDb *diskless_load_tempDb = NULL; + serverDb *diskless_load_tempDb = NULL; functionsLibCtx* temp_functions_lib_ctx = NULL; int empty_db_flags = server.repl_slave_lazy_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS; @@ -2088,7 +2088,7 @@ void readSyncBulkPayload(connection *conn) { rdbSaveInfo rsi = RDB_SAVE_INFO_INIT; if (use_diskless_load) { rio rdb; - redisDb *dbarray; + serverDb *dbarray; functionsLibCtx* functions_lib_ctx; int asyncLoading = 0; diff --git a/src/server.c b/src/server.c index 37feaeac73..2b2dafd640 100644 --- a/src/server.c +++ b/src/server.c @@ -1082,7 +1082,7 @@ void databasesCron(void) { if (dbs_per_call > server.dbnum) dbs_per_call = server.dbnum; for (j = 0; j < dbs_per_call; j++) { - redisDb *db = &server.db[resize_db % server.dbnum]; + serverDb *db = &server.db[resize_db % server.dbnum]; kvstoreTryResizeDicts(db->keys, CRON_DICTS_PER_DB); kvstoreTryResizeDicts(db->expires, CRON_DICTS_PER_DB); resize_db++; @@ -1092,7 +1092,7 @@ void databasesCron(void) { if (server.activerehashing) { uint64_t elapsed_us = 0; for (j = 0; j < dbs_per_call; j++) { - redisDb *db = &server.db[rehash_db % server.dbnum]; + serverDb *db = &server.db[rehash_db % server.dbnum]; elapsed_us += kvstoreIncrementallyRehash(db->keys, INCREMENTAL_REHASHING_THRESHOLD_US - elapsed_us); if (elapsed_us >= INCREMENTAL_REHASHING_THRESHOLD_US) break; @@ -2655,7 +2655,7 @@ void initServer(void) { strerror(errno)); exit(1); } - server.db = zmalloc(sizeof(redisDb)*server.dbnum); + server.db = zmalloc(sizeof(server)*server.dbnum); /* Create the Redis databases, and initialize other internal state. */ int slot_count_bits = 0; diff --git a/src/server.h b/src/server.h index 809c6bd29e..1d911cc8d2 100644 --- a/src/server.h +++ b/src/server.h @@ -974,7 +974,7 @@ typedef struct replBufBlock { /* Redis database representation. There are multiple databases identified * by integers from 0 (the default database) up to the max configured * database. The database number is the 'id' field in the structure. */ -typedef struct redisDb { +typedef struct serverDb { kvstore *keys; /* The keyspace for this DB */ kvstore *expires; /* Timeout of keys with a timeout set */ dict *blocking_keys; /* Keys with clients waiting for data (BLPOP)*/ @@ -987,7 +987,7 @@ typedef struct redisDb { long long avg_ttl; /* Average TTL, just for stats */ unsigned long expires_cursor; /* Cursor of the active expire cycle. */ list *defrag_later; /* List of key names to attempt to defrag one by one, gradually. */ -} redisDb; +} serverDb; /* forward declaration for functions ctx */ typedef struct functionsLibCtx functionsLibCtx; @@ -998,7 +998,7 @@ typedef struct functionsLibCtx functionsLibCtx; * For example: dbarray need to be set as main database on * successful loading and dropped on failure. */ typedef struct rdbLoadingCtx { - redisDb* dbarray; + serverDb* dbarray; functionsLibCtx* functions_lib_ctx; }rdbLoadingCtx; @@ -1062,7 +1062,7 @@ typedef struct blockingState { * where we make sure to remember if a given key was already added in the * server.ready_keys list. */ typedef struct readyList { - redisDb *db; + serverDb *db; robj *key; } readyList; @@ -1164,7 +1164,7 @@ typedef struct client { uint64_t flags; /* Client flags: CLIENT_* macros. */ connection *conn; int resp; /* RESP protocol version. Can be 2 or 3. */ - redisDb *db; /* Pointer to currently SELECTed DB. */ + serverDb *db; /* Pointer to currently SELECTed DB. */ robj *name; /* As set by CLIENT SETNAME. */ robj *lib_name; /* The client library name as set by CLIENT SETINFO. */ robj *lib_ver; /* The client library version as set by CLIENT SETINFO. */ @@ -1558,7 +1558,7 @@ struct redisServer { mode_t umask; /* The umask value of the process on startup */ int hz; /* serverCron() calls frequency in hertz */ int in_fork_child; /* indication that this is a fork child */ - redisDb *db; + serverDb *db; dict *commands; /* Command table */ dict *orig_commands; /* Command table before command renaming. */ aeEventLoop *el; @@ -2745,9 +2745,9 @@ void initClientMultiState(client *c); void freeClientMultiState(client *c); void queueMultiCommand(client *c, uint64_t cmd_flags); size_t multiStateMemOverhead(client *c); -void touchWatchedKey(redisDb *db, robj *key); +void touchWatchedKey(serverDb *db, robj *key); int isWatchedKeyExpired(client *c); -void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with); +void touchAllWatchedKeysInDb(serverDb *emptied, serverDb *replaced_with); void discardTransaction(client *c); void flagTransaction(client *c); void execCommandAbort(client *c, sds error); @@ -3123,12 +3123,12 @@ int getKeySlot(sds key); int calculateKeySlot(sds key); /* kvstore wrappers */ -int dbExpand(redisDb *db, uint64_t db_size, int try_expand); -int dbExpandExpires(redisDb *db, uint64_t db_size, int try_expand); -dictEntry *dbFind(redisDb *db, void *key); -dictEntry *dbFindExpires(redisDb *db, void *key); -unsigned long long dbSize(redisDb *db); -unsigned long long dbScan(redisDb *db, unsigned long long cursor, dictScanFunction *scan_cb, void *privdata); +int dbExpand(serverDb *db, uint64_t db_size, int try_expand); +int dbExpandExpires(serverDb *db, uint64_t db_size, int try_expand); +dictEntry *dbFind(serverDb *db, void *key); +dictEntry *dbFindExpires(serverDb *db, void *key); +unsigned long long dbSize(serverDb *db); +unsigned long long dbScan(serverDb *db, unsigned long long cursor, dictScanFunction *scan_cb, void *privdata); /* Set data type */ robj *setTypeCreate(sds value, size_t size_hint); @@ -3267,19 +3267,19 @@ long long getModuleNumericConfig(ModuleConfig *module_config); int setModuleNumericConfig(ModuleConfig *config, long long val, const char **err); /* db.c -- Keyspace access API */ -int removeExpire(redisDb *db, robj *key); -void deleteExpiredKeyAndPropagate(redisDb *db, robj *keyobj); -void propagateDeletion(redisDb *db, robj *key, int lazy); -int keyIsExpired(redisDb *db, robj *key); -long long getExpire(redisDb *db, robj *key); -void setExpire(client *c, redisDb *db, robj *key, long long when); +int removeExpire(serverDb *db, robj *key); +void deleteExpiredKeyAndPropagate(serverDb *db, robj *keyobj); +void propagateDeletion(serverDb *db, robj *key, int lazy); +int keyIsExpired(serverDb *db, robj *key); +long long getExpire(serverDb *db, robj *key); +void setExpire(client *c, serverDb *db, robj *key, long long when); int checkAlreadyExpired(long long when); -robj *lookupKeyRead(redisDb *db, robj *key); -robj *lookupKeyWrite(redisDb *db, robj *key); +robj *lookupKeyRead(serverDb *db, robj *key); +robj *lookupKeyWrite(serverDb *db, robj *key); robj *lookupKeyReadOrReply(client *c, robj *key, robj *reply); robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply); -robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags); -robj *lookupKeyWriteWithFlags(redisDb *db, robj *key, int flags); +robj *lookupKeyReadWithFlags(serverDb *db, robj *key, int flags); +robj *lookupKeyWriteWithFlags(serverDb *db, robj *key, int flags); robj *objectCommandLookup(client *c, robj *key); robj *objectCommandLookupOrReply(client *c, robj *key, robj *reply); int objectSetLRUOrLFU(robj *val, long long lfu_freq, long long lru_idle, @@ -3292,40 +3292,40 @@ int objectSetLRUOrLFU(robj *val, long long lfu_freq, long long lru_idle, #define LOOKUP_NOEXPIRE (1<<4) /* Avoid deleting lazy expired keys. */ #define LOOKUP_NOEFFECTS (LOOKUP_NONOTIFY | LOOKUP_NOSTATS | LOOKUP_NOTOUCH | LOOKUP_NOEXPIRE) /* Avoid any effects from fetching the key */ -void dbAdd(redisDb *db, robj *key, robj *val); -int dbAddRDBLoad(redisDb *db, sds key, robj *val); -void dbReplaceValue(redisDb *db, robj *key, robj *val); +void dbAdd(serverDb *db, robj *key, robj *val); +int dbAddRDBLoad(serverDb *db, sds key, robj *val); +void dbReplaceValue(serverDb *db, robj *key, robj *val); #define SETKEY_KEEPTTL 1 #define SETKEY_NO_SIGNAL 2 #define SETKEY_ALREADY_EXIST 4 #define SETKEY_DOESNT_EXIST 8 #define SETKEY_ADD_OR_UPDATE 16 /* Key most likely doesn't exists */ -void setKey(client *c, redisDb *db, robj *key, robj *val, int flags); -robj *dbRandomKey(redisDb *db); -int dbGenericDelete(redisDb *db, robj *key, int async, int flags); -int dbSyncDelete(redisDb *db, robj *key); -int dbDelete(redisDb *db, robj *key); -robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o); +void setKey(client *c, serverDb *db, robj *key, robj *val, int flags); +robj *dbRandomKey(serverDb *db); +int dbGenericDelete(serverDb *db, robj *key, int async, int flags); +int dbSyncDelete(serverDb *db, robj *key); +int dbDelete(serverDb *db, robj *key); +robj *dbUnshareStringValue(serverDb *db, robj *key, robj *o); #define EMPTYDB_NO_FLAGS 0 /* No flags. */ #define EMPTYDB_ASYNC (1<<0) /* Reclaim memory in another thread. */ #define EMPTYDB_NOFUNCTIONS (1<<1) /* Indicate not to flush the functions. */ long long emptyData(int dbnum, int flags, void(callback)(dict*)); -long long emptyDbStructure(redisDb *dbarray, int dbnum, int async, void(callback)(dict*)); +long long emptyDbStructure(serverDb *dbarray, int dbnum, int async, void(callback)(dict*)); void flushAllDataAndResetRDB(int flags); long long dbTotalServerKeyCount(void); -redisDb *initTempDb(void); -void discardTempDb(redisDb *tempDb, void(callback)(dict*)); +serverDb *initTempDb(void); +void discardTempDb(serverDb *tempDb, void(callback)(dict*)); int selectDb(client *c, int id); -void signalModifiedKey(client *c, redisDb *db, robj *key); +void signalModifiedKey(client *c, serverDb *db, robj *key); void signalFlushedDb(int dbid, int async); void scanGenericCommand(client *c, robj *o, unsigned long long cursor); int parseScanCursorOrReply(client *c, robj *o, unsigned long long *cursor); -int dbAsyncDelete(redisDb *db, robj *key); -void emptyDbAsync(redisDb *db); +int dbAsyncDelete(serverDb *db, robj *key); +void emptyDbAsync(serverDb *db); size_t lazyfreeGetPendingObjectsCount(void); size_t lazyfreeGetFreedObjectsCount(void); void lazyfreeResetStats(void); @@ -3423,15 +3423,15 @@ void replyToBlockedClientTimedOut(client *c); int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int unit); void disconnectAllBlockedClients(void); void handleClientsBlockedOnKeys(void); -void signalKeyAsReady(redisDb *db, robj *key, int type); +void signalKeyAsReady(serverDb *db, robj *key, int type); void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeout, int unblock_on_nokey); void blockClientShutdown(client *c); void blockPostponeClient(client *c); void blockForReplication(client *c, mstime_t timeout, long long offset, long numreplicas); void blockForAofFsync(client *c, mstime_t timeout, long long offset, int numlocal, long numreplicas); -void signalDeletedKeyAsReady(redisDb *db, robj *key, int type); +void signalDeletedKeyAsReady(serverDb *db, robj *key, int type); void updateStatsOnUnblock(client *c, long blocked_us, long reply_us, int had_errors); -void scanDatabaseForDeletedKeys(redisDb *emptied, redisDb *replaced_with); +void scanDatabaseForDeletedKeys(serverDb *emptied, serverDb *replaced_with); void totalNumberOfStatefulKeys(unsigned long *blocking_keys, unsigned long *blocking_keys_on_nokey, unsigned long *watched_keys); void blockedBeforeSleep(void); @@ -3444,7 +3444,7 @@ int clientsCronHandleTimeout(client *c, mstime_t now_ms); /* expire.c -- Handling of expired keys */ void activeExpireCycle(int type); void expireSlaveKeys(void); -void rememberSlaveKeyWithExpire(redisDb *db, robj *key); +void rememberSlaveKeyWithExpire(serverDb *db, robj *key); void flushSlaveKeysWithExpireList(void); size_t getSlaveKeyWithExpireCount(void); @@ -3771,7 +3771,7 @@ void debugDelay(int usec); void killIOThreads(void); void killThreads(void); void makeThreadKillable(void); -void swapMainDbWithTempDb(redisDb *tempDb); +void swapMainDbWithTempDb(serverDb *tempDb); sds getVersion(void); /* Use macro for checking log level to avoid evaluating arguments in cases log diff --git a/src/sort.c b/src/sort.c index bd1f10064d..86255ca265 100644 --- a/src/sort.c +++ b/src/sort.c @@ -59,7 +59,7 @@ redisSortOperation *createSortOperation(int type, robj *pattern) { * * The returned object will always have its refcount increased by 1 * when it is non-NULL. */ -robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) { +robj *lookupKeyByPattern(serverDb *db, robj *pattern, robj *subst) { char *p, *f, *k; sds spat, ssub; robj *keyobj, *fieldobj = NULL, *o; From cbbaf69d1de08c92c415a64e241ee8d79dac682d Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Wed, 3 Apr 2024 12:24:55 +0800 Subject: [PATCH 27/98] Remove unused REDIS_TEST_MAIN dead code in crc64.c (#160) We use `#ifdef SERVER_TEST` to run the relavent tests, we can now remove the dead code `#ifdef REDIS_TEST_MAIN`. Signed-off-by: Vitah Lin --- src/crc64.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/crc64.c b/src/crc64.c index f51d6819c6..0f71eea780 100644 --- a/src/crc64.c +++ b/src/crc64.c @@ -152,10 +152,3 @@ int crc64Test(int argc, char *argv[], int flags) { } #endif - -#ifdef REDIS_TEST_MAIN -int main(int argc, char *argv[]) { - return crc64Test(argc, argv); -} - -#endif From 730174445b72bb04c446c635d4c34041270b596b Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 11:26:20 +0700 Subject: [PATCH 28/98] Rename redisOpArray to serverOpArray (#157) A task of #144 Signed-off-by: 0del --- src/server.c | 8 ++++---- src/server.h | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/server.c b/src/server.c index 2b2dafd640..75ab399800 100644 --- a/src/server.c +++ b/src/server.c @@ -3117,7 +3117,7 @@ void resetErrorTableStats(void) { /* ========================== Redis OP Array API ============================ */ -int redisOpArrayAppend(redisOpArray *oa, int dbid, robj **argv, int argc, int target) { +int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int target) { redisOp *op; int prev_capacity = oa->capacity; @@ -3138,7 +3138,7 @@ int redisOpArrayAppend(redisOpArray *oa, int dbid, robj **argv, int argc, int ta return oa->numops; } -void redisOpArrayFree(redisOpArray *oa) { +void serverOpArrayFree(serverOpArray *oa) { while(oa->numops) { int j; redisOp *op; @@ -3322,7 +3322,7 @@ void alsoPropagate(int dbid, robj **argv, int argc, int target) { argvcopy[j] = argv[j]; incrRefCount(argv[j]); } - redisOpArrayAppend(&server.also_propagate,dbid,argvcopy,argc,target); + serverOpArrayAppend(&server.also_propagate,dbid,argvcopy,argc,target); } /* It is possible to call the function forceCommandPropagation() inside a @@ -3419,7 +3419,7 @@ static void propagatePendingCommands(void) { propagateNow(-1,&shared.exec,1,PROPAGATE_AOF|PROPAGATE_REPL); } - redisOpArrayFree(&server.also_propagate); + serverOpArrayFree(&server.also_propagate); } /* Performs operations that should be performed after an execution unit ends. diff --git a/src/server.h b/src/server.h index 1d911cc8d2..ec07b0a8ca 100644 --- a/src/server.h +++ b/src/server.h @@ -1385,14 +1385,14 @@ typedef struct redisOp { /* Defines an array of Redis operations. There is an API to add to this * structure in an easy way. * - * int redisOpArrayAppend(redisOpArray *oa, int dbid, robj **argv, int argc, int target); - * void redisOpArrayFree(redisOpArray *oa); + * int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int target); + * void serverOpArrayFree(serverOpArray *oa); */ -typedef struct redisOpArray { +typedef struct serverOpArray { redisOp *ops; int numops; int capacity; -} redisOpArray; +} serverOpArray; /* This structure is returned by the getMemoryOverheadData() function in * order to return memory overhead information. */ @@ -1844,7 +1844,7 @@ struct redisServer { int child_info_pipe[2]; /* Pipe used to write the child_info_data. */ int child_info_nread; /* Num of bytes of the last read from pipe */ /* Propagation of commands in AOF / replication */ - redisOpArray also_propagate; /* Additional command to propagate. */ + serverOpArray also_propagate; /* Additional command to propagate. */ int replication_allowed; /* Are we allowed to replicate? */ /* Logging */ char *logfile; /* Path of log file */ @@ -3065,7 +3065,7 @@ int incrCommandStatsOnError(struct redisCommand *cmd, int flags); void call(client *c, int flags); void alsoPropagate(int dbid, robj **argv, int argc, int target); void postExecutionUnitOperations(void); -void redisOpArrayFree(redisOpArray *oa); +void serverOpArrayFree(serverOpArray *oa); void forceCommandPropagation(client *c, int flags); void preventCommandPropagation(client *c); void preventCommandAOF(client *c); From 69d28be0f1939683d63546ef88ab949ee2e2847d Mon Sep 17 00:00:00 2001 From: Jun Luo Date: Wed, 3 Apr 2024 01:39:16 -0700 Subject: [PATCH 29/98] Rename redis to valkey in create-cluster script (#165) Otherwise currently create-cluster will not work (because there is no redis-*). Signed-off-by: Jun Luo --- utils/create-cluster/create-cluster | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/utils/create-cluster/create-cluster b/utils/create-cluster/create-cluster index dd20083313..f4f44871fc 100755 --- a/utils/create-cluster/create-cluster +++ b/utils/create-cluster/create-cluster @@ -28,7 +28,7 @@ then while [ $((PORT < ENDPORT)) != "0" ]; do PORT=$((PORT+1)) echo "Starting $PORT" - $BIN_PATH/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS} + $BIN_PATH/valkey-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS} done exit 0 fi @@ -44,7 +44,7 @@ then if [ "$2" == "-f" ]; then OPT_ARG="--cluster-yes" fi - $BIN_PATH/redis-cli --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG + $BIN_PATH/valkey-cli --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG exit 0 fi @@ -53,7 +53,7 @@ then while [ $((PORT < ENDPORT)) != "0" ]; do PORT=$((PORT+1)) echo "Stopping $PORT" - $BIN_PATH/redis-cli -p $PORT shutdown nosave + $BIN_PATH/valkey-cli -p $PORT shutdown nosave done exit 0 fi @@ -64,13 +64,13 @@ then while [ $((PORT < ENDPORT)) != "0" ]; do PORT=$((PORT+1)) echo "Stopping $PORT" - $BIN_PATH/redis-cli -p $PORT shutdown nosave + $BIN_PATH/valkey-cli -p $PORT shutdown nosave done PORT=$OLD_PORT while [ $((PORT < ENDPORT)) != "0" ]; do PORT=$((PORT+1)) echo "Starting $PORT" - $BIN_PATH/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS} + $BIN_PATH/valkey-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS} done exit 0 fi @@ -81,7 +81,7 @@ then while [ 1 ]; do clear date - $BIN_PATH/redis-cli -p $PORT cluster nodes | head -30 + $BIN_PATH/valkey-cli -p $PORT cluster nodes | head -30 sleep 1 done exit 0 @@ -105,7 +105,7 @@ if [ "$1" == "call" ] then while [ $((PORT < ENDPORT)) != "0" ]; do PORT=$((PORT+1)) - $BIN_PATH/redis-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9 + $BIN_PATH/valkey-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9 done exit 0 fi @@ -131,10 +131,10 @@ then fi echo "Usage: $0 [start|create|stop|restart|watch|tail|tailall|clean|clean-logs|call]" -echo "start -- Launch Redis Cluster instances." -echo "create [-f] -- Create a cluster using redis-cli --cluster create." -echo "stop -- Stop Redis Cluster instances." -echo "restart -- Restart Redis Cluster instances." +echo "start -- Launch Valkey Cluster instances." +echo "create [-f] -- Create a cluster using valkey-cli --cluster create." +echo "stop -- Stop Valkey Cluster instances." +echo "restart -- Restart Valkey Cluster instances." echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node." echo "tail -- Run tail -f of instance at base port + ID." echo "tailall -- Run tail -f for all the log files at once." From def09488aa2787038a2e8047a836dd2e76763a7c Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:07:28 +0700 Subject: [PATCH 30/98] Rename redis_member2struct ro server_member2struct (#166) part of #144 Signed-off-by: 0del --- src/multi.c | 4 ++-- src/server.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/multi.c b/src/multi.c index c3adf82b7a..cb082f91e1 100644 --- a/src/multi.c +++ b/src/multi.c @@ -390,7 +390,7 @@ void touchWatchedKey(serverDb *db, robj *key) { /* Check if we are already watching for this key */ listRewind(clients,&li); while((ln = listNext(&li))) { - watchedKey *wk = redis_member2struct(watchedKey, node, ln); + watchedKey *wk = server_member2struct(watchedKey, node, ln); client *c = wk->client; if (wk->expired) { @@ -443,7 +443,7 @@ void touchAllWatchedKeysInDb(serverDb *emptied, serverDb *replaced_with) { if (!clients) continue; listRewind(clients,&li); while((ln = listNext(&li))) { - watchedKey *wk = redis_member2struct(watchedKey, node, ln); + watchedKey *wk = server_member2struct(watchedKey, node, ln); if (wk->expired) { if (!replaced_with || !dbFind(replaced_with, key->ptr)) { /* Expired key now deleted. No logical change. Clear the diff --git a/src/server.h b/src/server.h index ec07b0a8ca..f3613f8778 100644 --- a/src/server.h +++ b/src/server.h @@ -103,7 +103,7 @@ struct hdr_histogram; #define max(a, b) ((a) > (b) ? (a) : (b)) /* Get the pointer of the outer struct from a member address */ -#define redis_member2struct(struct_name, member_name, member_addr) \ +#define server_member2struct(struct_name, member_name, member_addr) \ ((struct_name *)((char*)member_addr - offsetof(struct_name, member_name))) /* Error codes */ From 99bdcc0ed0df95843de02422c98b76e2b72c6e98 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:29:59 +0700 Subject: [PATCH 31/98] Rename redisCommandGroup to serverCommandGroup (#172) Part of issue #144 Signed-off-by: 0del --- src/commands.def | 2 +- src/server.h | 4 ++-- utils/generate-command-code.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands.def b/src/commands.def index 2d68e36d77..fd94d22ebc 100644 --- a/src/commands.def +++ b/src/commands.def @@ -5,7 +5,7 @@ * the fantastic * Redis Command Table! */ -/* Must match redisCommandGroup */ +/* Must match serverCommandGroup */ const char *COMMAND_GROUP_STR[] = { "generic", "string", diff --git a/src/server.h b/src/server.h index f3613f8778..6e99d2903e 100644 --- a/src/server.h +++ b/src/server.h @@ -2235,7 +2235,7 @@ typedef enum { COMMAND_GROUP_STREAM, COMMAND_GROUP_BITMAP, COMMAND_GROUP_MODULE, -} redisCommandGroup; +} serverCommandGroup; typedef void redisCommandProc(client *c); typedef int redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); @@ -2343,7 +2343,7 @@ struct redisCommand { int doc_flags; /* Flags for documentation (see CMD_DOC_*). */ const char *replaced_by; /* In case the command is deprecated, this is the successor command. */ const char *deprecated_since; /* In case the command is deprecated, when did it happen? */ - redisCommandGroup group; /* Command group */ + serverCommandGroup group; /* Command group */ commandHistory *history; /* History of the command */ int num_history; const char **tips; /* An array of strings that are meant to be tips for clients/proxies regarding this command */ diff --git a/utils/generate-command-code.py b/utils/generate-command-code.py index 2d7cc5b0d2..236bf40cfa 100755 --- a/utils/generate-command-code.py +++ b/utils/generate-command-code.py @@ -578,7 +578,7 @@ def create_command(name, desc): * the fantastic * Redis Command Table! */ -/* Must match redisCommandGroup */ +/* Must match serverCommandGroup */ const char *COMMAND_GROUP_STR[] = { "generic", "string", From a236fc8ef0cd9094adda29b7a8d4859c2e36ee77 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:33:33 +0700 Subject: [PATCH 32/98] Rename redisCommandProc, redisGetKeysProc to server prefix (#173) Part of #144 Signed-off-by: 0del --- src/db.c | 2 +- src/networking.c | 2 +- src/server.h | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/db.c b/src/db.c index e54d4e471e..e5de136063 100644 --- a/src/db.c +++ b/src/db.c @@ -2149,7 +2149,7 @@ int doesCommandHaveKeys(struct redisCommand *cmd) { /* A simplified channel spec table that contains all of the redis commands * and which channels they have and how they are accessed. */ typedef struct ChannelSpecs { - redisCommandProc *proc; /* Command procedure to match against */ + serverCommandProc *proc; /* Command procedure to match against */ uint64_t flags; /* CMD_CHANNEL_* flags for this command */ int start; /* The initial position of the first channel */ int count; /* The number of channels, or -1 if all remaining diff --git a/src/networking.c b/src/networking.c index 5d0167fc18..c4414f5a49 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2075,7 +2075,7 @@ int handleClientsWithPendingWrites(void) { /* resetClient prepare the client to process the next command */ void resetClient(client *c) { - redisCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL; + serverCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL; freeClientArgv(c); c->cur_script = NULL; diff --git a/src/server.h b/src/server.h index 6e99d2903e..e78d5a0f64 100644 --- a/src/server.h +++ b/src/server.h @@ -2237,8 +2237,8 @@ typedef enum { COMMAND_GROUP_MODULE, } serverCommandGroup; -typedef void redisCommandProc(client *c); -typedef int redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); +typedef void serverCommandProc(client *c); +typedef int serverGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); /* Redis command structure. * @@ -2348,7 +2348,7 @@ struct redisCommand { int num_history; const char **tips; /* An array of strings that are meant to be tips for clients/proxies regarding this command */ int num_tips; - redisCommandProc *proc; /* Command implementation */ + serverCommandProc *proc; /* Command implementation */ int arity; /* Number of arguments, it is possible to use -N to say >= N */ uint64_t flags; /* Command flags, see CMD_*. */ uint64_t acl_categories; /* ACl categories, see ACL_CATEGORY_*. */ @@ -2356,7 +2356,7 @@ struct redisCommand { int key_specs_num; /* Use a function to determine keys arguments in a command line. * Used for Redis Cluster redirect (may be NULL) */ - redisGetKeysProc *getkeys_proc; + serverGetKeysProc *getkeys_proc; int num_args; /* Length of args array. */ /* Array of subcommands (may be NULL) */ struct redisCommand *subcommands; From b19ebaf551de6b8b4aa35e1d054aece8dd8b900f Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:54:33 +0700 Subject: [PATCH 33/98] Rename redisCommand to serverCommand (#174) Part of #144 --------- Signed-off-by: 0del --- src/acl.c | 32 ++++++++-------- src/aof.c | 2 +- src/cluster.c | 4 +- src/cluster.h | 2 +- src/commands.c | 2 +- src/config.c | 2 +- src/db.c | 54 +++++++++++++------------- src/latency.c | 8 ++-- src/module.c | 36 +++++++++--------- src/multi.c | 2 +- src/networking.c | 2 +- src/script.c | 4 +- src/script_lua.c | 2 +- src/server.c | 90 ++++++++++++++++++++++---------------------- src/server.h | 98 ++++++++++++++++++++++++------------------------ 15 files changed, 170 insertions(+), 170 deletions(-) diff --git a/src/acl.c b/src/acl.c index 81f8b38499..244e7f0826 100644 --- a/src/acl.c +++ b/src/acl.c @@ -649,7 +649,7 @@ void ACLUpdateCommandRules(aclSelector *selector, const char *rule, int allow) { /* This function is used to allow/block a specific command. * Allowing/blocking a container command also applies for its subcommands */ -void ACLChangeSelectorPerm(aclSelector *selector, struct redisCommand *cmd, int allow) { +void ACLChangeSelectorPerm(aclSelector *selector, struct serverCommand *cmd, int allow) { unsigned long id = cmd->id; ACLSetSelectorCommandBit(selector,id,allow); ACLResetFirstArgsForCommand(selector,id); @@ -657,7 +657,7 @@ void ACLChangeSelectorPerm(aclSelector *selector, struct redisCommand *cmd, int dictEntry *de; dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict); while((de = dictNext(di)) != NULL) { - struct redisCommand *sub = (struct redisCommand *)dictGetVal(de); + struct serverCommand *sub = (struct serverCommand *)dictGetVal(de); ACLSetSelectorCommandBit(selector,sub->id,allow); } dictReleaseIterator(di); @@ -674,7 +674,7 @@ void ACLSetSelectorCommandBitsForCategory(dict *commands, aclSelector *selector, dictIterator *di = dictGetIterator(commands); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); if (cmd->acl_categories & cflag) { ACLChangeSelectorPerm(selector,cmd,value); } @@ -738,7 +738,7 @@ void ACLCountCategoryBitsForCommands(dict *commands, aclSelector *selector, unsi dictIterator *di = dictGetIterator(commands); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); if (cmd->acl_categories & cflag) { if (ACLGetSelectorCommandBit(selector,cmd->id)) (*on)++; @@ -922,8 +922,8 @@ robj *ACLDescribeUser(user *u) { /* Get a command from the original command table, that is not affected * by the command renaming operations: we base all the ACL work from that * table, so that ACLs are valid regardless of command renaming. */ -struct redisCommand *ACLLookupCommand(const char *name) { - struct redisCommand *cmd; +struct serverCommand *ACLLookupCommand(const char *name) { + struct serverCommand *cmd; sds sdsname = sdsnew(name); cmd = lookupCommandBySdsLogic(server.orig_commands,sdsname); sdsfree(sdsname); @@ -1140,7 +1140,7 @@ int ACLSetSelector(aclSelector *selector, const char* op, size_t oplen) { selector->flags &= ~SELECTOR_FLAG_ALLCHANNELS; } else if (op[0] == '+' && op[1] != '@') { if (strrchr(op,'|') == NULL) { - struct redisCommand *cmd = ACLLookupCommand(op+1); + struct serverCommand *cmd = ACLLookupCommand(op+1); if (cmd == NULL) { errno = ENOENT; return C_ERR; @@ -1154,7 +1154,7 @@ int ACLSetSelector(aclSelector *selector, const char* op, size_t oplen) { sub[0] = '\0'; sub++; - struct redisCommand *cmd = ACLLookupCommand(copy); + struct serverCommand *cmd = ACLLookupCommand(copy); /* Check if the command exists. We can't check the * first-arg to see if it is valid. */ @@ -1203,7 +1203,7 @@ int ACLSetSelector(aclSelector *selector, const char* op, size_t oplen) { zfree(copy); } } else if (op[0] == '-' && op[1] != '@') { - struct redisCommand *cmd = ACLLookupCommand(op+1); + struct serverCommand *cmd = ACLLookupCommand(op+1); if (cmd == NULL) { errno = ENOENT; return C_ERR; @@ -1699,7 +1699,7 @@ void cleanupACLKeyResultCache(aclKeyResultCache *cache) { * command cannot be executed because the selector is not allowed to run such * command, the second and third if the command is denied because the selector is trying * to access a key or channel that are not among the specified patterns. */ -static int ACLSelectorCheckCmd(aclSelector *selector, struct redisCommand *cmd, robj **argv, int argc, int *keyidxptr, aclKeyResultCache *cache) { +static int ACLSelectorCheckCmd(aclSelector *selector, struct serverCommand *cmd, robj **argv, int argc, int *keyidxptr, aclKeyResultCache *cache) { uint64_t id = cmd->id; int ret; if (!(selector->flags & SELECTOR_FLAG_ALLCOMMANDS) && !(cmd->flags & CMD_NO_AUTH)) { @@ -1799,7 +1799,7 @@ int ACLUserCheckKeyPerm(user *u, const char *key, int keylen, int flags) { * granted in addition to the access required by the command. Returns 1 * if the user has access or 0 otherwise. */ -int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct redisCommand *cmd, robj **argv, int argc, int flags) { +int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct serverCommand *cmd, robj **argv, int argc, int flags) { listIter li; listNode *ln; int local_idxptr; @@ -1858,7 +1858,7 @@ int ACLUserCheckChannelPerm(user *u, sds channel, int is_pattern) { * If the command fails an ACL check, idxptr will be to set to the first argv entry that * causes the failure, either 0 if the command itself fails or the idx of the key/channel * that causes the failure */ -int ACLCheckAllUserCommandPerm(user *u, struct redisCommand *cmd, robj **argv, int argc, int *idxptr) { +int ACLCheckAllUserCommandPerm(user *u, struct serverCommand *cmd, robj **argv, int argc, int *idxptr) { listIter li; listNode *ln; @@ -2754,7 +2754,7 @@ void addACLLogEntry(client *c, int reason, int context, int argpos, sds username } } -sds getAclErrorMessage(int acl_res, user *user, struct redisCommand *cmd, sds errored_val, int verbose) { +sds getAclErrorMessage(int acl_res, user *user, struct serverCommand *cmd, sds errored_val, int verbose) { switch (acl_res) { case ACL_DENIED_CMD: return sdscatfmt(sdsempty(), "User %S has no permissions to run " @@ -2787,7 +2787,7 @@ void aclCatWithFlags(client *c, dict *commands, uint64_t cflag, int *arraylen) { dictIterator *di = dictGetIterator(commands); while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); if (cmd->flags & CMD_MODULE) continue; if (cmd->acl_categories & cflag) { addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); @@ -3127,7 +3127,7 @@ void aclCommand(client *c) { addReplyLongLong(c, le->ctime); } } else if (!strcasecmp(sub,"dryrun") && c->argc >= 4) { - struct redisCommand *cmd; + struct serverCommand *cmd; user *u = ACLGetUserByName(c->argv[2]->ptr,sdslen(c->argv[2]->ptr)); if (u == NULL) { addReplyErrorFormat(c, "User '%s' not found", (char *)c->argv[2]->ptr); @@ -3191,7 +3191,7 @@ NULL } } -void addReplyCommandCategories(client *c, struct redisCommand *cmd) { +void addReplyCommandCategories(client *c, struct serverCommand *cmd) { int flagcount = 0; void *flaglen = addReplyDeferredLen(c); for (int j = 0; ACLCommandCategories[j].flag != 0; j++) { diff --git a/src/aof.c b/src/aof.c index cfa3df83a9..cb9c431364 100644 --- a/src/aof.c +++ b/src/aof.c @@ -1481,7 +1481,7 @@ int loadSingleAppendOnlyFile(char *filename) { robj **argv; char buf[AOF_ANNOTATION_LINE_MAX_LEN]; sds argsds; - struct redisCommand *cmd; + struct serverCommand *cmd; /* Serve the clients from time to time */ if (!(loops++ % 1024)) { diff --git a/src/cluster.c b/src/cluster.c index 60f5cc3b4e..ca002a17bb 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -990,7 +990,7 @@ void clusterCommand(client *c) { * * CLUSTER_REDIR_DOWN_STATE and CLUSTER_REDIR_DOWN_RO_STATE if the cluster is * down but the user attempts to execute a command that addresses one or more keys. */ -clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) { +clusterNode *getNodeByQuery(client *c, struct serverCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) { clusterNode *myself = getMyClusterNode(); clusterNode *n = NULL; robj *firstkey = NULL; @@ -1039,7 +1039,7 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in /* Check that all the keys are in the same hash slot, and obtain this * slot and the node associated. */ for (i = 0; i < ms->count; i++) { - struct redisCommand *mcmd; + struct serverCommand *mcmd; robj **margv; int margc, numkeys, j; keyReference *keyindex; diff --git a/src/cluster.h b/src/cluster.h index f21f1e9c16..463b4940d9 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -105,7 +105,7 @@ long long clusterNodeReplOffset(clusterNode *node); clusterNode *clusterLookupNode(const char *name, int length); /* functions with shared implementations */ -clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask); +clusterNode *getNodeByQuery(client *c, struct serverCommand *cmd, robj **argv, int argc, int *hashslot, int *ask); int clusterRedirectBlockedClientIfNeeded(client *c); void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code); void migrateCloseTimedoutSockets(void); diff --git a/src/commands.c b/src/commands.c index 5dcfe19738..6d8e5696f3 100644 --- a/src/commands.c +++ b/src/commands.c @@ -3,7 +3,7 @@ #define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,complexity,since,doc_flags,replaced,deprecated,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs #define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,key_spec_index,token,summary,since,flags,deprecated_since,numsubargs -#define COMMAND_STRUCT redisCommand +#define COMMAND_STRUCT serverCommand #define COMMAND_ARG redisCommandArg #ifdef LOG_REQ_RES diff --git a/src/config.c b/src/config.c index 14d45b6721..731a3304c7 100644 --- a/src/config.c +++ b/src/config.c @@ -537,7 +537,7 @@ void loadServerConfigFromString(char *config) { if (!strcasecmp(argv[0],"include") && argc == 2) { loadServerConfig(argv[1], 0, NULL); } else if (!strcasecmp(argv[0],"rename-command") && argc == 3) { - struct redisCommand *cmd = lookupCommandBySds(argv[1]); + struct serverCommand *cmd = lookupCommandBySds(argv[1]); int retval; if (!cmd) { diff --git a/src/db.c b/src/db.c index e5de136063..f58bde45df 100644 --- a/src/db.c +++ b/src/db.c @@ -1970,7 +1970,7 @@ keyReference *getKeysPrepareResult(getKeysResult *result, int numkeys) { /* Returns a bitmask with all the flags found in any of the key specs of the command. * The 'inv' argument means we'll return a mask with all flags that are missing in at least one spec. */ -int64_t getAllKeySpecsFlags(struct redisCommand *cmd, int inv) { +int64_t getAllKeySpecsFlags(struct serverCommand *cmd, int inv) { int64_t flags = 0; for (int j = 0; j < cmd->key_specs_num; j++) { keySpec *spec = cmd->key_specs + j; @@ -1986,7 +1986,7 @@ int64_t getAllKeySpecsFlags(struct redisCommand *cmd, int inv) { * GET_KEYSPEC_RETURN_PARTIAL: Skips invalid and incomplete keyspecs but returns the keys * found in other valid keyspecs. */ -int getKeysUsingKeySpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) { +int getKeysUsingKeySpecs(struct serverCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) { int j, i, last, first, step; keyReference *keys; serverAssert(result->numkeys == 0); /* caller should initialize or reset it */ @@ -2111,9 +2111,9 @@ int getKeysUsingKeySpecs(struct redisCommand *cmd, robj **argv, int argc, int se * Along with the position, this command also returns the flags that are * associated with how Redis will access the key. * - * 'cmd' must be point to the corresponding entry into the redisCommand + * 'cmd' must be point to the corresponding entry into the serverCommand * table, according to the command name in argv[0]. */ -int getKeysFromCommandWithSpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) { +int getKeysFromCommandWithSpecs(struct serverCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) { /* The command has at least one key-spec not marked as NOT_KEY */ int has_keyspec = (getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY); /* The command has at least one key-spec marked as VARIABLE_FLAGS */ @@ -2140,7 +2140,7 @@ int getKeysFromCommandWithSpecs(struct redisCommand *cmd, robj **argv, int argc, } /* This function returns a sanity check if the command may have keys. */ -int doesCommandHaveKeys(struct redisCommand *cmd) { +int doesCommandHaveKeys(struct serverCommand *cmd) { return cmd->getkeys_proc || /* has getkeys_proc (non modules) */ (cmd->flags & CMD_MODULE_GETKEYS) || /* module with GETKEYS */ (getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY); /* has at least one key-spec not marked as NOT_KEY */ @@ -2170,7 +2170,7 @@ ChannelSpecs commands_with_channels[] = { /* Returns 1 if the command may access any channels matched by the flags * argument. */ -int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags) { +int doesCommandHaveChannelsWithFlags(struct serverCommand *cmd, int flags) { /* If a module declares get channels, we are just going to assume * has channels. This API is allowed to return false positives. */ if (cmd->flags & CMD_MODULE_GETCHANNELS) { @@ -2195,9 +2195,9 @@ int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags) { * Along with the position, this command also returns the flags that are * associated with how Redis will access the channel. * - * 'cmd' must be point to the corresponding entry into the redisCommand + * 'cmd' must be point to the corresponding entry into the serverCommand * table, according to the command name in argv[0]. */ -int getChannelsFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int getChannelsFromCommand(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { keyReference *keys; /* If a module declares get channels, use that. */ if (cmd->flags & CMD_MODULE_GETCHANNELS) { @@ -2232,7 +2232,7 @@ int getChannelsFromCommand(struct redisCommand *cmd, robj **argv, int argc, getK * * NOTE: This function does not guarantee populating the flags for * the keys, in order to get flags you should use getKeysUsingKeySpecs. */ -int getKeysUsingLegacyRangeSpec(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int getKeysUsingLegacyRangeSpec(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { int j, i = 0, last, first, step; keyReference *keys; UNUSED(argv); @@ -2282,12 +2282,12 @@ int getKeysUsingLegacyRangeSpec(struct redisCommand *cmd, robj **argv, int argc, * so the actual return value is a heap allocated array of integers. The * length of the array is returned by reference into *numkeys. * - * 'cmd' must be point to the corresponding entry into the redisCommand + * 'cmd' must be point to the corresponding entry into the serverCommand * table, according to the command name in argv[0]. * * This function uses the command table if a command-specific helper function * is not required, otherwise it calls the command-specific function. */ -int getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int getKeysFromCommand(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { if (cmd->flags & CMD_MODULE_GETKEYS) { return moduleGetCommandKeysViaAPI(cmd,argv,argc,result); } else if (cmd->getkeys_proc) { @@ -2346,47 +2346,47 @@ int genericGetKeys(int storeKeyOfs, int keyCountOfs, int firstKeyOfs, int keySte return result->numkeys; } -int sintercardGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int sintercardGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 1, 2, 1, argv, argc, result); } -int zunionInterDiffStoreGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int zunionInterDiffStoreGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(1, 2, 3, 1, argv, argc, result); } -int zunionInterDiffGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int zunionInterDiffGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 1, 2, 1, argv, argc, result); } -int evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int evalGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 2, 3, 1, argv, argc, result); } -int functionGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int functionGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 2, 3, 1, argv, argc, result); } -int lmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int lmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 1, 2, 1, argv, argc, result); } -int blmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int blmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 2, 3, 1, argv, argc, result); } -int zmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int zmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 1, 2, 1, argv, argc, result); } -int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int bzmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { UNUSED(cmd); return genericGetKeys(0, 2, 3, 1, argv, argc, result); } @@ -2401,7 +2401,7 @@ int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult * implementation to fetch the keys. * * This command declares incomplete keys, so the flags are correctly set for this function */ -int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int sortROGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { keyReference *keys; UNUSED(cmd); UNUSED(argv); @@ -2423,7 +2423,7 @@ int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult * correctly identify keys in the "STORE" option. * * This command declares incomplete keys, so the flags are correctly set for this function */ -int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int sortGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { int i, j, num, found_store = 0; keyReference *keys; UNUSED(cmd); @@ -2468,7 +2468,7 @@ int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult * } /* This command declares incomplete keys, so the flags are correctly set for this function */ -int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int migrateGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { int i, j, num, first; keyReference *keys; UNUSED(cmd); @@ -2525,7 +2525,7 @@ int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResul * GEORADIUSBYMEMBER key member radius unit ... options ... * * This command has a fully defined keyspec, so returning flags isn't needed. */ -int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int georadiusGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { int i, num; keyReference *keys; UNUSED(cmd); @@ -2566,7 +2566,7 @@ int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysRes * STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N * * This command has a fully defined keyspec, so returning flags isn't needed. */ -int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int xreadGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { int i, num = 0; keyReference *keys; UNUSED(cmd); @@ -2614,7 +2614,7 @@ int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult /* Helper function to extract keys from the SET command, which may have * a read flag if the GET argument is passed in. */ -int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int setGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { keyReference *keys; UNUSED(cmd); @@ -2639,7 +2639,7 @@ int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *r /* Helper function to extract keys from the BITFIELD command, which may be * read-only if the BITFIELD GET subcommand is used. */ -int bitfieldGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int bitfieldGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { keyReference *keys; int readonly = 1; UNUSED(cmd); diff --git a/src/latency.c b/src/latency.c index 4805508e75..b5ec6e3823 100644 --- a/src/latency.c +++ b/src/latency.c @@ -493,10 +493,10 @@ void fillCommandCDF(client *c, struct hdr_histogram* histogram) { void latencyAllCommandsFillCDF(client *c, dict *commands, int *command_with_data) { dictIterator *di = dictGetSafeIterator(commands); dictEntry *de; - struct redisCommand *cmd; + struct serverCommand *cmd; while((de = dictNext(di)) != NULL) { - cmd = (struct redisCommand *) dictGetVal(de); + cmd = (struct serverCommand *) dictGetVal(de); if (cmd->latency_histogram) { addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); fillCommandCDF(c, cmd->latency_histogram); @@ -516,7 +516,7 @@ void latencySpecificCommandsFillCDF(client *c) { void *replylen = addReplyDeferredLen(c); int command_with_data = 0; for (int j = 2; j < c->argc; j++){ - struct redisCommand *cmd = lookupCommandBySds(c->argv[j]->ptr); + struct serverCommand *cmd = lookupCommandBySds(c->argv[j]->ptr); /* If the command does not exist we skip the reply */ if (cmd == NULL) { continue; @@ -533,7 +533,7 @@ void latencySpecificCommandsFillCDF(client *c) { dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict); while ((de = dictNext(di)) != NULL) { - struct redisCommand *sub = dictGetVal(de); + struct serverCommand *sub = dictGetVal(de); if (sub->latency_histogram) { addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname)); fillCommandCDF(c, sub->latency_histogram); diff --git a/src/module.c b/src/module.c index f06952df74..1545e6d9c4 100644 --- a/src/module.c +++ b/src/module.c @@ -238,7 +238,7 @@ typedef void (*RedisModuleDisconnectFunc) (RedisModuleCtx *ctx, struct RedisModu struct RedisModuleCommand { struct RedisModule *module; RedisModuleCmdFunc func; - struct redisCommand *rediscmd; + struct serverCommand *rediscmd; }; typedef struct RedisModuleCommand RedisModuleCommand; @@ -959,7 +959,7 @@ void RedisModuleCommandDispatcher(client *c) { * In order to accomplish its work, the module command is called, flagging * the context in a way that the command can recognize this is a special * "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */ -int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { RedisModuleCommand *cp = cmd->module_cmd; RedisModuleCtx ctx; moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_KEYS_POS_REQUEST); @@ -979,7 +979,7 @@ int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, /* This function returns the list of channels, with the same interface as * moduleGetCommandKeysViaAPI, for modules that declare "getchannels-api" * during registration. Unlike keys, this is the only way to declare channels. */ -int moduleGetCommandChannelsViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { +int moduleGetCommandChannelsViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { RedisModuleCommand *cp = cmd->module_cmd; RedisModuleCtx ctx; moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_CHANNELS_POS_REQUEST); @@ -1301,7 +1301,7 @@ int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc c * Function will take the ownership of both 'declared_name' and 'fullname' SDS. */ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) { - struct redisCommand *rediscmd; + struct serverCommand *rediscmd; RedisModuleCommand *cp; /* Create a command "proxy", which is a structure that is referenced @@ -1352,7 +1352,7 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * * The command doesn't belong to the calling module */ RedisModuleCommand *RM_GetCommand(RedisModuleCtx *ctx, const char *name) { - struct redisCommand *cmd = lookupCommandByCString(name); + struct serverCommand *cmd = lookupCommandByCString(name); if (!cmd || !(cmd->flags & CMD_MODULE)) return NULL; @@ -1399,7 +1399,7 @@ int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModul if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled) return REDISMODULE_ERR; - struct redisCommand *parent_cmd = parent->rediscmd; + struct serverCommand *parent_cmd = parent->rediscmd; if (parent_cmd->parent) return REDISMODULE_ERR; /* We don't allow more than one level of subcommands */ @@ -1553,7 +1553,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags if (!command || !command->module || !command->module->onload) return REDISMODULE_ERR; int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0; if (categories_flags == -1) return REDISMODULE_ERR; - struct redisCommand *rcmd = command->rediscmd; + struct serverCommand *rcmd = command->rediscmd; rcmd->acl_categories = categories_flags; /* ACL categories flags for module command */ command->module->num_commands_with_acl_categories++; return REDISMODULE_OK; @@ -1866,7 +1866,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo return REDISMODULE_ERR; } - struct redisCommand *cmd = command->rediscmd; + struct serverCommand *cmd = command->rediscmd; /* Check if any info has already been set. Overwriting info involves freeing * the old info, which is not implemented. */ @@ -2038,7 +2038,7 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { moduleCmdKeySpecAt(version, info->key_specs, j); if (j >= INT_MAX) { serverLog(LL_WARNING, "Invalid command info: Too many key specs"); - return 0; /* redisCommand.key_specs_num is an int. */ + return 0; /* serverCommand.key_specs_num is an int. */ } /* Flags. Exactly one flag in a group is set if and only if the @@ -2256,7 +2256,7 @@ void *moduleGetHandleByName(char *modulename) { } /* Returns 1 if `cmd` is a command of the module `modulename`. 0 otherwise. */ -int moduleIsModuleCommand(void *module_handle, struct redisCommand *cmd) { +int moduleIsModuleCommand(void *module_handle, struct serverCommand *cmd) { if (cmd->proc != RedisModuleCommandDispatcher) return 0; if (module_handle == NULL) @@ -3578,7 +3578,7 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { * The command returns REDISMODULE_ERR if the format specifiers are invalid * or the command name does not belong to a known command. */ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { - struct redisCommand *cmd; + struct serverCommand *cmd; robj **argv = NULL; int argc = 0, flags = 0, j; va_list ap; @@ -6773,7 +6773,7 @@ const char *moduleTypeModuleName(moduleType *mt) { } /* Return the module name from a module command */ -const char *moduleNameFromCommand(struct redisCommand *cmd) { +const char *moduleNameFromCommand(struct serverCommand *cmd) { serverAssert(cmd->proc == RedisModuleCommandDispatcher); RedisModuleCommand *cp = cmd->module_cmd; @@ -7528,7 +7528,7 @@ int RM_GetDbIdFromDigest(RedisModuleDigest *dig) { * handling is performed by Redis itself. */ void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { if (io->error) return; - struct redisCommand *cmd; + struct serverCommand *cmd; robj **argv = NULL; int argc = 0, flags = 0, j; va_list ap; @@ -9722,7 +9722,7 @@ RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) { */ int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **argv, int argc) { int keyidxptr; - struct redisCommand *cmd; + struct serverCommand *cmd; /* Find command */ if ((cmd = lookupCommand(argv, argc)) == NULL) { @@ -12154,7 +12154,7 @@ void moduleFreeArgs(struct redisCommandArg *args, int num_args) { * Note that caller needs to handle the deletion of the command table dict, * and after that needs to free the command->fullname and the command itself. */ -int moduleFreeCommand(struct RedisModule *module, struct redisCommand *cmd) { +int moduleFreeCommand(struct RedisModule *module, struct serverCommand *cmd) { if (cmd->proc != RedisModuleCommandDispatcher) return C_ERR; @@ -12193,7 +12193,7 @@ int moduleFreeCommand(struct RedisModule *module, struct redisCommand *cmd) { dictEntry *de; dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict); while ((de = dictNext(di)) != NULL) { - struct redisCommand *sub = dictGetVal(de); + struct serverCommand *sub = dictGetVal(de); if (moduleFreeCommand(module, sub) != C_OK) continue; serverAssert(dictDelete(cmd->subcommands_dict, sub->declared_name) == DICT_OK); @@ -12213,7 +12213,7 @@ void moduleUnregisterCommands(struct RedisModule *module) { dictIterator *di = dictGetSafeIterator(server.commands); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); if (moduleFreeCommand(module, cmd) != C_OK) continue; serverAssert(dictDelete(server.commands, cmd->fullname) == DICT_OK); @@ -13363,7 +13363,7 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val */ int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) { UNUSED(ctx); - struct redisCommand *cmd; + struct serverCommand *cmd; int *res = NULL; /* Find command */ diff --git a/src/multi.c b/src/multi.c index cb082f91e1..e8adeccde4 100644 --- a/src/multi.c +++ b/src/multi.c @@ -149,7 +149,7 @@ void execCommand(client *c) { int j; robj **orig_argv; int orig_argc, orig_argv_len; - struct redisCommand *orig_cmd; + struct serverCommand *orig_cmd; if (!(c->flags & CLIENT_MULTI)) { addReplyError(c,"EXEC without MULTI"); diff --git a/src/networking.c b/src/networking.c index c4414f5a49..90825ca284 100644 --- a/src/networking.c +++ b/src/networking.c @@ -385,7 +385,7 @@ void _addReplyProtoToList(client *c, list *reply_list, const char *s, size_t len /* The subscribe / unsubscribe command family has a push as a reply, * or in other words, it responds with a push (or several of them * depending on how many arguments it got), and has no reply. */ -int cmdHasPushAsReply(struct redisCommand *cmd) { +int cmdHasPushAsReply(struct serverCommand *cmd) { if (!cmd) return 0; return cmd->proc == subscribeCommand || cmd->proc == unsubscribeCommand || cmd->proc == psubscribeCommand || cmd->proc == punsubscribeCommand || diff --git a/src/script.c b/src/script.c index 4a6461c0b4..fd7c616717 100644 --- a/src/script.c +++ b/src/script.c @@ -319,7 +319,7 @@ void scriptKill(client *c, int is_eval) { addReply(c, shared.ok); } -static int scriptVerifyCommandArity(struct redisCommand *cmd, int argc, sds *err) { +static int scriptVerifyCommandArity(struct serverCommand *cmd, int argc, sds *err) { if (!cmd || ((cmd->arity > 0 && cmd->arity != argc) || (argc < -cmd->arity))) { if (cmd) *err = sdsnew("Wrong number of args calling Redis command from script"); @@ -541,7 +541,7 @@ void scriptCall(scriptRunCtx *run_ctx, sds *err) { /* Process module hooks */ moduleCallCommandFilters(c); - struct redisCommand *cmd = lookupCommand(c->argv, c->argc); + struct serverCommand *cmd = lookupCommand(c->argv, c->argc); c->cmd = c->lastcmd = c->realcmd = cmd; if (scriptVerifyCommandArity(cmd, c->argc, err) != C_OK) { goto error; diff --git a/src/script_lua.c b/src/script_lua.c index 3587bb2771..1126422582 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -1143,7 +1143,7 @@ static int luaRedisAclCheckCmdPermissionsCommand(lua_State *lua) { if (argv == NULL) return luaError(lua); /* Find command */ - struct redisCommand *cmd; + struct serverCommand *cmd; if ((cmd = lookupCommand(argv, argc)) == NULL) { luaPushError(lua, "Invalid command passed to redis.acl_check_cmd()"); raise_error = 1; diff --git a/src/server.c b/src/server.c index 75ab399800..53c2b57a21 100644 --- a/src/server.c +++ b/src/server.c @@ -2906,7 +2906,7 @@ void InitServerLast(void) { * because anyway the legacy (first,last,step) spec is to be deprecated * and one should use the new key specs scheme. */ -void populateCommandLegacyRangeSpec(struct redisCommand *c) { +void populateCommandLegacyRangeSpec(struct serverCommand *c) { memset(&c->legacy_range_key_spec, 0, sizeof(c->legacy_range_key_spec)); /* Set the movablekeys flag if we have a GETKEYS flag for modules. @@ -2985,7 +2985,7 @@ sds catSubCommandFullname(const char *parent_name, const char *sub_name) { return sdscatfmt(sdsempty(), "%s|%s", parent_name, sub_name); } -void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subcommand, const char *declared_name) { +void commandAddSubcommand(struct serverCommand *parent, struct serverCommand *subcommand, const char *declared_name) { if (!parent->subcommands_dict) parent->subcommands_dict = dictCreate(&commandTableDictType); @@ -2996,8 +2996,8 @@ void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subc } /* Set implicit ACl categories (see comment above the definition of - * struct redisCommand). */ -void setImplicitACLCategories(struct redisCommand *c) { + * struct serverCommand). */ +void setImplicitACLCategories(struct serverCommand *c) { if (c->flags & CMD_WRITE) c->acl_categories |= ACL_CATEGORY_WRITE; /* Exclude scripting commands from the RO category. */ @@ -3021,7 +3021,7 @@ void setImplicitACLCategories(struct redisCommand *c) { * * On success, the function return C_OK. Otherwise C_ERR is returned and we won't * add this command in the commands dict. */ -int populateCommandStructure(struct redisCommand *c) { +int populateCommandStructure(struct serverCommand *c) { /* If the command marks with CMD_SENTINEL, it exists in sentinel. */ if (!(c->flags & CMD_SENTINEL) && server.sentinel_mode) return C_ERR; @@ -3047,7 +3047,7 @@ int populateCommandStructure(struct redisCommand *c) { /* Handle subcommands */ if (c->subcommands) { for (int j = 0; c->subcommands[j].declared_name; j++) { - struct redisCommand *sub = c->subcommands+j; + struct serverCommand *sub = c->subcommands+j; sub->fullname = catSubCommandFullname(c->declared_name, sub->declared_name); if (populateCommandStructure(sub) == C_ERR) @@ -3060,13 +3060,13 @@ int populateCommandStructure(struct redisCommand *c) { return C_OK; } -extern struct redisCommand redisCommandTable[]; +extern struct serverCommand redisCommandTable[]; /* Populates the Redis Command Table dict from the static table in commands.c * which is auto generated from the json files in the commands folder. */ void populateCommandTable(void) { int j; - struct redisCommand *c; + struct serverCommand *c; for (j = 0;; j++) { c = redisCommandTable + j; @@ -3088,13 +3088,13 @@ void populateCommandTable(void) { } void resetCommandTableStats(dict* commands) { - struct redisCommand *c; + struct serverCommand *c; dictEntry *de; dictIterator *di; di = dictGetSafeIterator(commands); while((de = dictNext(di)) != NULL) { - c = (struct redisCommand *) dictGetVal(de); + c = (struct serverCommand *) dictGetVal(de); c->microseconds = 0; c->calls = 0; c->rejected_calls = 0; @@ -3156,12 +3156,12 @@ void serverOpArrayFree(serverOpArray *oa) { /* ====================== Commands lookup and execution ===================== */ int isContainerCommandBySds(sds s) { - struct redisCommand *base_cmd = dictFetchValue(server.commands, s); + struct serverCommand *base_cmd = dictFetchValue(server.commands, s); int has_subcommands = base_cmd && base_cmd->subcommands_dict; return has_subcommands; } -struct redisCommand *lookupSubcommand(struct redisCommand *container, sds sub_name) { +struct serverCommand *lookupSubcommand(struct serverCommand *container, sds sub_name) { return dictFetchValue(container->subcommands_dict, sub_name); } @@ -3173,8 +3173,8 @@ struct redisCommand *lookupSubcommand(struct redisCommand *container, sds sub_na * name (e.g. in COMMAND INFO) rather than to find the command * a user requested to execute (in processCommand). */ -struct redisCommand *lookupCommandLogic(dict *commands, robj **argv, int argc, int strict) { - struct redisCommand *base_cmd = dictFetchValue(commands, argv[0]->ptr); +struct serverCommand *lookupCommandLogic(dict *commands, robj **argv, int argc, int strict) { + struct serverCommand *base_cmd = dictFetchValue(commands, argv[0]->ptr); int has_subcommands = base_cmd && base_cmd->subcommands_dict; if (argc == 1 || !has_subcommands) { if (strict && argc != 1) @@ -3189,11 +3189,11 @@ struct redisCommand *lookupCommandLogic(dict *commands, robj **argv, int argc, i } } -struct redisCommand *lookupCommand(robj **argv, int argc) { +struct serverCommand *lookupCommand(robj **argv, int argc) { return lookupCommandLogic(server.commands,argv,argc,0); } -struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s) { +struct serverCommand *lookupCommandBySdsLogic(dict *commands, sds s) { int argc, j; sds *strings = sdssplitlen(s,sdslen(s),"|",1,&argc); if (strings == NULL) @@ -3212,17 +3212,17 @@ struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s) { argv[j] = &objects[j]; } - struct redisCommand *cmd = lookupCommandLogic(commands,argv,argc,1); + struct serverCommand *cmd = lookupCommandLogic(commands,argv,argc,1); sdsfreesplitres(strings,argc); return cmd; } -struct redisCommand *lookupCommandBySds(sds s) { +struct serverCommand *lookupCommandBySds(sds s) { return lookupCommandBySdsLogic(server.commands,s); } -struct redisCommand *lookupCommandByCStringLogic(dict *commands, const char *s) { - struct redisCommand *cmd; +struct serverCommand *lookupCommandByCStringLogic(dict *commands, const char *s) { + struct serverCommand *cmd; sds name = sdsnew(s); cmd = lookupCommandBySdsLogic(commands,name); @@ -3230,7 +3230,7 @@ struct redisCommand *lookupCommandByCStringLogic(dict *commands, const char *s) return cmd; } -struct redisCommand *lookupCommandByCString(const char *s) { +struct serverCommand *lookupCommandByCString(const char *s) { return lookupCommandByCStringLogic(server.commands,s); } @@ -3241,8 +3241,8 @@ struct redisCommand *lookupCommandByCString(const char *s) { * This is used by functions rewriting the argument vector such as * rewriteClientCommandVector() in order to set client->cmd pointer * correctly even if the command was renamed. */ -struct redisCommand *lookupCommandOrOriginal(robj **argv ,int argc) { - struct redisCommand *cmd = lookupCommandLogic(server.commands, argv, argc, 0); +struct serverCommand *lookupCommandOrOriginal(robj **argv ,int argc) { + struct serverCommand *cmd = lookupCommandLogic(server.commands, argv, argc, 0); if (!cmd) cmd = lookupCommandLogic(server.orig_commands, argv, argc, 0); return cmd; @@ -3352,7 +3352,7 @@ void preventCommandReplication(client *c) { } /* Log the last command a client executed into the slowlog. */ -void slowlogPushCurrentCommand(client *c, struct redisCommand *cmd, ustime_t duration) { +void slowlogPushCurrentCommand(client *c, struct serverCommand *cmd, ustime_t duration) { /* Some commands may contain sensitive data that should not be available in the slowlog. */ if (cmd->flags & CMD_SKIP_SLOWLOG) return; @@ -3459,7 +3459,7 @@ void postExecutionUnitOperations(void) { * twice, its possible to pass a NULL cmd value to indicate that the error was counted elsewhere. * * The function returns true if stats was updated and false if not. */ -int incrCommandStatsOnError(struct redisCommand *cmd, int flags) { +int incrCommandStatsOnError(struct serverCommand *cmd, int flags) { /* hold the prev error count captured on the last command execution */ static long long prev_err_count = 0; int res = 0; @@ -3516,7 +3516,7 @@ int incrCommandStatsOnError(struct redisCommand *cmd, int flags) { void call(client *c, int flags) { long long dirty; uint64_t client_old_flags = c->flags; - struct redisCommand *real_cmd = c->realcmd; + struct serverCommand *real_cmd = c->realcmd; client *prev_client = server.executing_client; server.executing_client = c; @@ -4640,7 +4640,7 @@ void addReplyCommandFlags(client *c, uint64_t flags, replyFlagNames *replyFlags) } } -void addReplyFlagsForCommand(client *c, struct redisCommand *cmd) { +void addReplyFlagsForCommand(client *c, struct serverCommand *cmd) { replyFlagNames flagNames[] = { {CMD_WRITE, "write"}, {CMD_READONLY, "readonly"}, @@ -4672,7 +4672,7 @@ void addReplyFlagsForCommand(client *c, struct redisCommand *cmd) { addReplyCommandFlags(c, cmd->flags, flagNames); } -void addReplyDocFlagsForCommand(client *c, struct redisCommand *cmd) { +void addReplyDocFlagsForCommand(client *c, struct serverCommand *cmd) { replyFlagNames docFlagNames[] = { {CMD_DOC_DEPRECATED, "deprecated"}, {CMD_DOC_SYSCMD, "syscmd"}, @@ -4818,7 +4818,7 @@ void addReplyJson(client *c, struct jsonObject *rs) { #endif -void addReplyCommandHistory(client *c, struct redisCommand *cmd) { +void addReplyCommandHistory(client *c, struct serverCommand *cmd) { addReplySetLen(c, cmd->num_history); for (int j = 0; jnum_history; j++) { addReplyArrayLen(c, 2); @@ -4827,14 +4827,14 @@ void addReplyCommandHistory(client *c, struct redisCommand *cmd) { } } -void addReplyCommandTips(client *c, struct redisCommand *cmd) { +void addReplyCommandTips(client *c, struct serverCommand *cmd) { addReplySetLen(c, cmd->num_tips); for (int j = 0; jnum_tips; j++) { addReplyBulkCString(c, cmd->tips[j]); } } -void addReplyCommandKeySpecs(client *c, struct redisCommand *cmd) { +void addReplyCommandKeySpecs(client *c, struct serverCommand *cmd) { addReplySetLen(c, cmd->key_specs_num); for (int i = 0; i < cmd->key_specs_num; i++) { int maplen = 3; @@ -4931,7 +4931,7 @@ void addReplyCommandKeySpecs(client *c, struct redisCommand *cmd) { } /* Reply with an array of sub-command using the provided reply callback. */ -void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*reply_function)(client*, struct redisCommand*), int use_map) { +void addReplyCommandSubCommands(client *c, struct serverCommand *cmd, void (*reply_function)(client*, struct serverCommand*), int use_map) { if (!cmd->subcommands_dict) { addReplySetLen(c, 0); return; @@ -4944,7 +4944,7 @@ void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*repl dictEntry *de; dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict); while((de = dictNext(di)) != NULL) { - struct redisCommand *sub = (struct redisCommand *)dictGetVal(de); + struct serverCommand *sub = (struct serverCommand *)dictGetVal(de); if (use_map) addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname)); reply_function(c, sub); @@ -4953,7 +4953,7 @@ void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*repl } /* Output the representation of a Redis command. Used by the COMMAND command and COMMAND INFO. */ -void addReplyCommandInfo(client *c, struct redisCommand *cmd) { +void addReplyCommandInfo(client *c, struct serverCommand *cmd) { if (!cmd) { addReplyNull(c); } else { @@ -4981,7 +4981,7 @@ void addReplyCommandInfo(client *c, struct redisCommand *cmd) { } /* Output the representation of a Redis command. Used by the COMMAND DOCS. */ -void addReplyCommandDocs(client *c, struct redisCommand *cmd) { +void addReplyCommandDocs(client *c, struct serverCommand *cmd) { /* Count our reply len so we don't have to use deferred reply. */ long maplen = 1; if (cmd->summary) maplen++; @@ -5054,7 +5054,7 @@ void addReplyCommandDocs(client *c, struct redisCommand *cmd) { /* Helper for COMMAND GETKEYS and GETKEYSANDFLAGS */ void getKeysSubcommandImpl(client *c, int with_flags) { - struct redisCommand *cmd = lookupCommand(c->argv+2,c->argc-2); + struct serverCommand *cmd = lookupCommand(c->argv+2,c->argc-2); getKeysResult result = GETKEYS_RESULT_INIT; int j; @@ -5138,7 +5138,7 @@ typedef struct { } cache; } commandListFilter; -int shouldFilterFromCommandList(struct redisCommand *cmd, commandListFilter *filter) { +int shouldFilterFromCommandList(struct serverCommand *cmd, commandListFilter *filter) { switch (filter->type) { case (COMMAND_LIST_FILTER_MODULE): if (!filter->cache.valid) { @@ -5170,7 +5170,7 @@ void commandListWithFilter(client *c, dict *commands, commandListFilter filter, dictIterator *di = dictGetIterator(commands); while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); if (!shouldFilterFromCommandList(cmd,&filter)) { addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); (*numcmds)++; @@ -5189,7 +5189,7 @@ void commandListWithoutFilter(client *c, dict *commands, int *numcmds) { dictIterator *di = dictGetIterator(commands); while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); (*numcmds)++; @@ -5273,7 +5273,7 @@ void commandDocsCommand(client *c) { addReplyMapLen(c, dictSize(server.commands)); di = dictGetIterator(server.commands); while ((de = dictNext(di)) != NULL) { - struct redisCommand *cmd = dictGetVal(de); + struct serverCommand *cmd = dictGetVal(de); addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); addReplyCommandDocs(c, cmd); } @@ -5283,7 +5283,7 @@ void commandDocsCommand(client *c) { int numcmds = 0; void *replylen = addReplyDeferredLen(c); for (i = 2; i < c->argc; i++) { - struct redisCommand *cmd = lookupCommandBySds(c->argv[i]->ptr); + struct serverCommand *cmd = lookupCommandBySds(c->argv[i]->ptr); if (!cmd) continue; addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); @@ -5405,13 +5405,13 @@ const char *getSafeInfoString(const char *s, size_t len, char **tmp) { } sds genRedisInfoStringCommandStats(sds info, dict *commands) { - struct redisCommand *c; + struct serverCommand *c; dictEntry *de; dictIterator *di; di = dictGetSafeIterator(commands); while((de = dictNext(di)) != NULL) { char *tmpsafe; - c = (struct redisCommand *) dictGetVal(de); + c = (struct serverCommand *) dictGetVal(de); if (c->calls || c->failed_calls || c->rejected_calls) { info = sdscatprintf(info, "cmdstat_%s:calls=%lld,usec=%lld,usec_per_call=%.2f" @@ -5445,13 +5445,13 @@ sds genRedisInfoStringACLStats(sds info) { } sds genRedisInfoStringLatencyStats(sds info, dict *commands) { - struct redisCommand *c; + struct serverCommand *c; dictEntry *de; dictIterator *di; di = dictGetSafeIterator(commands); while((de = dictNext(di)) != NULL) { char *tmpsafe; - c = (struct redisCommand *) dictGetVal(de); + c = (struct serverCommand *) dictGetVal(de); if (c->latency_histogram) { info = fillPercentileDistributionLatencies(info, getSafeInfoString(c->fullname, sdslen(c->fullname), &tmpsafe), diff --git a/src/server.h b/src/server.h index e78d5a0f64..d4d5495a98 100644 --- a/src/server.h +++ b/src/server.h @@ -202,7 +202,7 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT]; /* Hash table parameters */ #define HASHTABLE_MAX_LOAD_FACTOR 1.618 /* Maximum hash table load factor. */ -/* Command flags. Please check the definition of struct redisCommand in this file +/* Command flags. Please check the definition of struct serverCommand in this file * for more information about the meaning of every flag. */ #define CMD_WRITE (1ULL<<0) #define CMD_READONLY (1ULL<<1) @@ -1007,7 +1007,7 @@ typedef struct multiCmd { robj **argv; int argv_len; int argc; - struct redisCommand *cmd; + struct serverCommand *cmd; } multiCmd; typedef struct multiState { @@ -1177,8 +1177,8 @@ typedef struct client { int original_argc; /* Num of arguments of original command if arguments were rewritten. */ robj **original_argv; /* Arguments of original command if arguments were rewritten. */ size_t argv_len_sum; /* Sum of lengths of objects in argv list. */ - struct redisCommand *cmd, *lastcmd; /* Last command executed. */ - struct redisCommand *realcmd; /* The original command that was executed by the client, + struct serverCommand *cmd, *lastcmd; /* Last command executed. */ + struct serverCommand *realcmd; /* The original command that was executed by the client, Used to update error stats in case the c->cmd was modified during the command invocation (like on GEOADD for example). */ user *user; /* User associated with this connection. If the @@ -2238,7 +2238,7 @@ typedef enum { } serverCommandGroup; typedef void serverCommandProc(client *c); -typedef int serverGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); +typedef int serverGetKeysProc(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); /* Redis command structure. * @@ -2333,7 +2333,7 @@ typedef int serverGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, g * specific data structures, such as: DEL, RENAME, MOVE, SELECT, * TYPE, EXPIRE*, PEXPIRE*, TTL, PTTL, ... */ -struct redisCommand { +struct serverCommand { /* Declarative data */ const char *declared_name; /* A string representing the command declared_name. * It is a const char * for native commands and SDS for module commands. */ @@ -2359,7 +2359,7 @@ struct redisCommand { serverGetKeysProc *getkeys_proc; int num_args; /* Length of args array. */ /* Array of subcommands (may be NULL) */ - struct redisCommand *subcommands; + struct serverCommand *subcommands; /* Array of arguments (may be NULL) */ struct redisCommandArg *args; #ifdef LOG_REQ_RES @@ -2381,8 +2381,8 @@ struct redisCommand { * we can still support the reply format of * COMMAND INFO and COMMAND GETKEYS */ dict *subcommands_dict; /* A dictionary that holds the subcommands, the key is the subcommand sds name - * (not the fullname), and the value is the redisCommand structure pointer. */ - struct redisCommand *parent; + * (not the fullname), and the value is the serverCommand structure pointer. */ + struct serverCommand *parent; struct RedisModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */ }; @@ -2488,7 +2488,7 @@ extern dict *modules; *----------------------------------------------------------------------------*/ /* Command metadata */ -void populateCommandLegacyRangeSpec(struct redisCommand *c); +void populateCommandLegacyRangeSpec(struct serverCommand *c); /* Modules */ void moduleInitModulesSystem(void); @@ -2497,14 +2497,14 @@ void modulesCron(void); int moduleLoad(const char *path, void **argv, int argc, int is_loadex); int moduleUnload(sds name, const char **errmsg); void moduleLoadFromQueue(void); -int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int moduleGetCommandChannelsViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); +int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int moduleGetCommandChannelsViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); moduleType *moduleTypeLookupModuleByID(uint64_t id); moduleType *moduleTypeLookupModuleByName(const char *name); moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name); void moduleTypeNameByID(char *name, uint64_t moduleid); const char *moduleTypeModuleName(moduleType *mt); -const char *moduleNameFromCommand(struct redisCommand *cmd); +const char *moduleNameFromCommand(struct serverCommand *cmd); void moduleFreeContext(struct RedisModuleCtx *ctx); void moduleCallCommandUnblockedHandler(client *c); int isModuleClientUnblocked(client *c); @@ -2541,7 +2541,7 @@ int moduleDefragValue(robj *key, robj *obj, int dbid); int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long endtime, int dbid); void moduleDefragGlobals(void); void *moduleGetHandleByName(char *modulename); -int moduleIsModuleCommand(void *module_handle, struct redisCommand *cmd); +int moduleIsModuleCommand(void *module_handle, struct serverCommand *cmd); /* Utils */ long long ustime(void); @@ -2950,8 +2950,8 @@ void ACLClearCommandID(void); user *ACLGetUserByName(const char *name, size_t namelen); int ACLUserCheckKeyPerm(user *u, const char *key, int keylen, int flags); int ACLUserCheckChannelPerm(user *u, sds channel, int literal); -int ACLCheckAllUserCommandPerm(user *u, struct redisCommand *cmd, robj **argv, int argc, int *idxptr); -int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct redisCommand *cmd, robj **argv, int argc, int flags); +int ACLCheckAllUserCommandPerm(user *u, struct serverCommand *cmd, robj **argv, int argc, int *idxptr); +int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct serverCommand *cmd, robj **argv, int argc, int flags); int ACLCheckAllPerm(client *c, int *idxptr); int ACLSetUser(user *u, const char *op, ssize_t oplen); sds ACLStringSetUser(user *u, sds username, sds *argv, int argc); @@ -2963,11 +2963,11 @@ const char *ACLSetUserStringError(void); int ACLLoadConfiguredUsers(void); robj *ACLDescribeUser(user *u); void ACLLoadUsersAtStartup(void); -void addReplyCommandCategories(client *c, struct redisCommand *cmd); +void addReplyCommandCategories(client *c, struct serverCommand *cmd); user *ACLCreateUnlinkedUser(void); void ACLFreeUserAndKillClients(user *u); void addACLLogEntry(client *c, int reason, int context, int argpos, sds username, sds object); -sds getAclErrorMessage(int acl_res, user *user, struct redisCommand *cmd, sds errored_val, int verbose); +sds getAclErrorMessage(int acl_res, user *user, struct serverCommand *cmd, sds errored_val, int verbose); void ACLUpdateDefaultUserPassword(sds password); sds genRedisInfoStringACLStats(sds info); void ACLRecomputeCommandBitsFromCommandRulesAllUsers(void); @@ -3051,17 +3051,17 @@ int createSocketAcceptHandler(connListener *sfd, aeFileProc *accept_handler); connListener *listenerByType(const char *typename); int changeListener(connListener *listener); void closeListener(connListener *listener); -struct redisCommand *lookupSubcommand(struct redisCommand *container, sds sub_name); -struct redisCommand *lookupCommand(robj **argv, int argc); -struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s); -struct redisCommand *lookupCommandBySds(sds s); -struct redisCommand *lookupCommandByCStringLogic(dict *commands, const char *s); -struct redisCommand *lookupCommandByCString(const char *s); -struct redisCommand *lookupCommandOrOriginal(robj **argv, int argc); +struct serverCommand *lookupSubcommand(struct serverCommand *container, sds sub_name); +struct serverCommand *lookupCommand(robj **argv, int argc); +struct serverCommand *lookupCommandBySdsLogic(dict *commands, sds s); +struct serverCommand *lookupCommandBySds(sds s); +struct serverCommand *lookupCommandByCStringLogic(dict *commands, const char *s); +struct serverCommand *lookupCommandByCString(const char *s); +struct serverCommand *lookupCommandOrOriginal(robj **argv, int argc); int commandCheckExistence(client *c, sds *err); int commandCheckArity(client *c, sds *err); void startCommandExecution(void); -int incrCommandStatsOnError(struct redisCommand *cmd, int flags); +int incrCommandStatsOnError(struct serverCommand *cmd, int flags); void call(client *c, int flags); void alsoPropagate(int dbid, robj **argv, int argc, int target); void postExecutionUnitOperations(void); @@ -3070,7 +3070,7 @@ void forceCommandPropagation(client *c, int flags); void preventCommandPropagation(client *c); void preventCommandAOF(client *c); void preventCommandReplication(client *c); -void slowlogPushCurrentCommand(client *c, struct redisCommand *cmd, ustime_t duration); +void slowlogPushCurrentCommand(client *c, struct serverCommand *cmd, ustime_t duration); void updateCommandLatencyHistogram(struct hdr_histogram** latency_histogram, int64_t duration_hist); int prepareForShutdown(int flags); void replyToClientsBlockedOnShutdown(void); @@ -3337,29 +3337,29 @@ void freeReplicationBacklogRefMemAsync(list *blocks, rax *index); #define GET_KEYSPEC_INCLUDE_NOT_KEYS (1<<0) /* Consider 'fake' keys as keys */ #define GET_KEYSPEC_RETURN_PARTIAL (1<<1) /* Return all keys that can be found */ -int getKeysFromCommandWithSpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result); +int getKeysFromCommandWithSpecs(struct serverCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result); keyReference *getKeysPrepareResult(getKeysResult *result, int numkeys); -int getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int doesCommandHaveKeys(struct redisCommand *cmd); -int getChannelsFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags); +int getKeysFromCommand(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int doesCommandHaveKeys(struct serverCommand *cmd); +int getChannelsFromCommand(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int doesCommandHaveChannelsWithFlags(struct serverCommand *cmd, int flags); void getKeysFreeResult(getKeysResult *result); -int sintercardGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result); -int zunionInterDiffGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result); -int zunionInterDiffStoreGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result); -int evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int functionGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int lmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int blmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int zmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); -int bitfieldGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result); +int sintercardGetKeys(struct serverCommand *cmd,robj **argv, int argc, getKeysResult *result); +int zunionInterDiffGetKeys(struct serverCommand *cmd,robj **argv, int argc, getKeysResult *result); +int zunionInterDiffStoreGetKeys(struct serverCommand *cmd,robj **argv, int argc, getKeysResult *result); +int evalGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int functionGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int sortGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int sortROGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int migrateGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int georadiusGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int xreadGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int lmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int blmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int zmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int bzmpopGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int setGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +int bitfieldGetKeys(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); unsigned short crc16(const char *buf, int len); @@ -3766,7 +3766,7 @@ int memtest_preserving_test(unsigned long *m, size_t bytes, int passes); void mixDigest(unsigned char *digest, const void *ptr, size_t len); void xorDigest(unsigned char *digest, const void *ptr, size_t len); sds catSubCommandFullname(const char *parent_name, const char *sub_name); -void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subcommand, const char *declared_name); +void commandAddSubcommand(struct serverCommand *parent, struct serverCommand *subcommand, const char *declared_name); void debugDelay(int usec); void killIOThreads(void); void killThreads(void); From 25122b140e8fb6a6b93e1f49f22e8fd522b754bc Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:04:51 +0700 Subject: [PATCH 34/98] Rename redisObject to serverObject (#175) Part of #144 Signed-off-by: 0del --- src/evict.c | 2 +- src/module.c | 4 ++-- src/rio.h | 4 ++-- src/server.h | 18 +++++++++--------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/evict.c b/src/evict.c index e3b7ebcece..be8cfad75f 100644 --- a/src/evict.c +++ b/src/evict.c @@ -69,7 +69,7 @@ static struct evictionPoolEntry *EvictionPoolLRU; /* Return the LRU clock, based on the clock resolution. This is a time * in a reduced-bits format that can be used to set and check the - * object->lru field of redisObject structures. */ + * object->lru field of serverObject structures. */ unsigned int getLRUClock(void) { return (mstime()/LRU_CLOCK_RESOLUTION) & LRU_CLOCK_MAX; } diff --git a/src/module.c b/src/module.c index 1545e6d9c4..1a08a9af8e 100644 --- a/src/module.c +++ b/src/module.c @@ -430,7 +430,7 @@ typedef struct RedisModuleUser { /* This is a structure used to export some meta-information such as dbid to the module. */ typedef struct RedisModuleKeyOptCtx { - struct redisObject *from_key, *to_key; /* Optional name of key processed, NULL when unknown. + struct serverObject *from_key, *to_key; /* Optional name of key processed, NULL when unknown. In most cases, only 'from_key' is valid, but in callbacks such as `copy2`, both 'from_key' and 'to_key' are valid. */ int from_dbid, to_dbid; /* The dbid of the key being processed, -1 when unknown. @@ -13430,7 +13430,7 @@ const char *RM_GetCurrentCommandName(RedisModuleCtx *ctx) { struct RedisModuleDefragCtx { long long int endtime; unsigned long *cursor; - struct redisObject *key; /* Optional name of key processed, NULL when unknown. */ + struct serverObject *key; /* Optional name of key processed, NULL when unknown. */ int dbid; /* The dbid of the key being processed, -1 when unknown. */ }; diff --git a/src/rio.h b/src/rio.h index 9dd59d32b1..2b71c5881e 100644 --- a/src/rio.h +++ b/src/rio.h @@ -175,8 +175,8 @@ size_t rioWriteBulkString(rio *r, const char *buf, size_t len); size_t rioWriteBulkLongLong(rio *r, long long l); size_t rioWriteBulkDouble(rio *r, double d); -struct redisObject; -int rioWriteBulkObject(rio *r, struct redisObject *obj); +struct serverObject; +int rioWriteBulkObject(rio *r, struct serverObject *obj); void rioGenericUpdateChecksum(rio *r, const void *buf, size_t len); void rioSetAutoSync(rio *r, off_t bytes); diff --git a/src/server.h b/src/server.h index d4d5495a98..4d7c94bd73 100644 --- a/src/server.h +++ b/src/server.h @@ -81,7 +81,7 @@ typedef long long ustime_t; /* microsecond time type. */ #include "connection.h" /* Connection abstraction */ #define REDISMODULE_CORE 1 -typedef struct redisObject robj; +typedef struct serverObject robj; #include "redismodule.h" /* Redis modules API defines. */ /* Following includes allow test functions to be called from Redis main() */ @@ -750,14 +750,14 @@ typedef void *(*moduleTypeLoadFunc)(struct RedisModuleIO *io, int encver); typedef void (*moduleTypeSaveFunc)(struct RedisModuleIO *io, void *value); typedef int (*moduleTypeAuxLoadFunc)(struct RedisModuleIO *rdb, int encver, int when); typedef void (*moduleTypeAuxSaveFunc)(struct RedisModuleIO *rdb, int when); -typedef void (*moduleTypeRewriteFunc)(struct RedisModuleIO *io, struct redisObject *key, void *value); +typedef void (*moduleTypeRewriteFunc)(struct RedisModuleIO *io, struct serverObject *key, void *value); typedef void (*moduleTypeDigestFunc)(struct RedisModuleDigest *digest, void *value); typedef size_t (*moduleTypeMemUsageFunc)(const void *value); typedef void (*moduleTypeFreeFunc)(void *value); -typedef size_t (*moduleTypeFreeEffortFunc)(struct redisObject *key, const void *value); -typedef void (*moduleTypeUnlinkFunc)(struct redisObject *key, void *value); -typedef void *(*moduleTypeCopyFunc)(struct redisObject *fromkey, struct redisObject *tokey, const void *value); -typedef int (*moduleTypeDefragFunc)(struct RedisModuleDefragCtx *ctx, struct redisObject *key, void **value); +typedef size_t (*moduleTypeFreeEffortFunc)(struct serverObject *key, const void *value); +typedef void (*moduleTypeUnlinkFunc)(struct serverObject *key, void *value); +typedef void *(*moduleTypeCopyFunc)(struct serverObject *fromkey, struct serverObject *tokey, const void *value); +typedef int (*moduleTypeDefragFunc)(struct RedisModuleDefragCtx *ctx, struct serverObject *key, void **value); typedef size_t (*moduleTypeMemUsageFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value, size_t sample_size); typedef void (*moduleTypeFreeFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value); typedef size_t (*moduleTypeFreeEffortFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value); @@ -846,7 +846,7 @@ struct RedisModuleIO { moduleType *type; /* Module type doing the operation. */ int error; /* True if error condition happened. */ struct RedisModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/ - struct redisObject *key; /* Optional name of key processed */ + struct serverObject *key; /* Optional name of key processed */ int dbid; /* The dbid of the key being processed, -1 when unknown. */ sds pre_flush_buffer; /* A buffer that should be flushed before next write operation * See rdbSaveSingleModuleAux for more details */ @@ -873,7 +873,7 @@ struct RedisModuleIO { struct RedisModuleDigest { unsigned char o[20]; /* Ordered elements. */ unsigned char x[20]; /* Xored elements. */ - struct redisObject *key; /* Optional name of key processed */ + struct serverObject *key; /* Optional name of key processed */ int dbid; /* The dbid of the key being processed */ }; @@ -909,7 +909,7 @@ struct RedisModuleDigest { #define OBJ_SHARED_REFCOUNT INT_MAX /* Global object never destroyed. */ #define OBJ_STATIC_REFCOUNT (INT_MAX-1) /* Object allocated in the stack. */ #define OBJ_FIRST_SPECIAL_REFCOUNT OBJ_STATIC_REFCOUNT -struct redisObject { +struct serverObject { unsigned type:4; unsigned encoding:4; unsigned lru:LRU_BITS; /* LRU time (relative to global lru_clock) or From c413834da1183a85ea8a8e1447428a47a62c2be2 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:06:01 +0700 Subject: [PATCH 35/98] Rename redisTLSContextConfig to serverTLSContextConfig (#176) Part of #144 Signed-off-by: 0del --- src/server.h | 6 +++--- src/tls.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server.h b/src/server.h index 4d7c94bd73..2b904309a9 100644 --- a/src/server.h +++ b/src/server.h @@ -1475,7 +1475,7 @@ struct malloc_stats { * TLS Context Configuration *----------------------------------------------------------------------------*/ -typedef struct redisTLSContextConfig { +typedef struct serverTLSContextConfig { char *cert_file; /* Server side and optionally client side cert file name */ char *key_file; /* Private key filename for cert_file */ char *key_file_pass; /* Optional password for key_file */ @@ -1492,7 +1492,7 @@ typedef struct redisTLSContextConfig { int session_caching; int session_cache_size; int session_cache_timeout; -} redisTLSContextConfig; +} serverTLSContextConfig; /*----------------------------------------------------------------------------- * AOF manifest definition @@ -2050,7 +2050,7 @@ struct redisServer { int tls_cluster; int tls_replication; int tls_auth_clients; - redisTLSContextConfig tls_ctx_config; + serverTLSContextConfig tls_ctx_config; /* cpu affinity */ char *server_cpulist; /* cpu affinity list of redis server main/io thread. */ char *bio_cpulist; /* cpu affinity list of bio thread. */ diff --git a/src/tls.c b/src/tls.c index d011c16ea1..a6bd066097 100644 --- a/src/tls.c +++ b/src/tls.c @@ -203,7 +203,7 @@ static int tlsPasswordCallback(char *buf, int size, int rwflag, void *u) { /* Create a *base* SSL_CTX using the SSL configuration provided. The base context * includes everything that's common for both client-side and server-side connections. */ -static SSL_CTX *createSSLContext(redisTLSContextConfig *ctx_config, int protocols, int client) { +static SSL_CTX *createSSLContext(serverTLSContextConfig *ctx_config, int protocols, int client) { const char *cert_file = client ? ctx_config->client_cert_file : ctx_config->cert_file; const char *key_file = client ? ctx_config->client_key_file : ctx_config->key_file; const char *key_file_pass = client ? ctx_config->client_key_file_pass : ctx_config->key_file_pass; @@ -282,12 +282,12 @@ static SSL_CTX *createSSLContext(redisTLSContextConfig *ctx_config, int protocol /* Attempt to configure/reconfigure TLS. This operation is atomic and will * leave the SSL_CTX unchanged if fails. - * @priv: config of redisTLSContextConfig. + * @priv: config of serverTLSContextConfig. * @reconfigure: if true, ignore the previous configure; if false, only * configure from @ctx_config if redis_tls_ctx is NULL. */ static int tlsConfigure(void *priv, int reconfigure) { - redisTLSContextConfig *ctx_config = (redisTLSContextConfig *)priv; + serverTLSContextConfig *ctx_config = (serverTLSContextConfig *)priv; char errbuf[256]; SSL_CTX *ctx = NULL; SSL_CTX *client_ctx = NULL; From 1629e28f86c598bf8663c1a0ede81b68bc04a8c2 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:12:34 +0700 Subject: [PATCH 36/98] Rename redisError to serverError (#177) Part of #144 Signed-off-by: 0del --- src/server.c | 8 ++++---- src/server.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server.c b/src/server.c index 53c2b57a21..f2ecd3488f 100644 --- a/src/server.c +++ b/src/server.c @@ -4246,11 +4246,11 @@ void incrementErrorCount(const char *fullerr, size_t namelen) { return; } - struct redisError *error = zmalloc(sizeof(*error)); + struct serverError *error = zmalloc(sizeof(*error)); error->count = 1; raxInsert(server.errors,(unsigned char*)fullerr,namelen,error,NULL); } else { - struct redisError *error = result; + struct serverError *error = result; error->count++; } } @@ -6071,10 +6071,10 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { raxIterator ri; raxStart(&ri,server.errors); raxSeek(&ri,"^",NULL,0); - struct redisError *e; + struct serverError *e; while(raxNext(&ri)) { char *tmpsafe; - e = (struct redisError *) ri.data; + e = (struct serverError *) ri.data; info = sdscatprintf(info, "errorstat_%.*s:count=%lld\r\n", (int)ri.key_len, getSafeInfoString((char *) ri.key, ri.key_len, &tmpsafe), e->count); diff --git a/src/server.h b/src/server.h index 2b904309a9..a5e6761be9 100644 --- a/src/server.h +++ b/src/server.h @@ -2386,7 +2386,7 @@ struct serverCommand { struct RedisModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */ }; -struct redisError { +struct serverError { long long count; }; From 1736018aa92b3d635248b2730bf3ebb498778b57 Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Wed, 3 Apr 2024 10:47:26 -0700 Subject: [PATCH 37/98] Remove trademarked wording on configuration file and individual configs (#29) Remove trademarked wording on configuration layer. Following changes for release notes: 1. Rename redis.conf to valkey.conf 2. Pre-filled config in the template config file: Changing pidfile to `/var/run/valkey_6379.pid` Signed-off-by: Harkrishn Patro --- .gitignore | 3 +- sentinel.conf | 4 +- src/acl.c | 6 +- src/config.c | 4 +- src/module.c | 2 +- src/server.c | 18 +- src/server.h | 4 +- tests/support/server.tcl | 2 +- tests/test_helper.tcl | 2 +- tests/unit/other.tcl | 2 +- utils/install_server.sh | 2 +- utils/systemd-redis_server.service | 4 +- redis.conf => valkey.conf | 371 ++++++++++++++--------------- 13 files changed, 206 insertions(+), 218 deletions(-) rename redis.conf => valkey.conf (88%) diff --git a/.gitignore b/.gitignore index fa53b69d67..920e32eca7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,7 @@ release.h src/transfer.sh src/configs redis.ds -src/redis.conf -src/nodes.conf +src/*.conf deps/lua/src/lua deps/lua/src/luac deps/lua/src/liblua.a diff --git a/sentinel.conf b/sentinel.conf index b7b3604f0e..0180558b4f 100644 --- a/sentinel.conf +++ b/sentinel.conf @@ -146,7 +146,7 @@ sentinel down-after-milliseconds mymaster 30000 # # For more information about ACL configuration please refer to the Redis # website at https://redis.io/topics/acl and redis server configuration -# template redis.conf. +# template valkey.conf. # ACL LOG # @@ -164,7 +164,7 @@ acllog-max-len 128 # ACL file, the server will refuse to start. # # The format of the external ACL user file is exactly the same as the -# format that is used inside redis.conf to describe users. +# format that is used inside valkey.conf to describe users. # # aclfile /etc/redis/sentinel-users.acl diff --git a/src/acl.c b/src/acl.c index 244e7f0826..f0668a4ecd 100644 --- a/src/acl.c +++ b/src/acl.c @@ -64,7 +64,7 @@ static unsigned long nextid = 0; /* Next command id that has not been assigned * struct ACLCategoryItem { char *name; uint64_t flag; -} ACLDefaultCommandCategories[] = { /* See redis.conf for details on each category. */ +} ACLDefaultCommandCategories[] = { /* See valkey.conf for details on each category. */ {"keyspace", ACL_CATEGORY_KEYSPACE}, {"read", ACL_CATEGORY_READ}, {"write", ACL_CATEGORY_WRITE}, @@ -2272,7 +2272,7 @@ int ACLLoadConfiguredUsers(void) { /* This function loads the ACL from the specified filename: every line * is validated and should be either empty or in the format used to specify - * users in the redis.conf configuration or in the ACL file, that is: + * users in the valkey.conf or in the ACL file, that is: * * user ... rules ... * @@ -2566,7 +2566,7 @@ int ACLSaveToFile(const char *filename) { /* This function is called once the server is already running, modules are * loaded, and we are ready to start, in order to load the ACLs either from - * the pending list of users defined in redis.conf, or from the ACL file. + * the pending list of users defined in valkey.conf, or from the ACL file. * The function will just exit with an error if the user is trying to mix * both the loading methods. */ void ACLLoadUsersAtStartup(void) { diff --git a/src/config.c b/src/config.c index 731a3304c7..888567a157 100644 --- a/src/config.c +++ b/src/config.c @@ -1275,7 +1275,7 @@ int rewriteConfigRewriteLine(struct rewriteConfigState *state, const char *optio } /* Write the long long 'bytes' value as a string in a way that is parsable - * inside redis.conf. If possible uses the GB, MB, KB notation. */ + * inside valkey.conf. If possible uses the GB, MB, KB notation. */ int rewriteConfigFormatMemory(char *buf, size_t len, long long bytes) { int gb = 1024*1024*1024; int mb = 1024*1024; @@ -1473,7 +1473,7 @@ void rewriteConfigReplicaOfOption(standardConfig *config, const char *name, stru /* If this is a master, we want all the slaveof config options * in the file to be removed. Note that if this is a cluster instance - * we don't want a slaveof directive inside redis.conf. */ + * we don't want a slaveof directive inside valkey.conf. */ if (server.cluster_enabled || server.masterhost == NULL) { rewriteConfigMarkAsProcessed(state, name); return; diff --git a/src/module.c b/src/module.c index 1a08a9af8e..af0d92cf8b 100644 --- a/src/module.c +++ b/src/module.c @@ -8703,7 +8703,7 @@ void moduleReleaseGIL(void) { * used to send anything to the client, and has the db number where the event * occurred as its selected db number. * - * Notice that it is not necessary to enable notifications in redis.conf for + * Notice that it is not necessary to enable notifications in valkey.conf for * module notifications to work. * * Warning: the notification callbacks are performed in a synchronous manner, diff --git a/src/server.c b/src/server.c index f2ecd3488f..eab88ce7ba 100644 --- a/src/server.c +++ b/src/server.c @@ -2142,7 +2142,7 @@ void initServerConfig(void) { /* Command table -- we initialize it here as it is part of the * initial configuration, since command names may be changed via - * redis.conf using the rename-command directive. */ + * valkey.conf using the rename-command directive. */ server.commands = dictCreate(&commandTableDictType); server.orig_commands = dictCreate(&commandTableDictType); populateCommandTable(); @@ -3081,7 +3081,7 @@ void populateCommandTable(void) { retval1 = dictAdd(server.commands, sdsdup(c->fullname), c); /* Populate an additional dictionary that will be unaffected - * by rename-command statements in redis.conf. */ + * by rename-command statements in valkey.conf. */ retval2 = dictAdd(server.orig_commands, sdsdup(c->fullname), c); serverAssert(retval1 == DICT_OK && retval2 == DICT_OK); } @@ -3236,7 +3236,7 @@ struct serverCommand *lookupCommandByCString(const char *s) { /* Lookup the command in the current table, if not found also check in * the original table containing the original command names unaffected by - * redis.conf rename-command statement. + * valkey.conf rename-command statement. * * This is used by functions rewriting the argument vector such as * rewriteClientCommandVector() in order to set client->cmd pointer @@ -6275,7 +6275,7 @@ sds getVersion(void) { } void usage(void) { - fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf] [options] [-]\n"); + fprintf(stderr,"Usage: ./redis-server [/path/to/valkey.conf] [options] [-]\n"); fprintf(stderr," ./redis-server - (read config from stdin)\n"); fprintf(stderr," ./redis-server -v or --version\n"); fprintf(stderr," ./redis-server -h or --help\n"); @@ -6285,11 +6285,11 @@ void usage(void) { fprintf(stderr,"Examples:\n"); fprintf(stderr," ./redis-server (run the server with default conf)\n"); fprintf(stderr," echo 'maxmemory 128mb' | ./redis-server -\n"); - fprintf(stderr," ./redis-server /etc/redis/6379.conf\n"); + fprintf(stderr," ./redis-server /etc/valkey/6379.conf\n"); fprintf(stderr," ./redis-server --port 7777\n"); fprintf(stderr," ./redis-server --port 7777 --replicaof 127.0.0.1 8888\n"); - fprintf(stderr," ./redis-server /etc/myredis.conf --loglevel verbose -\n"); - fprintf(stderr," ./redis-server /etc/myredis.conf --loglevel verbose\n\n"); + fprintf(stderr," ./redis-server /etc/myvalkey.conf --loglevel verbose -\n"); + fprintf(stderr," ./redis-server /etc/myvalkey.conf --loglevel verbose\n\n"); fprintf(stderr,"Sentinel mode:\n"); fprintf(stderr," ./redis-server /etc/sentinel.conf --sentinel\n"); exit(1); @@ -6306,7 +6306,7 @@ void redisAsciiArt(void) { /* Show the ASCII logo if: log file is stdout AND stdout is a * tty AND syslog logging is disabled. Also show logo if the user - * forced us to do so via redis.conf. */ + * forced us to do so via valkey.conf. */ int show_logo = ((!server.syslog_enabled && server.logfile[0] == '\0' && isatty(fileno(stdout))) || @@ -6700,7 +6700,7 @@ void redisOutOfMemoryHandler(size_t allocation_size) { allocation_size); } -/* Callback for sdstemplate on proc-title-template. See redis.conf for +/* Callback for sdstemplate on proc-title-template. See valkey.conf for * supported variables. */ static sds redisProcTitleGetVariable(const sds varname, void *arg) diff --git a/src/server.h b/src/server.h index a5e6761be9..b248445da0 100644 --- a/src/server.h +++ b/src/server.h @@ -1734,7 +1734,7 @@ struct redisServer { durationStats duration_stats[EL_DURATION_TYPE_NUM]; /* Configuration */ - int verbosity; /* Loglevel in redis.conf */ + int verbosity; /* Loglevel verbosity */ int maxidletime; /* Client timeout in seconds */ int tcpkeepalive; /* Set SO_KEEPALIVE if non-zero. */ int active_expire_enabled; /* Can be disabled for testing purposes. */ @@ -2314,7 +2314,7 @@ typedef int serverGetKeysProc(struct serverCommand *cmd, robj **argv, int argc, * * The following additional flags are only used in order to put commands * in a specific ACL category. Commands can have multiple ACL categories. - * See redis.conf for the exact meaning of each. + * See valkey.conf for the exact meaning of each. * * @keyspace, @read, @write, @set, @sortedset, @list, @hash, @string, @bitmap, * @hyperloglog, @stream, @admin, @fast, @slow, @pubsub, @blocking, @dangerous, diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 43f619b251..3cf41c2a2e 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -536,7 +536,7 @@ proc start_server {options {code undefined}} { } # write new configuration to temporary file - set config_file [tmpfile redis.conf] + set config_file [tmpfile valkey.conf] create_server_config_file $config_file $config $config_lines set stdout [format "%s/%s" [dict get $config "dir"] "stdout"] diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index c110885c12..3e51541580 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -327,7 +327,7 @@ proc run_solo {name code} { proc cleanup {} { if {!$::quiet} {puts -nonewline "Cleanup: may take some time... "} flush stdout - catch {exec rm -rf {*}[glob tests/tmp/redis.conf.*]} + catch {exec rm -rf {*}[glob tests/tmp/valkey.conf.*]} catch {exec rm -rf {*}[glob tests/tmp/server*.*]} catch {exec rm -rf {*}[glob tests/tmp/*.acl.*]} if {!$::quiet} {puts "OK"} diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index b364fc74a7..4fab1db041 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -419,7 +419,7 @@ start_server {tags {"other external:skip"}} { assert_equal $expect_port [lindex $cmdline 3] assert_equal $expect_tls_port [lindex $cmdline 4] assert_match "*/tests/tmp/server.*/socket" [lindex $cmdline 5] - assert_match "*/tests/tmp/redis.conf.*" [lindex $cmdline 6] + assert_match "*/tests/tmp/valkey.conf.*" [lindex $cmdline 6] # Try setting a bad template catch {r config set "proc-title-template" "{invalid-var}"} err diff --git a/utils/install_server.sh b/utils/install_server.sh index efda7da1c3..e22d88bb40 100755 --- a/utils/install_server.sh +++ b/utils/install_server.sh @@ -166,7 +166,7 @@ mkdir -p "$REDIS_DATA_DIR" || die "Could not create redis data directory" #render the templates TMP_FILE="/tmp/${REDIS_PORT}.conf" -DEFAULT_CONFIG="${SCRIPTPATH}/../redis.conf" +DEFAULT_CONFIG="${SCRIPTPATH}/../valkey.conf" INIT_TPL_FILE="${SCRIPTPATH}/redis_init_script.tpl" INIT_SCRIPT_DEST="/etc/init.d/redis_${REDIS_PORT}" PIDFILE="/var/run/redis_${REDIS_PORT}.pid" diff --git a/utils/systemd-redis_server.service b/utils/systemd-redis_server.service index cf158644ae..15400b439e 100644 --- a/utils/systemd-redis_server.service +++ b/utils/systemd-redis_server.service @@ -24,9 +24,9 @@ Wants=network-online.target After=network-online.target [Service] -ExecStart=/usr/local/bin/redis-server --supervised systemd --daemonize no +ExecStart=/usr/local/bin/valkey-server --supervised systemd --daemonize no ## Alternatively, have redis-server load a configuration file: -#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf +#ExecStart=/usr/local/bin/valkey-server /path/to/your/valkey.conf LimitNOFILE=10032 NoNewPrivileges=yes #OOMScoreAdjust=-900 diff --git a/redis.conf b/valkey.conf similarity index 88% rename from redis.conf rename to valkey.conf index 65e01b0742..33442b340d 100644 --- a/redis.conf +++ b/valkey.conf @@ -1,9 +1,9 @@ -# Redis configuration file example. +# Valkey configuration file example. # -# Note that in order to read the configuration file, Redis must be +# Note that in order to read the configuration file, the server must be # started with the file path as first argument: # -# ./redis-server /path/to/redis.conf +# ./valkey-server /path/to/valkey.conf # Note on units: when memory size is needed, it is possible to specify # it in the usual form of 1k 5GB 4M and so forth: @@ -20,12 +20,12 @@ ################################## INCLUDES ################################### # Include one or more other config files here. This is useful if you -# have a standard template that goes to all Redis servers but also need +# have a standard template that goes to all servers but also need # to customize a few per-server settings. Include files can include # other files, so use this wisely. # # Note that option "include" won't be rewritten by command "CONFIG REWRITE" -# from admin or Redis Sentinel. Since Redis always uses the last processed +# from admin or Sentinel. Since the server always uses the last processed # line as value of a configuration directive, you'd better put includes # at the beginning of this file to avoid overwriting config change at runtime. # @@ -55,11 +55,11 @@ ################################## NETWORK ##################################### -# By default, if no "bind" configuration directive is specified, Redis listens +# By default, if no "bind" configuration directive is specified, the server listens # for connections from all available network interfaces on the host machine. # It is possible to listen to just one or multiple selected interfaces using # the "bind" configuration directive, followed by one or more IP addresses. -# Each address can be prefixed by "-", which means that redis will not fail to +# Each address can be prefixed by "-", which means that the server will not fail to # start if the address is not available. Being not available only refers to # addresses that does not correspond to any network interface. Addresses that # are already in use will always fail, and unsupported protocols will always BE @@ -71,11 +71,11 @@ # bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6 # bind * -::* # like the default, all available interfaces # -# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the +# ~~~ WARNING ~~~ If the computer running the server is directly exposed to the # internet, binding to all the interfaces is dangerous and will expose the # instance to everybody on the internet. So by default we uncomment the -# following bind directive, that will force Redis to listen only on the -# IPv4 and IPv6 (if available) loopback interface addresses (this means Redis +# following bind directive, that will force the server to listen only on the +# IPv4 and IPv6 (if available) loopback interface addresses (this means the server # will only be able to accept client connections from the same host that it is # running on). # @@ -100,26 +100,26 @@ bind 127.0.0.1 -::1 # bind-source-addr 10.0.0.1 # Protected mode is a layer of security protection, in order to avoid that -# Redis instances left open on the internet are accessed and exploited. +# the server instances left open on the internet are accessed and exploited. # # When protected mode is on and the default user has no password, the server # only accepts local connections from the IPv4 address (127.0.0.1), IPv6 address # (::1) or Unix domain sockets. # # By default protected mode is enabled. You should disable it only if -# you are sure you want clients from other hosts to connect to Redis +# you are sure you want clients from other hosts to connect to the server # even if no authentication is configured. protected-mode yes -# Redis uses default hardened security configuration directives to reduce the +# The server uses default hardened security configuration directives to reduce the # attack surface on innocent users. Therefore, several sensitive configuration # directives are immutable, and some potentially-dangerous commands are blocked. # -# Configuration directives that control files that Redis writes to (e.g., 'dir' +# Configuration directives that control files that the server writes to (e.g., 'dir' # and 'dbfilename') and that aren't usually modified during runtime # are protected by making them immutable. # -# Commands that can increase the attack surface of Redis and that aren't usually +# Commands that can increase the attack surface of the server and that aren't usually # called by users are blocked by default. # # These can be exposed to either all connections or just local ones by setting @@ -135,7 +135,7 @@ protected-mode yes # enable-module-command no # Accept connections on the specified port, default is 6379 (IANA #815344). -# If port 0 is specified Redis will not listen on a TCP socket. +# If port 0 is specified the server will not listen on a TCP socket. port 6379 # TCP listen() backlog. @@ -150,10 +150,10 @@ tcp-backlog 511 # Unix socket. # # Specify the path for the Unix socket that will be used to listen for -# incoming connections. There is no default, so Redis will not listen +# incoming connections. There is no default, so the server will not listen # on a unix socket when not specified. # -# unixsocket /run/redis.sock +# unixsocket /run/valkey.sock # unixsocketperm 700 # Close the connection after a client is idle for N seconds (0 to disable) @@ -171,9 +171,6 @@ timeout 0 # On Linux, the specified value (in seconds) is the period used to send ACKs. # Note that to close the connection the double of the time is needed. # On other kernels the period depends on the kernel configuration. -# -# A reasonable value for this option is 300 seconds, which is the new -# Redis default starting with Redis 3.2.1. tcp-keepalive 300 # Apply OS-specific mechanism to mark the listening socket with the specified @@ -199,15 +196,15 @@ tcp-keepalive 300 # server to connected clients, masters or cluster peers. These files should be # PEM formatted. # -# tls-cert-file redis.crt -# tls-key-file redis.key +# tls-cert-file valkey.crt +# tls-key-file valkey.key # # If the key file is encrypted using a passphrase, it can be included here # as well. # # tls-key-file-pass secret -# Normally Redis uses the same certificate for both server functions (accepting +# Normally the server uses the same certificate for both server functions (accepting # connections) and client functions (replicating from a master, establishing # cluster bus connections, etc.). # @@ -228,10 +225,10 @@ tcp-keepalive 300 # required by older versions of OpenSSL (<3.0). Newer versions do not require # this configuration and recommend against it. # -# tls-dh-params-file redis.dh +# tls-dh-params-file valkey.dh # Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL -# clients and peers. Redis requires an explicit configuration of at least one +# clients and peers. The server requires an explicit configuration of at least one # of these, and will not implicitly use the system wide configuration. # # tls-ca-cert-file ca.crt @@ -247,14 +244,14 @@ tcp-keepalive 300 # tls-auth-clients no # tls-auth-clients optional -# By default, a Redis replica does not attempt to establish a TLS connection +# By default, a replica does not attempt to establish a TLS connection # with its master. # # Use the following directive to enable TLS on replication links. # # tls-replication yes -# By default, the Redis Cluster bus uses a plain TCP connection. To enable +# By default, the cluster bus uses a plain TCP connection. To enable # TLS for the bus protocol, use the following directive: # # tls-cluster yes @@ -304,18 +301,18 @@ tcp-keepalive 300 ################################# GENERAL ##################################### -# By default Redis does not run as a daemon. Use 'yes' if you need it. -# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. -# When Redis is supervised by upstart or systemd, this parameter has no impact. +# By default the server does not run as a daemon. Use 'yes' if you need it. +# Note that the server will write a pid file in /var/run/valkey.pid when daemonized. +# When the server is supervised by upstart or systemd, this parameter has no impact. daemonize no -# If you run Redis from upstart or systemd, Redis can interact with your +# If you run the server from upstart or systemd, the server can interact with your # supervision tree. Options: # supervised no - no supervision interaction -# supervised upstart - signal upstart by putting Redis into SIGSTOP mode +# supervised upstart - signal upstart by putting the server into SIGSTOP mode # requires "expect stop" in your upstart job config # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET -# on startup, and updating Redis status on a regular +# on startup, and updating the server status on a regular # basis. # supervised auto - detect upstart or systemd method based on # UPSTART_JOB or NOTIFY_SOCKET environment variables @@ -327,19 +324,19 @@ daemonize no # # supervised auto -# If a pid file is specified, Redis writes it where specified at startup +# If a pid file is specified, the server writes it where specified at startup # and removes it at exit. # # When the server runs non daemonized, no pid file is created if none is # specified in the configuration. When the server is daemonized, the pid file -# is used even if not specified, defaulting to "/var/run/redis.pid". +# is used even if not specified, defaulting to "/var/run/valkey.pid". # -# Creating a pid file is best effort: if Redis is not able to create it +# Creating a pid file is best effort: if the server is not able to create it # nothing bad happens, the server will start and run normally. # -# Note that on modern Linux systems "/run/redis.pid" is more conforming +# Note that on modern Linux systems "/run/valkey.pid" is more conforming # and should be used instead. -pidfile /var/run/redis_6379.pid +pidfile /var/run/valkey_6379.pid # Specify the server verbosity level. # This can be one of: @@ -351,7 +348,7 @@ pidfile /var/run/redis_6379.pid loglevel notice # Specify the log file name. Also the empty string can be used to force -# Redis to log on the standard output. Note that if you use standard +# the server to log on the standard output. Note that if you use standard # output for logging but daemonize, logs will be sent to /dev/null logfile "" @@ -371,7 +368,7 @@ logfile "" # crash-log-enabled no # To disable the fast memory check that's run as part of the crash log, which -# will possibly let redis terminate sooner, uncomment the following: +# will possibly let the server terminate sooner, uncomment the following: # # crash-memcheck-enabled no @@ -380,7 +377,7 @@ logfile "" # dbid is a number between 0 and 'databases'-1 databases 16 -# By default Redis shows an ASCII art logo only when started to log to the +# By default the server shows an ASCII art logo only when started to log to the # standard output and if the standard output is a TTY and syslog logging is # disabled. Basically this means that normally a logo is displayed only in # interactive sessions. @@ -389,12 +386,12 @@ databases 16 # ASCII art logo in startup logs by setting the following option to yes. always-show-logo no -# By default, Redis modifies the process title (as seen in 'top' and 'ps') to +# By default, the server modifies the process title (as seen in 'top' and 'ps') to # provide some runtime information. It is possible to disable this and leave # the process name as executed by setting the following to no. set-proc-title yes -# When changing the process title, Redis uses the following template to construct +# When changing the process title, the server uses the following template to construct # the modified title. # # Template variables are specified in curly brackets. The following variables are @@ -422,7 +419,7 @@ locale-collate "" # # save [ ...] # -# Redis will save the DB if the given number of seconds elapsed and it +# The server will save the DB if the given number of seconds elapsed and it # surpassed the given number of write operations against the DB. # # Snapshotting can be completely disabled with a single empty string argument @@ -430,7 +427,7 @@ locale-collate "" # # save "" # -# Unless specified otherwise, by default Redis will save the DB: +# Unless specified otherwise, by default the server will save the DB: # * After 3600 seconds (an hour) if at least 1 change was performed # * After 300 seconds (5 minutes) if at least 100 changes were performed # * After 60 seconds if at least 10000 changes were performed @@ -439,17 +436,17 @@ locale-collate "" # # save 3600 1 300 100 60 10000 -# By default Redis will stop accepting writes if RDB snapshots are enabled +# By default the server will stop accepting writes if RDB snapshots are enabled # (at least one save point) and the latest background save failed. # This will make the user aware (in a hard way) that data is not persisting # on disk properly, otherwise chances are that no one will notice and some # disaster will happen. # -# If the background saving process will start working again Redis will +# If the background saving process will start working again, the server will # automatically allow writes again. # -# However if you have setup your proper monitoring of the Redis server -# and persistence, you may want to disable this feature so that Redis will +# However if you have setup your proper monitoring of the server +# and persistence, you may want to disable this feature so that the server will # continue to work as usual even if there are problems with disk, # permissions, and so forth. stop-writes-on-bgsave-error yes @@ -512,18 +509,18 @@ dir ./ ################################# REPLICATION ################################# -# Master-Replica replication. Use replicaof to make a Redis instance a copy of -# another Redis server. A few things to understand ASAP about Redis replication. +# Master-Replica replication. Use replicaof to make a server a copy of +# another server. A few things to understand ASAP about replication. # # +------------------+ +---------------+ # | Master | ---> | Replica | # | (receive writes) | | (exact copy) | # +------------------+ +---------------+ # -# 1) Redis replication is asynchronous, but you can configure a master to +# 1) Replication is asynchronous, but you can configure a master to # stop accepting writes if it appears to be not connected with at least # a given number of replicas. -# 2) Redis replicas are able to perform a partial resynchronization with the +# 2) Replicas are able to perform a partial resynchronization with the # master if the replication link is lost for a relatively small amount of # time. You may want to configure the replication backlog size (see the next # sections of this file) with a sensible value depending on your needs. @@ -540,8 +537,8 @@ dir ./ # # masterauth # -# However this is not enough if you are using Redis ACLs (for Redis version -# 6 or greater), and the default user is not capable of running the PSYNC +# However this is not enough if you are using ACLs +# and the default user is not capable of running the PSYNC # command and/or other commands needed for replication. In this case it's # better to configure a special user to use with replication, and specify the # masteruser configuration as such: @@ -573,7 +570,7 @@ replica-serve-stale-data yes # may also cause problems if clients are writing to it because of a # misconfiguration. # -# Since Redis 2.6 by default replicas are read-only. +# By default, replicas are read-only. # # Note: read only replicas are not designed to be exposed to untrusted clients # on the internet. It's just a protection layer against misuse of the instance. @@ -592,10 +589,10 @@ replica-read-only yes # # The transmission can happen in two different ways: # -# 1) Disk-backed: The Redis master creates a new process that writes the RDB +# 1) Disk-backed: The master creates a new process that writes the RDB # file on disk. Later the file is transferred by the parent # process to the replicas incrementally. -# 2) Diskless: The Redis master creates a new process that directly writes the +# 2) Diskless: The master creates a new process that directly writes the # RDB file to replica sockets, without touching the disk at all. # # With disk-backed replication, while the RDB file is generated, more replicas @@ -627,13 +624,13 @@ repl-diskless-sync-delay 5 # When diskless replication is enabled with a delay, it is possible to let # the replication start before the maximum delay is reached if the maximum # number of replicas expected have connected. Default of 0 means that the -# maximum is not defined and Redis will wait the full delay. +# maximum is not defined and the server will wait the full delay. repl-diskless-sync-max-replicas 0 # ----------------------------------------------------------------------------- # WARNING: Since in this setup the replica does not immediately store an RDB on -# disk, it may cause data loss during failovers. RDB diskless load + Redis -# modules not handling I/O reads may cause Redis to abort in case of I/O errors +# disk, it may cause data loss during failovers. RDB diskless load + server +# modules not handling I/O reads may cause the server to abort in case of I/O errors # during the initial synchronization stage with the master. # ----------------------------------------------------------------------------- # @@ -683,7 +680,7 @@ repl-diskless-load disabled # Disable TCP_NODELAY on the replica socket after SYNC? # -# If you select "yes" Redis will use a smaller number of TCP packets and +# If you select "yes", the server will use a smaller number of TCP packets and # less bandwidth to send data to replicas. But this can add a delay for # the data to appear on the replica side, up to 40 milliseconds with # Linux kernels using a default configuration. @@ -722,8 +719,8 @@ repl-disable-tcp-nodelay no # # repl-backlog-ttl 3600 -# The replica priority is an integer number published by Redis in the INFO -# output. It is used by Redis Sentinel in order to select a replica to promote +# The replica priority is an integer number published by the server in the INFO +# output. It is used by Sentinel in order to select a replica to promote # into a master if the master is no longer working correctly. # # A replica with a low priority number is considered better for promotion, so @@ -732,18 +729,15 @@ repl-disable-tcp-nodelay no # # However a special priority of 0 marks the replica as not able to perform the # role of master, so a replica with priority of 0 will never be selected by -# Redis Sentinel for promotion. +# Sentinel for promotion. # # By default the priority is 100. replica-priority 100 -# The propagation error behavior controls how Redis will behave when it is +# The propagation error behavior controls how the server will behave when it is # unable to handle a command being processed in the replication stream from a master # or processed while reading from an AOF file. Errors that occur during propagation -# are unexpected, and can cause data inconsistency. However, there are edge cases -# in earlier versions of Redis where it was possible for the server to replicate or persist -# commands that would fail on future versions. For this reason the default behavior -# is to ignore such errors and continue processing commands. +# are unexpected, and can cause data inconsistency. # # If an application wants to ensure there is no data divergence, this configuration # should be set to 'panic' instead. The value can also be set to 'panic-on-replicas' @@ -756,17 +750,15 @@ replica-priority 100 # Replica ignore disk write errors controls the behavior of a replica when it is # unable to persist a write command received from its master to disk. By default, # this configuration is set to 'no' and will crash the replica in this condition. -# It is not recommended to change this default, however in order to be compatible -# with older versions of Redis this config can be toggled to 'yes' which will just -# log a warning and execute the write command it got from the master. +# It is not recommended to change this default. # # replica-ignore-disk-write-errors no # ----------------------------------------------------------------------------- -# By default, Redis Sentinel includes all replicas in its reports. A replica -# can be excluded from Redis Sentinel's announcements. An unannounced replica +# By default, Sentinel includes all replicas in its reports. A replica +# can be excluded from Sentinel's announcements. An unannounced replica # will be ignored by the 'sentinel replicas ' command and won't be -# exposed to Redis Sentinel's clients. +# exposed to Sentinel's clients. # # This option does not change the behavior of replica-priority. Even with # replica-announced set to 'no', the replica can be promoted to master. To @@ -796,10 +788,10 @@ replica-priority 100 # By default min-replicas-to-write is set to 0 (feature disabled) and # min-replicas-max-lag is set to 10. -# A Redis master is able to list the address and port of the attached +# A master is able to list the address and port of the attached # replicas in different ways. For example the "INFO replication" section # offers this information, which is used, among other tools, by -# Redis Sentinel in order to discover replica instances. +# Sentinel in order to discover replica instances. # Another place where this info is available is in the output of the # "ROLE" command of a master. # @@ -827,7 +819,7 @@ replica-priority 100 ############################### KEYS TRACKING ################################# -# Redis implements server assisted support for client side caching of values. +# The client side caching of values is assisted via server-side support. # This is implemented using an invalidation table that remembers, using # a radix key indexed by key name, what clients have which keys. In turn # this is used in order to send invalidation messages to clients. Please @@ -836,22 +828,22 @@ replica-priority 100 # https://redis.io/topics/client-side-caching # # When tracking is enabled for a client, all the read only queries are assumed -# to be cached: this will force Redis to store information in the invalidation +# to be cached: this will force the server to store information in the invalidation # table. When keys are modified, such information is flushed away, and # invalidation messages are sent to the clients. However if the workload is -# heavily dominated by reads, Redis could use more and more memory in order +# heavily dominated by reads, the server could use more and more memory in order # to track the keys fetched by many clients. # # For this reason it is possible to configure a maximum fill value for the # invalidation table. By default it is set to 1M of keys, and once this limit -# is reached, Redis will start to evict keys in the invalidation table +# is reached, the server will start to evict keys in the invalidation table # even if they were not modified, just to reclaim memory: this will in turn # force the clients to invalidate the cached values. Basically the table # maximum size is a trade off between the memory you want to spend server # side to track information about who cached what, and the ability of clients # to retain cached objects in memory. # -# If you set the value to 0, it means there are no limits, and Redis will +# If you set the value to 0, it means there are no limits, and the server will # retain as many keys as needed in the invalidation table. # In the "stats" INFO section, you can find information about the number of # keys in the invalidation table at every given moment. @@ -863,7 +855,7 @@ replica-priority 100 ################################## SECURITY ################################### -# Warning: since Redis is pretty fast, an outside user can try up to +# Warning: since the server is pretty fast, an outside user can try up to # 1 million passwords per second against a modern box. This means that you # should use very strong passwords, otherwise they will be very easy to break. # Note that because the password is really a shared secret between the client @@ -871,7 +863,7 @@ replica-priority 100 # can be easily a long string from /dev/urandom or whatever, so by using a # long and unguessable password no brute force attack will be possible. -# Redis ACL users are defined in the following format: +# ACL users are defined in the following format: # # user ... acl rules ... # @@ -902,7 +894,7 @@ replica-priority 100 # +@ Allow the execution of all the commands in such category # with valid categories are like @admin, @set, @sortedset, ... # and so forth, see the full list in the server.c file where -# the Redis command table is described and defined. +# the server command table is described and defined. # The special category @all means all the commands, but currently # present in the server, and that will be loaded in the future # via modules. @@ -1011,7 +1003,7 @@ replica-priority 100 # * stream - Data type: streams related. # # For more information about ACL configuration please refer to -# the Redis web site at https://redis.io/topics/acl +# the Valkey web site at https://redis.io/topics/acl # ACL LOG # @@ -1029,11 +1021,11 @@ acllog-max-len 128 # ACL file, the server will refuse to start. # # The format of the external ACL user file is exactly the same as the -# format that is used inside redis.conf to describe users. +# format that is used inside valkey.conf to describe users. # -# aclfile /etc/redis/users.acl +# aclfile /etc/valkey/users.acl -# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility +# IMPORTANT NOTE: "requirepass" is just a compatibility # layer on top of the new ACL system. The option effect will be just setting # the password for the default user. Clients will still authenticate using # AUTH as usually, or more explicitly with AUTH default @@ -1044,16 +1036,13 @@ acllog-max-len 128 # # requirepass foobared -# New users are initialized with restrictive permissions by default, via the -# equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it -# is possible to manage access to Pub/Sub channels with ACL rules as well. The -# default Pub/Sub channels permission if new users is controlled by the +# The default Pub/Sub channels permission for new users is controlled by the # acl-pubsub-default configuration directive, which accepts one of these values: # # allchannels: grants access to all Pub/Sub channels # resetchannels: revokes access to all Pub/Sub channels # -# From Redis 7.0, acl-pubsub-default defaults to 'resetchannels' permission. +# acl-pubsub-default defaults to 'resetchannels' permission. # # acl-pubsub-default resetchannels @@ -1085,15 +1074,15 @@ acllog-max-len 128 ################################### CLIENTS #################################### # Set the max number of connected clients at the same time. By default -# this limit is set to 10000 clients, however if the Redis server is not +# this limit is set to 10000 clients, however if the server is not # able to configure the process file limit to allow for the specified limit # the max number of allowed clients is set to the current file limit -# minus 32 (as Redis reserves a few file descriptors for internal uses). +# minus 32 (as the server reserves a few file descriptors for internal uses). # -# Once the limit is reached Redis will close all the new connections sending +# Once the limit is reached the server will close all the new connections sending # an error 'max number of clients reached'. # -# IMPORTANT: When Redis Cluster is used, the max number of connections is also +# IMPORTANT: With a cluster-enabled setup, the max number of connections is also # shared with the cluster bus: every node in the cluster will use two # connections, one incoming and another outgoing. It is important to size the # limit accordingly in case of very large clusters. @@ -1103,15 +1092,15 @@ acllog-max-len 128 ############################## MEMORY MANAGEMENT ################################ # Set a memory usage limit to the specified amount of bytes. -# When the memory limit is reached Redis will try to remove keys +# When the memory limit is reached the server will try to remove keys # according to the eviction policy selected (see maxmemory-policy). # -# If Redis can't remove keys according to the policy, or if the policy is -# set to 'noeviction', Redis will start to reply with errors to commands +# If the server can't remove keys according to the policy, or if the policy is +# set to 'noeviction', the server will start to reply with errors to commands # that would use more memory, like SET, LPUSH, and so on, and will continue # to reply to read-only commands like GET. # -# This option is usually useful when using Redis as an LRU or LFU cache, or to +# This option is usually useful when using the server as an LRU or LFU cache, or to # set a hard memory limit for an instance (using the 'noeviction' policy). # # WARNING: If you have replicas attached to an instance with maxmemory on, @@ -1127,7 +1116,7 @@ acllog-max-len 128 # # maxmemory -# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory +# MAXMEMORY POLICY: how the server will select what to remove when maxmemory # is reached. You can select one from the following behaviors: # # volatile-lru -> Evict using approximated LRU, only keys with an expire set. @@ -1146,7 +1135,7 @@ acllog-max-len 128 # randomized algorithms. # # Note: with any of the above policies, when there are no suitable keys for -# eviction, Redis will return an error on write operations that require +# eviction, the server will return an error on write operations that require # more memory. These are usually commands that create new keys, add data or # modify existing keys. A few examples are: SET, INCR, HSET, LPUSH, SUNIONSTORE, # SORT (due to the STORE argument), and EXEC (if the transaction includes any @@ -1158,7 +1147,7 @@ acllog-max-len 128 # LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated # algorithms (in order to save memory), so you can tune it for speed or -# accuracy. By default Redis will check five keys and pick the one that was +# accuracy. By default the server will check five keys and pick the one that was # used least recently, you can change the sample size using the following # configuration directive. # @@ -1176,7 +1165,7 @@ acllog-max-len 128 # # maxmemory-eviction-tenacity 10 -# Starting from Redis 5, by default a replica will ignore its maxmemory setting +# By default a replica will ignore its maxmemory setting # (unless it is promoted to master after a failover or manually). It means # that the eviction of keys will be just handled by the master, sending the # DEL commands to the replica as keys evict in the master side. @@ -1196,7 +1185,7 @@ acllog-max-len 128 # # replica-ignore-maxmemory yes -# Redis reclaims expired keys in two ways: upon access when those keys are +# The server reclaims expired keys in two ways: upon access when those keys are # found to be expired, and also in background, in what is called the # "active expire key". The key space is slowly and interactively scanned # looking for expired keys to reclaim, so that it is possible to free memory @@ -1215,16 +1204,16 @@ acllog-max-len 128 ############################# LAZY FREEING #################################### -# Redis has two primitives to delete keys. One is called DEL and is a blocking +# The server has two primitives to delete keys. One is called DEL and is a blocking # deletion of the object. It means that the server stops processing new commands # in order to reclaim all the memory associated with an object in a synchronous # way. If the key deleted is associated with a small object, the time needed # in order to execute the DEL command is very small and comparable to most other -# O(1) or O(log_N) commands in Redis. However if the key is associated with an +# O(1) or O(log_N) commands in the server. However if the key is associated with an # aggregated value containing millions of elements, the server can block for # a long time (even seconds) in order to complete the operation. # -# For the above reasons Redis also offers non blocking deletion primitives +# For the above reasons the server also offers non blocking deletion primitives # such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and # FLUSHDB commands, in order to reclaim memory in background. Those commands # are executed in constant time. Another thread will incrementally free the @@ -1232,9 +1221,9 @@ acllog-max-len 128 # # DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled. # It's up to the design of the application to understand when it is a good -# idea to use one or the other. However the Redis server sometimes has to +# idea to use one or the other. However the server sometimes has to # delete keys or flush the whole database as a side effect of other operations. -# Specifically Redis deletes objects independently of a user call in the +# Specifically the server deletes objects independently of a user call in the # following scenarios: # # 1) On eviction, because of the maxmemory and maxmemory policy configurations, @@ -1278,21 +1267,21 @@ lazyfree-lazy-user-flush no ################################ THREADED I/O ################################# -# Redis is mostly single threaded, however there are certain threaded +# The server is mostly single threaded, however there are certain threaded # operations such as UNLINK, slow I/O accesses and other things that are # performed on side threads. # -# Now it is also possible to handle Redis clients socket reads and writes +# Now it is also possible to handle the server clients socket reads and writes # in different I/O threads. Since especially writing is so slow, normally -# Redis users use pipelining in order to speed up the Redis performances per +# users use pipelining in order to speed up the server performances per # core, and spawn multiple instances in order to scale more. Using I/O -# threads it is possible to easily speedup two times Redis without resorting +# threads it is possible to easily speedup two times the server without resorting # to pipelining nor sharding of the instance. # # By default threading is disabled, we suggest enabling it only in machines # that have at least 4 or more cores, leaving at least one spare core. # Using more than 8 threads is unlikely to help much. We also recommend using -# threaded I/O only if you actually have performance problems, with Redis +# threaded I/O only if you actually have performance problems, with # instances being able to use a quite big percentage of CPU time, otherwise # there is no point in using this feature. # @@ -1317,9 +1306,9 @@ lazyfree-lazy-user-flush no # CONFIG SET. Also, this feature currently does not work when SSL is # enabled. # -# NOTE 2: If you want to test the Redis speedup using redis-benchmark, make +# NOTE 2: If you want to test the server speedup using valkey-benchmark, make # sure you also run the benchmark itself in threaded mode, using the -# --threads option to match the number of Redis threads, otherwise you'll not +# --threads option to match the number of server threads, otherwise you'll not # be able to notice the improvements. ############################ KERNEL OOM CONTROL ############################## @@ -1327,12 +1316,12 @@ lazyfree-lazy-user-flush no # On Linux, it is possible to hint the kernel OOM killer on what processes # should be killed first when out of memory. # -# Enabling this feature makes Redis actively control the oom_score_adj value +# Enabling this feature makes the server actively control the oom_score_adj value # for all its processes, depending on their role. The default scores will # attempt to have background child processes killed before all others, and # replicas killed before masters. # -# Redis supports these options: +# The server supports these options: # # no: Don't make changes to oom-score-adj (default). # yes: Alias to "relative" see below. @@ -1359,7 +1348,7 @@ oom-score-adj-values 0 200 800 # Usually the kernel Transparent Huge Pages control is set to "madvise" or # or "never" by default (/sys/kernel/mm/transparent_hugepage/enabled), in which # case this config has no effect. On systems in which it is set to "always", -# redis will attempt to disable it specifically for the redis process in order +# the server will attempt to disable it specifically for the server process in order # to avoid latency problems specifically with fork(2) and CoW. # If for some reason you prefer to keep it enabled, you can set this config to # "no" and the kernel global to "always". @@ -1368,20 +1357,20 @@ disable-thp yes ############################## APPEND ONLY MODE ############################### -# By default Redis asynchronously dumps the dataset on disk. This mode is -# good enough in many applications, but an issue with the Redis process or +# By default the server asynchronously dumps the dataset on disk. This mode is +# good enough in many applications, but an issue with the server process or # a power outage may result into a few minutes of writes lost (depending on # the configured save points). # # The Append Only File is an alternative persistence mode that provides # much better durability. For instance using the default data fsync policy -# (see later in the config file) Redis can lose just one second of writes in a +# (see later in the config file) the server can lose just one second of writes in a # dramatic event like a server power outage, or a single write if something -# wrong with the Redis process itself happens, but the operating system is +# wrong with the process itself happens, but the operating system is # still running correctly. # # AOF and RDB persistence can be enabled at the same time without problems. -# If the AOF is enabled on startup Redis will load the AOF, that is the file +# If the AOF is enabled on startup the server will load the AOF, that is the file # with the better durability guarantees. # # Note that changing this value in a config file of an existing database and @@ -1394,7 +1383,7 @@ appendonly no # The base name of the append only file. # -# Redis 7 and newer use a set of append-only files to persist the dataset +# The server uses a set of append-only files to persist the dataset # and changes applied to it. There are two basic types of files in use: # # - Base files, which are a snapshot representing the complete state of the @@ -1406,7 +1395,7 @@ appendonly no # In addition, manifest files are used to track the files and the order in # which they were created and should be applied. # -# Append-only file names are created by Redis following a specific pattern. +# Append-only file names are created by the server following a specific pattern. # The file name's prefix is based on the 'appendfilename' configuration # parameter, followed by additional information about the sequence and type. # @@ -1419,7 +1408,7 @@ appendonly no appendfilename "appendonly.aof" -# For convenience, Redis stores all persistent append-only files in a dedicated +# For convenience, the server stores all persistent append-only files in a dedicated # directory. The name of the directory is determined by the appenddirname # configuration parameter. @@ -1429,7 +1418,7 @@ appenddirname "appendonlydir" # instead of waiting for more data in the output buffer. Some OS will really flush # data on disk, some other OS will just try to do it ASAP. # -# Redis supports three different modes: +# The server supports three different modes: # # no: don't fsync, just let the OS flush the data when it wants. Faster. # always: fsync after every write to the append only log. Slow, Safest. @@ -1455,7 +1444,7 @@ appendfsync everysec # When the AOF fsync policy is set to always or everysec, and a background # saving process (a background save or AOF log background rewriting) is # performing a lot of I/O against the disk, in some Linux configurations -# Redis may block too long on the fsync() call. Note that there is no fix for +# the server may block too long on the fsync() call. Note that there is no fix for # this currently, as even performing fsync in a different thread will block # our synchronous write(2) call. # @@ -1463,7 +1452,7 @@ appendfsync everysec # that will prevent fsync() from being called in the main process while a # BGSAVE or BGREWRITEAOF is in progress. # -# This means that while another child is saving, the durability of Redis is +# This means that while another child is saving, the durability of the server is # the same as "appendfsync no". In practical terms, this means that it is # possible to lose up to 30 seconds of log in the worst scenario (with the # default Linux settings). @@ -1474,10 +1463,10 @@ appendfsync everysec no-appendfsync-on-rewrite no # Automatic rewrite of the append only file. -# Redis is able to automatically rewrite the log file implicitly calling +# The server is able to automatically rewrite the log file implicitly calling # BGREWRITEAOF when the AOF log size grows by the specified percentage. # -# This is how it works: Redis remembers the size of the AOF file after the +# This is how it works: The server remembers the size of the AOF file after the # latest rewrite (if no rewrite has happened since the restart, the size of # the AOF at startup is used). # @@ -1493,36 +1482,36 @@ no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb -# An AOF file may be found to be truncated at the end during the Redis +# An AOF file may be found to be truncated at the end during the server # startup process, when the AOF data gets loaded back into memory. -# This may happen when the system where Redis is running +# This may happen when the system where the server is running # crashes, especially when an ext4 filesystem is mounted without the -# data=ordered option (however this can't happen when Redis itself +# data=ordered option (however this can't happen when the server itself # crashes or aborts but the operating system still works correctly). # -# Redis can either exit with an error when this happens, or load as much +# The server can either exit with an error when this happens, or load as much # data as possible (the default now) and start if the AOF file is found # to be truncated at the end. The following option controls this behavior. # # If aof-load-truncated is set to yes, a truncated AOF file is loaded and -# the Redis server starts emitting a log to inform the user of the event. +# the server starts emitting a log to inform the user of the event. # Otherwise if the option is set to no, the server aborts with an error # and refuses to start. When the option is set to no, the user requires -# to fix the AOF file using the "redis-check-aof" utility before to restart +# to fix the AOF file using the "valkey-check-aof" utility before to restart # the server. # # Note that if the AOF file will be found to be corrupted in the middle # the server will still exit with an error. This option only applies when -# Redis will try to read more data from the AOF file but not enough bytes +# the server will try to read more data from the AOF file but not enough bytes # will be found. aof-load-truncated yes -# Redis can create append-only base files in either RDB or AOF formats. Using +# The server can create append-only base files in either RDB or AOF formats. Using # the RDB format is always faster and more efficient, and disabling it is only # supported for backward compatibility purposes. aof-use-rdb-preamble yes -# Redis supports recording timestamp annotations in the AOF to support restoring +# The server supports recording timestamp annotations in the AOF to support restoring # the data from a specific point-in-time. However, using this capability changes # the AOF format in a way that may not be compatible with existing AOF parsers. aof-timestamp-enabled no @@ -1541,7 +1530,7 @@ aof-timestamp-enabled no # # shutdown-timeout 10 -# When Redis receives a SIGINT or SIGTERM, shutdown is initiated and by default +# When the server receives a SIGINT or SIGTERM, shutdown is initiated and by default # an RDB snapshot is written to disk in a blocking operation if save points are configured. # The options used on signaled shutdown can include the following values: # default: Saves RDB snapshot only if save points are configured. @@ -1560,12 +1549,12 @@ aof-timestamp-enabled no ################ NON-DETERMINISTIC LONG BLOCKING COMMANDS ##################### # Maximum time in milliseconds for EVAL scripts, functions and in some cases -# modules' commands before Redis can start processing or rejecting other clients. +# modules' commands before the server can start processing or rejecting other clients. # -# If the maximum execution time is reached Redis will start to reply to most +# If the maximum execution time is reached the server will start to reply to most # commands with a BUSY error. # -# In this state Redis will only allow a handful of commands to be executed. +# In this state the server will only allow a handful of commands to be executed. # For instance, SCRIPT KILL, FUNCTION KILL, SHUTDOWN NOSAVE and possibly some # module specific 'allow-busy' commands. # @@ -1581,17 +1570,17 @@ aof-timestamp-enabled no # lua-time-limit 5000 # busy-reply-threshold 5000 -################################ REDIS CLUSTER ############################### +################################ VALKEY CLUSTER ############################### -# Normal Redis instances can't be part of a Redis Cluster; only nodes that are -# started as cluster nodes can. In order to start a Redis instance as a +# Normal server instances can't be part of a cluster; only nodes that are +# started as cluster nodes can. In order to start a server instance as a # cluster node enable the cluster support uncommenting the following: # # cluster-enabled yes # Every cluster node has a cluster configuration file. This file is not -# intended to be edited by hand. It is created and updated by Redis nodes. -# Every Redis Cluster node requires a different cluster configuration file. +# intended to be edited by hand. It is created and updated by each node. +# Every cluster node requires a different cluster configuration file. # Make sure that instances running in the same system do not have # overlapping cluster configuration file names. # @@ -1681,7 +1670,7 @@ aof-timestamp-enabled no # # cluster-allow-replica-migration yes -# By default Redis Cluster nodes stop accepting queries if they detect there +# By default cluster nodes stop accepting queries if they detect there # is at least a hash slot uncovered (no available node is serving it). # This way if the cluster is partially down (for example a range of hash slots # are no longer covered) all the cluster becomes, eventually, unavailable. @@ -1776,11 +1765,11 @@ aof-timestamp-enabled no ########################## CLUSTER DOCKER/NAT support ######################## -# In certain deployments, Redis Cluster nodes address discovery fails, because +# In certain deployments, cluster node's address discovery fails, because # addresses are NAT-ted or because ports are forwarded (the typical case is # Docker and other containers). # -# In order to make Redis Cluster working in such environments, a static +# In order to make a cluster work in such environments, a static # configuration where each node knows its public address is needed. The # following four options are used for this scope, and are: # @@ -1798,7 +1787,7 @@ aof-timestamp-enabled no # to zero, then cluster-announce-port refers to the TLS port. Note also that # cluster-announce-tls-port has no effect if tls-cluster is set to no. # -# If the above options are not used, the normal Redis Cluster auto-detection +# If the above options are not used, the normal cluster auto-detection # will be used instead. # # Note that when remapped, the bus port may not be at the fixed offset of @@ -1815,14 +1804,14 @@ aof-timestamp-enabled no ################################## SLOW LOG ################################### -# The Redis Slow Log is a system to log queries that exceeded a specified +# The server Slow Log is a system to log queries that exceeded a specified # execution time. The execution time does not include the I/O operations # like talking with the client, sending the reply and so forth, # but just the time needed to actually execute the command (this is the only # stage of command execution where the thread is blocked and can not serve # other requests in the meantime). # -# You can configure the slow log with two parameters: one tells Redis +# You can configure the slow log with two parameters: one tells the server # what is the execution time, in microseconds, to exceed in order for the # command to get logged, and the other parameter is the length of the # slow log. When a new command is logged the oldest one is removed from the @@ -1839,9 +1828,9 @@ slowlog-max-len 128 ################################ LATENCY MONITOR ############################## -# The Redis latency monitoring subsystem samples different operations +# The server latency monitoring subsystem samples different operations # at runtime in order to collect data related to possible sources of -# latency of a Redis instance. +# latency of a server instance. # # Via the LATENCY command this information is available to the user that can # print graphs and obtain reports. @@ -1860,7 +1849,7 @@ latency-monitor-threshold 0 ################################ LATENCY TRACKING ############################## -# The Redis extended latency monitoring tracks the per command latencies and enables +# The server's extended latency monitoring tracks the per command latencies and enables # exporting the percentile distribution via the INFO latencystats command, # and cumulative latency distributions (histograms) via the LATENCY command. # @@ -1874,7 +1863,7 @@ latency-monitor-threshold 0 ############################# EVENT NOTIFICATION ############################## -# Redis can notify Pub/Sub clients about events happening in the key space. +# The server can notify Pub/Sub clients about events happening in the key space. # This feature is documented at https://redis.io/topics/notifications # # For instance if keyspace events notification is enabled, and a client @@ -1884,7 +1873,7 @@ latency-monitor-threshold 0 # PUBLISH __keyspace@0__:foo del # PUBLISH __keyevent@0__:del foo # -# It is possible to select the events that Redis will notify among a set +# It is possible to select the events that the server will notify among a set # of classes. Every class is identified by a single character: # # K Keyspace events, published with __keyspace@__ prefix. @@ -2009,8 +1998,8 @@ stream-node-max-bytes 4096 stream-node-max-entries 100 # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in -# order to help rehashing the main Redis hash table (the one mapping top-level -# keys to values). The hash table implementation Redis uses (see dict.c) +# order to help rehashing the main server hash table (the one mapping top-level +# keys to values). The hash table implementation the server uses (see dict.c) # performs a lazy rehashing: the more operation you run into a hash table # that is rehashing, the more rehashing "steps" are performed, so if the # server is idle the rehashing is never complete and some more memory is used @@ -2021,7 +2010,7 @@ stream-node-max-entries 100 # # If unsure: # use "activerehashing no" if you have hard latency requirements and it is -# not a good thing in your environment that Redis can reply from time to time +# not a good thing in your environment that the server can reply from time to time # to queries with 2 milliseconds delay. # # use "activerehashing yes" if you don't have such hard requirements but @@ -2099,21 +2088,21 @@ client-output-buffer-limit pubsub 32mb 8mb 60 # eviction at 5% of maxmemory: # maxmemory-clients 5% -# In the Redis protocol, bulk requests, that are, elements representing single +# In the server protocol, bulk requests, that are, elements representing single # strings, are normally limited to 512 mb. However you can change this limit # here, but must be 1mb or greater # # proto-max-bulk-len 512mb -# Redis calls an internal function to perform many background tasks, like +# The server calls an internal function to perform many background tasks, like # closing connections of clients in timeout, purging expired keys that are # never requested, and so forth. # -# Not all tasks are performed with the same frequency, but Redis checks for +# Not all tasks are performed with the same frequency, but the server checks for # tasks to perform according to the specified "hz" value. # # By default "hz" is set to 10. Raising the value will use more CPU when -# Redis is idle, but at the same time will make Redis more responsive when +# the server is idle, but at the same time will make the server more responsive when # there are many keys expiring at the same time, and timeouts may be # handled with more precision. # @@ -2127,7 +2116,7 @@ hz 10 # avoid too many clients are processed for each background task invocation # in order to avoid latency spikes. # -# Since the default HZ value by default is conservatively set to 10, Redis +# Since the default HZ value by default is conservatively set to 10, the server # offers, and enables by default, the ability to use an adaptive HZ value # which will temporarily raise when there are many connected clients. # @@ -2144,22 +2133,22 @@ dynamic-hz yes # big latency spikes. aof-rewrite-incremental-fsync yes -# When redis saves RDB file, if the following option is enabled +# When the server saves RDB file, if the following option is enabled # the file will be fsync-ed every 4 MB of data generated. This is useful # in order to commit the file to the disk more incrementally and avoid # big latency spikes. rdb-save-incremental-fsync yes -# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good +# The server's LFU eviction (see maxmemory setting) can be tuned. However it is a good # idea to start with the default settings and only change them after investigating # how to improve the performances and how the keys LFU change over time, which # is possible to inspect via the OBJECT FREQ command. # -# There are two tunable parameters in the Redis LFU implementation: the +# There are two tunable parameters in the server LFU implementation: the # counter logarithm factor and the counter decay time. It is important to # understand what the two parameters mean before changing them. # -# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis +# The LFU counter is just 8 bits per key, it's maximum value is 255, so the server # uses a probabilistic increment with logarithmic behavior. Given the value # of the old counter, when a key is accessed, the counter is incremented in # this way: @@ -2186,8 +2175,8 @@ rdb-save-incremental-fsync yes # # NOTE: The above table was obtained by running the following commands: # -# redis-benchmark -n 1000000 incr foo -# redis-cli object freq foo +# valkey-benchmark -n 1000000 incr foo +# valkey-cli object freq foo # # NOTE 2: The counter initial value is 5 in order to give new objects a chance # to accumulate hits. @@ -2226,7 +2215,7 @@ rdb-save-incremental-fsync yes # What is active defragmentation? # ------------------------------- # -# Active (online) defragmentation allows a Redis server to compact the +# Active (online) defragmentation allows a server to compact the # spaces left between small allocations and deallocations of data in memory, # thus allowing to reclaim back memory. # @@ -2234,11 +2223,11 @@ rdb-save-incremental-fsync yes # less so with Jemalloc, fortunately) and certain workloads. Normally a server # restart is needed in order to lower the fragmentation, or at least to flush # away all the data and create it again. However thanks to this feature -# implemented by Oran Agra for Redis 4.0 this process can happen at runtime +# implemented by Oran Agra, this process can happen at runtime # in a "hot" way, while the server is running. # # Basically when the fragmentation is over a certain level (see the -# configuration options below) Redis will start to create new copies of the +# configuration options below) the server will start to create new copies of the # values in contiguous memory regions by exploiting certain specific Jemalloc # features (in order to understand if an allocation is causing fragmentation # and to allocate it in a better place), and at the same time, will release the @@ -2247,8 +2236,8 @@ rdb-save-incremental-fsync yes # # Important things to understand: # -# 1. This feature is disabled by default, and only works if you compiled Redis -# to use the copy of Jemalloc we ship with the source code of Redis. +# 1. This feature is disabled by default, and only works if you compiled the server +# to use the copy of Jemalloc we ship with the source code of the server. # This is the default with Linux builds. # # 2. You never need to enable this feature if you don't have fragmentation @@ -2288,20 +2277,20 @@ rdb-save-incremental-fsync yes # Jemalloc background thread for purging will be enabled by default jemalloc-bg-thread yes -# It is possible to pin different threads and processes of Redis to specific +# It is possible to pin different threads and processes of the server to specific # CPUs in your system, in order to maximize the performances of the server. -# This is useful both in order to pin different Redis threads in different -# CPUs, but also in order to make sure that multiple Redis instances running +# This is useful both in order to pin different server threads in different +# CPUs, but also in order to make sure that multiple server instances running # in the same host will be pinned to different CPUs. # # Normally you can do this using the "taskset" command, however it is also -# possible to this via Redis configuration directly, both in Linux and FreeBSD. +# possible to do this via the server configuration directly, both in Linux and FreeBSD. # # You can pin the server/IO threads, bio threads, aof rewrite child process, and # the bgsave child process. The syntax to specify the cpu list is the same as # the taskset command: # -# Set redis server/io threads to cpu affinity 0,2,4,6: +# Set server/io threads to cpu affinity 0,2,4,6: # server-cpulist 0-7:2 # # Set bio threads to cpu affinity 1,3: @@ -2313,7 +2302,7 @@ jemalloc-bg-thread yes # Set bgsave child process to cpu affinity 1,10,11 # bgsave-cpulist 1,10-11 -# In some cases redis will emit warnings and even refuse to start if it detects +# In some cases the server will emit warnings and even refuse to start if it detects # that the system is in bad state, it is possible to suppress these warnings # by setting the following config which takes a space delimited list of warnings # to suppress From add5f5615cd3206dc859476b13a81a3b4da287ee Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:24:01 +0700 Subject: [PATCH 38/98] Rename some redis structs to server (#178) - redisFunctionSym -> serverFunctionSym - redisSortObject -> serverSortObject - redisSortOperation -> serverSortOperation #144 Signed-off-by: 0del --- src/server.h | 10 +++++----- src/sort.c | 18 +++++++++--------- utils/build-static-symbols.tcl | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/server.h b/src/server.h index b248445da0..3b05c7ca33 100644 --- a/src/server.h +++ b/src/server.h @@ -2390,23 +2390,23 @@ struct serverError { long long count; }; -struct redisFunctionSym { +struct serverFunctionSym { char *name; unsigned long pointer; }; -typedef struct _redisSortObject { +typedef struct _serverSortObject { robj *obj; union { double score; robj *cmpobj; } u; -} redisSortObject; +} serverSortObject; -typedef struct _redisSortOperation { +typedef struct _serverSortOperation { int type; robj *pattern; -} redisSortOperation; +} serverSortOperation; /* Structure to hold list iteration abstraction. */ typedef struct { diff --git a/src/sort.c b/src/sort.c index 86255ca265..78d15a7199 100644 --- a/src/sort.c +++ b/src/sort.c @@ -36,8 +36,8 @@ zskiplistNode* zslGetElementByRank(zskiplist *zsl, unsigned long rank); -redisSortOperation *createSortOperation(int type, robj *pattern) { - redisSortOperation *so = zmalloc(sizeof(*so)); +serverSortOperation *createSortOperation(int type, robj *pattern) { + serverSortOperation *so = zmalloc(sizeof(*so)); so->type = type; so->pattern = pattern; return so; @@ -137,7 +137,7 @@ robj *lookupKeyByPattern(serverDb *db, robj *pattern, robj *subst) { * the additional parameter is not standard but a BSD-specific we have to * pass sorting parameters via the global 'server' structure */ int sortCompare(const void *s1, const void *s2) { - const redisSortObject *so1 = s1, *so2 = s2; + const serverSortObject *so1 = s1, *so2 = s2; int cmp; if (!server.sort_alpha) { @@ -197,7 +197,7 @@ void sortCommandGeneric(client *c, int readonly) { int int_conversion_error = 0; int syntax_error = 0; robj *sortval, *sortby = NULL, *storekey = NULL; - redisSortObject *vector; /* Resulting vector to sort */ + serverSortObject *vector; /* Resulting vector to sort */ int user_has_full_key_access = 0; /* ACL - used in order to verify 'get' and 'by' options can be used */ /* Create a list of operations to perform for every sorted element. * Operations can be GET */ @@ -363,7 +363,7 @@ void sortCommandGeneric(client *c, int readonly) { } /* Load the sorting vector with all the objects to sort */ - vector = zmalloc(sizeof(redisSortObject)*vectorlen); + vector = zmalloc(sizeof(serverSortObject)*vectorlen); j = 0; if (sortval->type == OBJ_LIST && dontsort) { @@ -516,9 +516,9 @@ void sortCommandGeneric(client *c, int readonly) { server.sort_bypattern = sortby ? 1 : 0; server.sort_store = storekey ? 1 : 0; if (sortby && (start != 0 || end != vectorlen-1)) - pqsort(vector,vectorlen,sizeof(redisSortObject),sortCompare, start,end); + pqsort(vector,vectorlen,sizeof(serverSortObject),sortCompare, start,end); else - qsort(vector,vectorlen,sizeof(redisSortObject),sortCompare); + qsort(vector,vectorlen,sizeof(serverSortObject),sortCompare); } /* Send command output to the output buffer, performing the specified @@ -536,7 +536,7 @@ void sortCommandGeneric(client *c, int readonly) { if (!getop) addReplyBulk(c,vector[j].obj); listRewind(operations,&li); while((ln = listNext(&li))) { - redisSortOperation *sop = ln->value; + serverSortOperation *sop = ln->value; robj *val = lookupKeyByPattern(c->db,sop->pattern, vector[j].obj); @@ -568,7 +568,7 @@ void sortCommandGeneric(client *c, int readonly) { } else { listRewind(operations,&li); while((ln = listNext(&li))) { - redisSortOperation *sop = ln->value; + serverSortOperation *sop = ln->value; robj *val = lookupKeyByPattern(c->db,sop->pattern, vector[j].obj); diff --git a/utils/build-static-symbols.tcl b/utils/build-static-symbols.tcl index e634cbe0ff..0aa8f72402 100644 --- a/utils/build-static-symbols.tcl +++ b/utils/build-static-symbols.tcl @@ -12,7 +12,7 @@ while {[gets $fd line] != -1} { } } set symlist [lsort -unique $symlist] -puts "static struct redisFunctionSym symsTable\[\] = {" +puts "static struct serverFunctionSym symsTable\[\] = {" foreach sym $symlist { puts "{\"$sym\",(unsigned long)$sym}," } From f753db514166c1e2cbb63a6cbbf4c5f3722204e2 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:26:33 +0700 Subject: [PATCH 39/98] rename redis functions in server.h (#179) redisPopcount -> serverPopcount redisSetProcTitle -> serverSetProcTitle redisCommunicateSystemd -> serverCommunicateSystemd redisSetCpuAffinity -> serverSetCpuAffinity redisFork -> serverFork #144 Signed-off-by: 0del --- src/aof.c | 6 +++--- src/bio.c | 2 +- src/bitops.c | 6 +++--- src/cluster_legacy.c | 2 +- src/config.c | 2 +- src/eval.c | 2 +- src/module.c | 4 ++-- src/networking.c | 2 +- src/rdb.c | 12 ++++++------ src/replication.c | 4 ++-- src/server.c | 36 ++++++++++++++++++------------------ src/server.h | 10 +++++----- 12 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/aof.c b/src/aof.c index cb9c431364..c775d5b612 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2467,12 +2467,12 @@ int rewriteAppendOnlyFileBackground(void) { server.stat_aof_rewrites++; - if ((childpid = redisFork(CHILD_TYPE_AOF)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_AOF)) == 0) { char tmpfile[256]; /* Child */ - redisSetProcTitle("redis-aof-rewrite"); - redisSetCpuAffinity(server.aof_rewrite_cpulist); + serverSetProcTitle("redis-aof-rewrite"); + serverSetCpuAffinity(server.aof_rewrite_cpulist); snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid()); if (rewriteAppendOnlyFile(tmpfile) == C_OK) { serverLog(LL_NOTICE, diff --git a/src/bio.c b/src/bio.c index 10ecf8db29..da62222426 100644 --- a/src/bio.c +++ b/src/bio.c @@ -212,7 +212,7 @@ void *bioProcessBackgroundJobs(void *arg) { redis_set_thread_title(bio_worker_title[worker]); - redisSetCpuAffinity(server.bio_cpulist); + serverSetCpuAffinity(server.bio_cpulist); makeThreadKillable(); diff --git a/src/bitops.c b/src/bitops.c index 925c2a71dd..bc76d9acb5 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -37,7 +37,7 @@ /* Count number of bits set in the binary array pointed by 's' and long * 'count' bytes. The implementation of this function is required to * work with an input string length up to 512 MB or more (server.proto_max_bulk_len) */ -long long redisPopcount(void *s, long count) { +long long serverPopcount(void *s, long count) { long long bits = 0; unsigned char *p = s; uint32_t *p4; @@ -870,7 +870,7 @@ void bitcountCommand(client *c) { addReply(c,shared.czero); } else { long bytes = (long)(end-start+1); - long long count = redisPopcount(p+start,bytes); + long long count = serverPopcount(p+start,bytes); if (first_byte_neg_mask != 0 || last_byte_neg_mask != 0) { unsigned char firstlast[2] = {0, 0}; /* We may count bits of first byte and last byte which are out of @@ -878,7 +878,7 @@ void bitcountCommand(client *c) { * bits in the range to zero. So these bit will not be excluded. */ if (first_byte_neg_mask != 0) firstlast[0] = p[start] & first_byte_neg_mask; if (last_byte_neg_mask != 0) firstlast[1] = p[end] & last_byte_neg_mask; - count -= redisPopcount(firstlast,2); + count -= serverPopcount(firstlast,2); } addReplyLongLong(c,count); } diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 4e4f9425d6..edb510d6e1 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -805,7 +805,7 @@ int clusterLockConfig(char *filename) { * we'll retain the lock to the file as long as the process exists. * * After fork, the child process will get the fd opened by the parent process, - * we need save `fd` to `cluster_config_file_lock_fd`, so that in redisFork(), + * we need save `fd` to `cluster_config_file_lock_fd`, so that in serverFork(), * it will be closed in the child process. * If it is not closed, when the main process is killed -9, but the child process * (redis-aof-rewrite) is still alive, the fd(lock) will still be held by the diff --git a/src/config.c b/src/config.c index 888567a157..8b193891cf 100644 --- a/src/config.c +++ b/src/config.c @@ -2445,7 +2445,7 @@ static int updateLocaleCollate(const char **err) { } static int updateProcTitleTemplate(const char **err) { - if (redisSetProcTitle(NULL) == C_ERR) { + if (serverSetProcTitle(NULL) == C_ERR) { *err = "failed to set process title"; return 0; } diff --git a/src/eval.c b/src/eval.c index a0e6a65737..2561322f3d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -865,7 +865,7 @@ void ldbSendLogs(void) { int ldbStartSession(client *c) { ldb.forked = (c->flags & CLIENT_LUA_DEBUG_SYNC) == 0; if (ldb.forked) { - pid_t cp = redisFork(CHILD_TYPE_LDB); + pid_t cp = serverFork(CHILD_TYPE_LDB); if (cp == -1) { addReplyErrorFormat(c,"Fork() failed: can't run EVAL in debugging mode: %s", strerror(errno)); return 0; diff --git a/src/module.c b/src/module.c index af0d92cf8b..2314845461 100644 --- a/src/module.c +++ b/src/module.c @@ -11248,9 +11248,9 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { pid_t childpid; - if ((childpid = redisFork(CHILD_TYPE_MODULE)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_MODULE)) == 0) { /* Child */ - redisSetProcTitle("redis-module-fork"); + serverSetProcTitle("redis-module-fork"); } else if (childpid == -1) { serverLog(LL_WARNING,"Can't fork for module: %s", strerror(errno)); } else { diff --git a/src/networking.c b/src/networking.c index 90825ca284..e979e2ecc3 100644 --- a/src/networking.c +++ b/src/networking.c @@ -4226,7 +4226,7 @@ void *IOThreadMain(void *myid) { snprintf(thdname, sizeof(thdname), "io_thd_%ld", id); redis_set_thread_title(thdname); - redisSetCpuAffinity(server.server_cpulist); + serverSetCpuAffinity(server.server_cpulist); makeThreadKillable(); while(1) { diff --git a/src/rdb.c b/src/rdb.c index 688437ddd5..1039340493 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1577,12 +1577,12 @@ int rdbSaveBackground(int req, char *filename, rdbSaveInfo *rsi, int rdbflags) { server.dirty_before_bgsave = server.dirty; server.lastbgsave_try = time(NULL); - if ((childpid = redisFork(CHILD_TYPE_RDB)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_RDB)) == 0) { int retval; /* Child */ - redisSetProcTitle("redis-rdb-bgsave"); - redisSetCpuAffinity(server.bgsave_cpulist); + serverSetProcTitle("redis-rdb-bgsave"); + serverSetCpuAffinity(server.bgsave_cpulist); retval = rdbSave(req, filename,rsi,rdbflags); if (retval == C_OK) { sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB"); @@ -3583,7 +3583,7 @@ int rdbSaveToSlavesSockets(int req, rdbSaveInfo *rsi) { } /* Create the child process. */ - if ((childpid = redisFork(CHILD_TYPE_RDB)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_RDB)) == 0) { /* Child */ int retval, dummy; rio rdb; @@ -3594,8 +3594,8 @@ int rdbSaveToSlavesSockets(int req, rdbSaveInfo *rsi) { * get a write error and exit. */ close(server.rdb_pipe_read); - redisSetProcTitle("redis-rdb-to-slaves"); - redisSetCpuAffinity(server.bgsave_cpulist); + serverSetProcTitle("redis-rdb-to-slaves"); + serverSetCpuAffinity(server.bgsave_cpulist); retval = rdbSaveRioWithEOFMark(req,&rdb,NULL,rsi); if (retval == C_OK && rioFlush(&rdb) == 0) diff --git a/src/replication.c b/src/replication.c index d2ea5bbf23..eec67e06b1 100644 --- a/src/replication.c +++ b/src/replication.c @@ -2288,7 +2288,7 @@ void readSyncBulkPayload(connection *conn) { serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Finished with success"); if (server.supervised_mode == SUPERVISED_SYSTEMD) { - redisCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode.\n"); + serverCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode.\n"); } /* Send the initial ACK immediately to put this replica in online state. */ @@ -2859,7 +2859,7 @@ void syncWithMaster(connection *conn) { if (psync_result == PSYNC_CONTINUE) { serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Master accepted a Partial Resynchronization."); if (server.supervised_mode == SUPERVISED_SYSTEMD) { - redisCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Partial Resynchronization accepted. Ready to accept connections in read-write mode.\n"); + serverCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Partial Resynchronization accepted. Ready to accept connections in read-write mode.\n"); } return; } diff --git a/src/server.c b/src/server.c index eab88ce7ba..43727a24e6 100644 --- a/src/server.c +++ b/src/server.c @@ -4318,7 +4318,7 @@ int prepareForShutdown(int flags) { serverLog(LL_NOTICE,"User requested shutdown..."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STOPPING=1\n"); + serverCommunicateSystemd("STOPPING=1\n"); /* If we have any replicas, let them catch up the replication offset before * we shut down, to avoid data loss. */ @@ -4454,7 +4454,7 @@ int finishShutdown(void) { } else { serverLog(LL_WARNING, "Writing initial AOF, can't exit."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STATUS=Writing initial AOF, can't exit.\n"); + serverCommunicateSystemd("STATUS=Writing initial AOF, can't exit.\n"); goto error; } } @@ -4476,7 +4476,7 @@ int finishShutdown(void) { if ((server.saveparamslen > 0 && !nosave) || save) { serverLog(LL_NOTICE,"Saving the final RDB snapshot before exiting."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STATUS=Saving the final RDB snapshot\n"); + serverCommunicateSystemd("STATUS=Saving the final RDB snapshot\n"); /* Snapshotting. Perform a SYNC SAVE and exit */ rdbSaveInfo rsi, *rsiptr; rsiptr = rdbPopulateSaveInfo(&rsi); @@ -4492,7 +4492,7 @@ int finishShutdown(void) { } else { serverLog(LL_WARNING,"Error trying to save the DB, can't exit."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STATUS=Error trying to save the DB, can't exit.\n"); + serverCommunicateSystemd("STATUS=Error trying to save the DB, can't exit.\n"); goto error; } } @@ -6349,7 +6349,7 @@ int changeListener(connListener *listener) { /* Just close the server if port disabled */ if (listener->port == 0) { - if (server.set_proc_title) redisSetProcTitle(NULL); + if (server.set_proc_title) serverSetProcTitle(NULL); return C_OK; } @@ -6363,7 +6363,7 @@ int changeListener(connListener *listener) { serverPanic("Unrecoverable error creating %s accept handler.", listener->ct->get_type(NULL)); } - if (server.set_proc_title) redisSetProcTitle(NULL); + if (server.set_proc_title) serverSetProcTitle(NULL); return C_OK; } @@ -6449,7 +6449,7 @@ void closeChildUnusedResourceAfterFork(void) { } /* purpose is one of CHILD_TYPE_ types */ -int redisFork(int purpose) { +int serverFork(int purpose) { if (isMutuallyExclusiveChildType(purpose)) { if (hasActiveChildProcess()) { errno = EEXIST; @@ -6749,7 +6749,7 @@ int validateProcTitleTemplate(const char *template) { return ok; } -int redisSetProcTitle(char *title) { +int serverSetProcTitle(char *title) { #ifdef USE_SETPROCTITLE if (!title) title = server.exec_argv[0]; sds proc_title = expandProcTitleTemplate(server.proc_title_template, title); @@ -6764,7 +6764,7 @@ int redisSetProcTitle(char *title) { return C_OK; } -void redisSetCpuAffinity(const char *cpulist) { +void serverSetCpuAffinity(const char *cpulist) { #ifdef USE_SETCPUAFFINITY setcpuaffinity(cpulist); #else @@ -6774,7 +6774,7 @@ void redisSetCpuAffinity(const char *cpulist) { /* Send a notify message to systemd. Returns sd_notify return code which is * a positive number on success. */ -int redisCommunicateSystemd(const char *sd_notify_msg) { +int serverCommunicateSystemd(const char *sd_notify_msg) { #ifdef HAVE_LIBSYSTEMD int ret = sd_notify(0, sd_notify_msg); @@ -6812,7 +6812,7 @@ static int redisSupervisedSystemd(void) { "systemd supervision requested or auto-detected, but Redis is compiled without libsystemd support!"); return 0; #else - if (redisCommunicateSystemd("STATUS=Redis is loading...\n") <= 0) + if (serverCommunicateSystemd("STATUS=Redis is loading...\n") <= 0) return 0; serverLog(LL_NOTICE, "Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit."); @@ -7169,7 +7169,7 @@ int main(int argc, char **argv) { initServer(); if (background || server.pidfile) createPidFile(); - if (server.set_proc_title) redisSetProcTitle(NULL); + if (server.set_proc_title) serverSetProcTitle(NULL); redisAsciiArt(); checkTcpBacklogSettings(); if (server.cluster_enabled) { @@ -7207,17 +7207,17 @@ int main(int argc, char **argv) { if (server.supervised_mode == SUPERVISED_SYSTEMD) { if (!server.masterhost) { - redisCommunicateSystemd("STATUS=Ready to accept connections\n"); + serverCommunicateSystemd("STATUS=Ready to accept connections\n"); } else { - redisCommunicateSystemd("STATUS=Ready to accept connections in read-only mode. Waiting for MASTER <-> REPLICA sync\n"); + serverCommunicateSystemd("STATUS=Ready to accept connections in read-only mode. Waiting for MASTER <-> REPLICA sync\n"); } - redisCommunicateSystemd("READY=1\n"); + serverCommunicateSystemd("READY=1\n"); } } else { sentinelIsRunning(); if (server.supervised_mode == SUPERVISED_SYSTEMD) { - redisCommunicateSystemd("STATUS=Ready to accept connections\n"); - redisCommunicateSystemd("READY=1\n"); + serverCommunicateSystemd("STATUS=Ready to accept connections\n"); + serverCommunicateSystemd("READY=1\n"); } } @@ -7226,7 +7226,7 @@ int main(int argc, char **argv) { serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory); } - redisSetCpuAffinity(server.server_cpulist); + serverSetCpuAffinity(server.server_cpulist); setOOMScoreAdj(-1); aeMain(server.el); diff --git a/src/server.h b/src/server.h index 3b05c7ca33..07dd1485d5 100644 --- a/src/server.h +++ b/src/server.h @@ -2551,11 +2551,11 @@ void getRandomHexChars(char *p, size_t len); void getRandomBytes(unsigned char *p, size_t len); uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); void exitFromChild(int retcode); -long long redisPopcount(void *s, long count); -int redisSetProcTitle(char *title); +long long serverPopcount(void *s, long count); +int serverSetProcTitle(char *title); int validateProcTitleTemplate(const char *template); -int redisCommunicateSystemd(const char *sd_notify_msg); -void redisSetCpuAffinity(const char *cpulist); +int serverCommunicateSystemd(const char *sd_notify_msg); +void serverSetCpuAffinity(const char *cpulist); /* afterErrorReply flags */ #define ERR_REPLY_FLAG_NO_STATS_UPDATE (1ULL<<0) /* Indicating that we should not update @@ -2906,7 +2906,7 @@ void sendChildInfo(childInfoType info_type, size_t keys, char *pname); void receiveChildInfo(void); /* Fork helpers */ -int redisFork(int purpose); +int serverFork(int purpose); int hasActiveChildProcess(void); void resetChildState(void); int isMutuallyExclusiveChildType(int type); From 8b3ab8f74fe7cfc45f6e97b0f702210afada776d Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:29:33 +0700 Subject: [PATCH 40/98] Rename redisAtomic to serverAtomic (#180) https://github.com/valkey-io/valkey/issues/144 Signed-off-by: 0del --- src/atomicvar.h | 8 ++++---- src/lazyfree.c | 4 ++-- src/networking.c | 2 +- src/redis-benchmark.c | 14 +++++++------- src/server.h | 26 +++++++++++++------------- src/threads_mngr.c | 4 ++-- src/zmalloc.c | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/atomicvar.h b/src/atomicvar.h index bcabdccc58..b506c5d29e 100644 --- a/src/atomicvar.h +++ b/src/atomicvar.h @@ -80,8 +80,8 @@ #ifndef __ATOMIC_VAR_H #define __ATOMIC_VAR_H -/* Define redisAtomic for atomic variable. */ -#define redisAtomic +/* Define serverAtomic for atomic variable. */ +#define serverAtomic /* To test Redis with Helgrind (a Valgrind tool) it is useful to define * the following macro, so that __sync macros are used: those can be detected @@ -109,8 +109,8 @@ #if !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && defined(__STDC_VERSION__) && \ (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) /* Use '_Atomic' keyword if the compiler supports. */ -#undef redisAtomic -#define redisAtomic _Atomic +#undef serverAtomic +#define serverAtomic _Atomic /* Implementation using _Atomic in C11. */ #include diff --git a/src/lazyfree.c b/src/lazyfree.c index cd220fca15..4733d8f99a 100644 --- a/src/lazyfree.c +++ b/src/lazyfree.c @@ -4,8 +4,8 @@ #include "functions.h" #include "cluster.h" -static redisAtomic size_t lazyfree_objects = 0; -static redisAtomic size_t lazyfreed_objects = 0; +static serverAtomic size_t lazyfree_objects = 0; +static serverAtomic size_t lazyfreed_objects = 0; /* Release objects from the lazyfree thread. It's just decrRefCount() * updating the count of objects to release. */ diff --git a/src/networking.c b/src/networking.c index e979e2ecc3..5bb7706e7d 100644 --- a/src/networking.c +++ b/src/networking.c @@ -4195,7 +4195,7 @@ void processEventsWhileBlocked(void) { #endif typedef struct __attribute__((aligned(CACHE_LINE_SIZE))) threads_pending { - redisAtomic unsigned long value; + serverAtomic unsigned long value; } threads_pending; pthread_t io_threads[IO_THREADS_MAX_NUM]; diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index f1cc39a7ed..48d178109c 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -85,11 +85,11 @@ static struct config { int tls; struct cliSSLconfig sslconfig; int numclients; - redisAtomic int liveclients; + serverAtomic int liveclients; int requests; - redisAtomic int requests_issued; - redisAtomic int requests_finished; - redisAtomic int previous_requests_finished; + serverAtomic int requests_issued; + serverAtomic int requests_finished; + serverAtomic int previous_requests_finished; int last_printed_bytes; long long previous_tick; int keysize; @@ -118,9 +118,9 @@ static struct config { struct redisConfig *redis_config; struct hdr_histogram* latency_histogram; struct hdr_histogram* current_sec_latency_histogram; - redisAtomic int is_fetching_slots; - redisAtomic int is_updating_slots; - redisAtomic int slots_last_update; + serverAtomic int is_fetching_slots; + serverAtomic int is_updating_slots; + serverAtomic int slots_last_update; int enable_tracking; pthread_mutex_t liveclients_mutex; pthread_mutex_t is_updating_slots_mutex; diff --git a/src/server.h b/src/server.h index 07dd1485d5..4226bd99dd 100644 --- a/src/server.h +++ b/src/server.h @@ -1594,7 +1594,7 @@ struct redisServer { int module_pipe[2]; /* Pipe used to awake the event loop by module threads. */ pid_t child_pid; /* PID of current child */ int child_type; /* Type of current child */ - redisAtomic int module_gil_acquring; /* Indicates whether the GIL is being acquiring by the main thread. */ + serverAtomic int module_gil_acquring; /* Indicates whether the GIL is being acquiring by the main thread. */ /* Networking */ int port; /* TCP listening port */ int tls_port; /* TLS listening port */ @@ -1633,7 +1633,7 @@ struct redisServer { pause_event client_pause_per_purpose[NUM_PAUSE_PURPOSES]; char neterr[ANET_ERR_LEN]; /* Error buffer for anet.c */ dict *migrate_cached_sockets;/* MIGRATE cached sockets */ - redisAtomic uint64_t next_client_id; /* Next client unique ID. Incremental. */ + serverAtomic uint64_t next_client_id; /* Next client unique ID. Incremental. */ int protected_mode; /* Don't accept external connections. */ int io_threads_num; /* Number of IO threads to use. */ int io_threads_do_reads; /* Read and parse from IO threads? */ @@ -1689,10 +1689,10 @@ struct redisServer { long long slowlog_log_slower_than; /* SLOWLOG time limit (to get logged) */ unsigned long slowlog_max_len; /* SLOWLOG max number of items logged */ struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */ - redisAtomic long long stat_net_input_bytes; /* Bytes read from network. */ - redisAtomic long long stat_net_output_bytes; /* Bytes written to network. */ - redisAtomic long long stat_net_repl_input_bytes; /* Bytes read during replication, added to stat_net_input_bytes in 'info'. */ - redisAtomic long long stat_net_repl_output_bytes; /* Bytes written during replication, added to stat_net_output_bytes in 'info'. */ + serverAtomic long long stat_net_input_bytes; /* Bytes read from network. */ + serverAtomic long long stat_net_output_bytes; /* Bytes written to network. */ + serverAtomic long long stat_net_repl_input_bytes; /* Bytes read during replication, added to stat_net_input_bytes in 'info'. */ + serverAtomic long long stat_net_repl_output_bytes; /* Bytes written during replication, added to stat_net_output_bytes in 'info'. */ size_t stat_current_cow_peak; /* Peak size of copy on write bytes. */ size_t stat_current_cow_bytes; /* Copy on write bytes while child is active. */ monotime stat_current_cow_updated; /* Last update time of stat_current_cow_bytes */ @@ -1709,9 +1709,9 @@ struct redisServer { long long stat_dump_payload_sanitizations; /* Number deep dump payloads integrity validations. */ long long stat_io_reads_processed; /* Number of read events processed by IO / Main threads */ long long stat_io_writes_processed; /* Number of write events processed by IO / Main threads */ - redisAtomic long long stat_total_reads_processed; /* Total number of read events processed */ - redisAtomic long long stat_total_writes_processed; /* Total number of write events processed */ - redisAtomic long long stat_client_qbuf_limit_disconnections; /* Total number of clients reached query buf length limit */ + serverAtomic long long stat_total_reads_processed; /* Total number of read events processed */ + serverAtomic long long stat_total_writes_processed; /* Total number of write events processed */ + serverAtomic long long stat_client_qbuf_limit_disconnections; /* Total number of clients reached query buf length limit */ long long stat_client_outbuf_limit_disconnections; /* Total number of clients reached output buf length limit */ /* The following two are used to track instantaneous metrics, like * number of operations per second, network traffic. */ @@ -1800,8 +1800,8 @@ struct redisServer { int aof_last_write_errno; /* Valid if aof write/fsync status is ERR */ int aof_load_truncated; /* Don't stop on unexpected AOF EOF. */ int aof_use_rdb_preamble; /* Specify base AOF to use RDB encoding on AOF rewrites. */ - redisAtomic int aof_bio_fsync_status; /* Status of AOF fsync in bio job. */ - redisAtomic int aof_bio_fsync_errno; /* Errno of AOF fsync in bio job. */ + serverAtomic int aof_bio_fsync_status; /* Status of AOF fsync in bio job. */ + serverAtomic int aof_bio_fsync_errno; /* Errno of AOF fsync in bio job. */ aofManifest *aof_manifest; /* Used to track AOFs. */ int aof_disable_auto_gc; /* If disable automatically deleting HISTORY type AOFs? default no. (for testings). */ @@ -1866,7 +1866,7 @@ struct redisServer { char replid2[CONFIG_RUN_ID_SIZE+1]; /* replid inherited from master*/ long long master_repl_offset; /* My current replication offset */ long long second_replid_offset; /* Accept offsets up to this for replid2. */ - redisAtomic long long fsynced_reploff_pending;/* Largest replication offset to + serverAtomic long long fsynced_reploff_pending;/* Largest replication offset to * potentially have been fsynced, applied to fsynced_reploff only when AOF state is AOF_ON (not during the initial rewrite) */ @@ -1974,7 +1974,7 @@ struct redisServer { int list_max_listpack_size; int list_compress_depth; /* time cache */ - redisAtomic time_t unixtime; /* Unix time sampled every cron cycle. */ + serverAtomic time_t unixtime; /* Unix time sampled every cron cycle. */ time_t timezone; /* Cached timezone. As set by tzset(). */ int daylight_active; /* Currently in daylight saving time. */ mstime_t mstime; /* 'unixtime' in milliseconds. */ diff --git a/src/threads_mngr.c b/src/threads_mngr.c index 01080c8221..2d71ffacd0 100644 --- a/src/threads_mngr.c +++ b/src/threads_mngr.c @@ -46,10 +46,10 @@ static const clock_t RUN_ON_THREADS_TIMEOUT = 2; static run_on_thread_cb g_callback = NULL; static volatile size_t g_tids_len = 0; -static redisAtomic size_t g_num_threads_done = 0; +static serverAtomic size_t g_num_threads_done = 0; /* This flag is set while ThreadsManager_runOnThreads is running */ -static redisAtomic int g_in_progress = 0; +static serverAtomic int g_in_progress = 0; /*============================ Internal prototypes ========================== */ diff --git a/src/zmalloc.c b/src/zmalloc.c index 27b64dc0d7..65ad1f4c6a 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -90,7 +90,7 @@ void zlibc_free(void *ptr) { #define update_zmalloc_stat_alloc(__n) atomicIncr(used_memory,(__n)) #define update_zmalloc_stat_free(__n) atomicDecr(used_memory,(__n)) -static redisAtomic size_t used_memory = 0; +static serverAtomic size_t used_memory = 0; static void zmalloc_default_oom(size_t size) { fprintf(stderr, "zmalloc: Out of memory trying to allocate %zu bytes\n", From edee864b34b8bd1b08f864aff909af96dfd8bf19 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:30:30 +0700 Subject: [PATCH 41/98] rename redisOp to serverOp (#181) https://github.com/valkey-io/valkey/issues/144 Signed-off-by: 0del --- src/server.c | 8 ++++---- src/server.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/server.c b/src/server.c index 43727a24e6..b073de2da0 100644 --- a/src/server.c +++ b/src/server.c @@ -3118,7 +3118,7 @@ void resetErrorTableStats(void) { /* ========================== Redis OP Array API ============================ */ int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int target) { - redisOp *op; + serverOp *op; int prev_capacity = oa->capacity; if (oa->numops == 0) { @@ -3128,7 +3128,7 @@ int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int } if (prev_capacity != oa->capacity) - oa->ops = zrealloc(oa->ops,sizeof(redisOp)*oa->capacity); + oa->ops = zrealloc(oa->ops,sizeof(serverOp)*oa->capacity); op = oa->ops+oa->numops; op->dbid = dbid; op->argv = argv; @@ -3141,7 +3141,7 @@ int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int void serverOpArrayFree(serverOpArray *oa) { while(oa->numops) { int j; - redisOp *op; + serverOp *op; oa->numops--; op = oa->ops+oa->numops; @@ -3385,7 +3385,7 @@ static void propagatePendingCommands(void) { return; int j; - redisOp *rop; + serverOp *rop; /* If we got here it means we have finished an execution-unit. * If that unit has caused propagation of multiple commands, they diff --git a/src/server.h b/src/server.h index 4226bd99dd..730ef2b5bb 100644 --- a/src/server.h +++ b/src/server.h @@ -1371,16 +1371,16 @@ typedef struct clientBufferLimitsConfig { extern clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_OBUF_COUNT]; -/* The redisOp structure defines a Redis Operation, that is an instance of +/* The serverOp structure defines a Redis Operation, that is an instance of * a command with an argument vector, database ID, propagation target * (PROPAGATE_*), and command pointer. * * Currently only used to additionally propagate more commands to AOF/Replication * after the propagation of the executed command. */ -typedef struct redisOp { +typedef struct serverOp { robj **argv; int argc, dbid, target; -} redisOp; +} serverOp; /* Defines an array of Redis operations. There is an API to add to this * structure in an easy way. @@ -1389,7 +1389,7 @@ typedef struct redisOp { * void serverOpArrayFree(serverOpArray *oa); */ typedef struct serverOpArray { - redisOp *ops; + serverOp *ops; int numops; int capacity; } serverOpArray; From 3a0ba0ad93be5a2981c0ec0efc8c7a55be0a58e6 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:33:38 +0700 Subject: [PATCH 42/98] rename redisCommandArgType serverCommandArgType (#182) redisCommandArgType -> serverCommandArgType redisCommandArg -> serverCommandArg https://github.com/valkey-io/valkey/issues/144 Signed-off-by: 0del --- src/cli_commands.h | 2 +- src/commands.c | 2 +- src/commands.h | 10 +++++----- src/module.c | 18 +++++++++--------- src/server.c | 4 ++-- src/server.h | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/cli_commands.h b/src/cli_commands.h index eb5a476e38..d8455116dc 100644 --- a/src/cli_commands.h +++ b/src/cli_commands.h @@ -11,7 +11,7 @@ /* Syntax specifications for a command argument. */ typedef struct cliCommandArg { char *name; - redisCommandArgType type; + serverCommandArgType type; char *token; char *since; int flags; diff --git a/src/commands.c b/src/commands.c index 6d8e5696f3..bb93f98183 100644 --- a/src/commands.c +++ b/src/commands.c @@ -4,7 +4,7 @@ #define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,complexity,since,doc_flags,replaced,deprecated,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs #define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,key_spec_index,token,summary,since,flags,deprecated_since,numsubargs #define COMMAND_STRUCT serverCommand -#define COMMAND_ARG redisCommandArg +#define COMMAND_ARG serverCommandArg #ifdef LOG_REQ_RES #include "commands_with_reply_schema.def" diff --git a/src/commands.h b/src/commands.h index 1eefab4812..f093781160 100644 --- a/src/commands.h +++ b/src/commands.h @@ -12,7 +12,7 @@ typedef enum { ARG_TYPE_PURE_TOKEN, ARG_TYPE_ONEOF, /* Has subargs */ ARG_TYPE_BLOCK /* Has subargs */ -} redisCommandArgType; +} serverCommandArgType; #define CMD_ARG_NONE (0) #define CMD_ARG_OPTIONAL (1<<0) @@ -20,9 +20,9 @@ typedef enum { #define CMD_ARG_MULTIPLE_TOKEN (1<<2) /* Must be compatible with RedisModuleCommandArg. See moduleCopyCommandArgs. */ -typedef struct redisCommandArg { +typedef struct serverCommandArg { const char *name; - redisCommandArgType type; + serverCommandArgType type; int key_spec_index; const char *token; const char *summary; @@ -30,9 +30,9 @@ typedef struct redisCommandArg { int flags; const char *deprecated_since; int num_args; - struct redisCommandArg *subargs; + struct serverCommandArg *subargs; const char *display_text; -} redisCommandArg; +} serverCommandArg; /* Returns the command group name by group number. */ const char *commandGroupStr(int index); diff --git a/src/module.c b/src/module.c index 2314845461..44c983f2e3 100644 --- a/src/module.c +++ b/src/module.c @@ -500,9 +500,9 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info); static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api); static int moduleValidateCommandArgs(RedisModuleCommandArg *args, const RedisModuleCommandInfoVersion *version); -static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, +static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, const RedisModuleCommandInfoVersion *version); -static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); +static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); static int moduleConvertArgFlags(int flags); void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags); @@ -1450,7 +1450,7 @@ moduleCmdArgAt(const RedisModuleCommandInfoVersion *version, /* Recursively populate the args structure (setting num_args to the number of * subargs) and return the number of args. */ -int populateArgsStructure(struct redisCommandArg *args) { +int populateArgsStructure(struct serverCommandArg *args) { if (!args) return 0; int count = 0; @@ -2197,13 +2197,13 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, } /* Converts an array of RedisModuleCommandArg into a freshly allocated array of - * struct redisCommandArg. */ -static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, + * struct serverCommandArg. */ +static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, const RedisModuleCommandInfoVersion *version) { size_t count = 0; while (moduleCmdArgAt(version, args, count)->name) count++; - serverAssert(count < SIZE_MAX / sizeof(struct redisCommandArg)); - struct redisCommandArg *realargs = zcalloc((count+1) * sizeof(redisCommandArg)); + serverAssert(count < SIZE_MAX / sizeof(struct serverCommandArg)); + struct serverCommandArg *realargs = zcalloc((count+1) * sizeof(serverCommandArg)); for (size_t j = 0; j < count; j++) { RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); @@ -2224,7 +2224,7 @@ static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args return realargs; } -static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { +static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { if (error) *error = 0; switch (type) { case REDISMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; @@ -12132,7 +12132,7 @@ void moduleFreeModuleStructure(struct RedisModule *module) { zfree(module); } -void moduleFreeArgs(struct redisCommandArg *args, int num_args) { +void moduleFreeArgs(struct serverCommandArg *args, int num_args) { for (int j = 0; j < num_args; j++) { zfree((char *)args[j].name); zfree((char *)args[j].token); diff --git a/src/server.c b/src/server.c index b073de2da0..efd7f7b3be 100644 --- a/src/server.c +++ b/src/server.c @@ -4699,7 +4699,7 @@ void addReplyFlagsForKeyArgs(client *c, uint64_t flags) { addReplyCommandFlags(c, flags, docFlagNames); } -/* Must match redisCommandArgType */ +/* Must match serverCommandArgType */ const char *ARG_TYPE_STR[] = { "string", "integer", @@ -4722,7 +4722,7 @@ void addReplyFlagsForArg(client *c, uint64_t flags) { addReplyCommandFlags(c, flags, argFlagNames); } -void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_args) { +void addReplyCommandArgList(client *c, struct serverCommandArg *args, int num_args) { addReplyArrayLen(c, num_args); for (int j = 0; j Date: Thu, 4 Apr 2024 01:34:18 +0700 Subject: [PATCH 43/98] rename redisServer to valkeyServer (#183) https://github.com/valkey-io/valkey/issues/144 Signed-off-by: 0del --- src/server.c | 2 +- src/server.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server.c b/src/server.c index efd7f7b3be..3dde30c8f4 100644 --- a/src/server.c +++ b/src/server.c @@ -89,7 +89,7 @@ double R_Zero, R_PosInf, R_NegInf, R_Nan; /*================================= Globals ================================= */ /* Global vars */ -struct redisServer server; /* Server global state */ +struct valkeyServer server; /* Server global state */ /*============================ Internal prototypes ========================== */ diff --git a/src/server.h b/src/server.h index 711486b9cf..0925ee6dba 100644 --- a/src/server.h +++ b/src/server.h @@ -1544,7 +1544,7 @@ typedef enum childInfoType { CHILD_INFO_TYPE_MODULE_COW_SIZE } childInfoType; -struct redisServer { +struct valkeyServer { /* General */ pid_t pid; /* Main process pid. */ pthread_t main_thread_id; /* Main thread id */ @@ -2462,7 +2462,7 @@ extern int io_threads_op; * Extern declarations *----------------------------------------------------------------------------*/ -extern struct redisServer server; +extern struct valkeyServer server; extern struct sharedObjectsStruct shared; extern dictType objectKeyPointerValueDictType; extern dictType objectKeyHeapPointerValueDictType; From 125a2987af1f779af45966f539ec1f63650f8593 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:46:23 +0700 Subject: [PATCH 44/98] rename git sha related (#184) redisGitSHA1 -> serverGitSHA1 redisGitDirty -> serverGitDirty redisBuildId -> serverBuildId redisBuildIdRaw -> serverBuildIdRaw redisBuildIdString -> serverBuildIdString #144 #170 Signed-off-by: 0del --- src/cli_common.c | 10 +++++----- src/release.c | 12 ++++++------ src/server.c | 20 ++++++++++---------- src/server.h | 10 +++++----- src/tls.c | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/cli_common.c b/src/cli_common.c index 49cae3eabf..368906bcef 100644 --- a/src/cli_common.c +++ b/src/cli_common.c @@ -50,8 +50,8 @@ #define UNUSED(V) ((void) V) -char *redisGitSHA1(void); -char *redisGitDirty(void); +char *serverGitSHA1(void); +char *serverGitDirty(void); /* Wrapper around redisSecureConnection to avoid hiredis_ssl dependencies if * not building with TLS support. @@ -416,9 +416,9 @@ sds cliVersion(void) { sds version = sdscatprintf(sdsempty(), "%s", REDIS_VERSION); /* Add git commit and working tree status when available. */ - if (strtoll(redisGitSHA1(),NULL,16)) { - version = sdscatprintf(version, " (git:%s", redisGitSHA1()); - if (strtoll(redisGitDirty(),NULL,10)) + if (strtoll(serverGitSHA1(),NULL,16)) { + version = sdscatprintf(version, " (git:%s", serverGitSHA1()); + if (strtoll(serverGitDirty(),NULL,10)) version = sdscatprintf(version, "-dirty"); version = sdscat(version, ")"); } diff --git a/src/release.c b/src/release.c index adc7e55ddb..fdc1dbd5b2 100644 --- a/src/release.c +++ b/src/release.c @@ -37,19 +37,19 @@ #include "release.h" #include "crc64.h" -char *redisGitSHA1(void) { +char *serverGitSHA1(void) { return REDIS_GIT_SHA1; } -char *redisGitDirty(void) { +char *serverGitDirty(void) { return REDIS_GIT_DIRTY; } -const char *redisBuildIdRaw(void) { +const char *serverBuildIdRaw(void) { return REDIS_BUILD_ID_RAW; } -uint64_t redisBuildId(void) { +uint64_t serverBuildId(void) { char *buildid = REDIS_BUILD_ID_RAW; return crc64(0,(unsigned char*)buildid,strlen(buildid)); @@ -58,11 +58,11 @@ uint64_t redisBuildId(void) { /* Return a cached value of the build string in order to avoid recomputing * and converting it in hex every time: this string is shown in the INFO * output that should be fast. */ -char *redisBuildIdString(void) { +char *serverBuildIdString(void) { static char buf[32]; static int cached = 0; if (!cached) { - snprintf(buf,sizeof(buf),"%llx",(unsigned long long) redisBuildId()); + snprintf(buf,sizeof(buf),"%llx",(unsigned long long) serverBuildId()); cached = 1; } return buf; diff --git a/src/server.c b/src/server.c index 3dde30c8f4..df5adac183 100644 --- a/src/server.c +++ b/src/server.c @@ -5585,9 +5585,9 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { info = sdscatfmt(info, "# Server\r\n" FMTARGS( "redis_version:%s\r\n", REDIS_VERSION, - "redis_git_sha1:%s\r\n", redisGitSHA1(), - "redis_git_dirty:%i\r\n", strtol(redisGitDirty(),NULL,10) > 0, - "redis_build_id:%s\r\n", redisBuildIdString(), + "redis_git_sha1:%s\r\n", serverGitSHA1(), + "redis_git_dirty:%i\r\n", strtol(serverGitDirty(),NULL,10) > 0, + "redis_build_id:%s\r\n", serverBuildIdString(), "redis_mode:%s\r\n", mode, "os:%s", name.sysname, " %s", name.release, @@ -6266,11 +6266,11 @@ sds getVersion(void) { sds version = sdscatprintf(sdsempty(), "v=%s sha=%s:%d malloc=%s bits=%d build=%llx", REDIS_VERSION, - redisGitSHA1(), - atoi(redisGitDirty()) > 0, + serverGitSHA1(), + atoi(serverGitDirty()) > 0, ZMALLOC_LIB, sizeof(long) == 4 ? 32 : 64, - (unsigned long long) redisBuildId()); + (unsigned long long) serverBuildId()); return version; } @@ -6320,8 +6320,8 @@ void redisAsciiArt(void) { } else { snprintf(buf,1024*16,ascii_logo, REDIS_VERSION, - redisGitSHA1(), - strtol(redisGitDirty(),NULL,10) > 0, + serverGitSHA1(), + strtol(serverGitDirty(),NULL,10) > 0, (sizeof(long) == 8) ? "64" : "32", mode, server.port ? server.port : server.tls_port, (long) getpid() @@ -7157,8 +7157,8 @@ int main(int argc, char **argv) { "Redis version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", REDIS_VERSION, (sizeof(long) == 8) ? 64 : 32, - redisGitSHA1(), - strtol(redisGitDirty(),NULL,10) > 0, + serverGitSHA1(), + strtol(serverGitDirty(),NULL,10) > 0, (int)getpid()); if (argc == 1) { diff --git a/src/server.h b/src/server.h index 0925ee6dba..ef492763b8 100644 --- a/src/server.h +++ b/src/server.h @@ -3470,11 +3470,11 @@ void dictListDestructor(dict *d, void *val); void *dictSdsDup(dict *d, const void *key); /* Git SHA1 */ -char *redisGitSHA1(void); -char *redisGitDirty(void); -uint64_t redisBuildId(void); -const char *redisBuildIdRaw(void); -char *redisBuildIdString(void); +char *serverGitSHA1(void); +char *serverGitDirty(void); +uint64_t serverBuildId(void); +const char *serverBuildIdRaw(void); +char *serverBuildIdString(void); /* Commands prototypes */ void authCommand(client *c); diff --git a/src/tls.c b/src/tls.c index a6bd066097..bb1cee14c7 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1176,7 +1176,7 @@ int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) { UNUSED(argc); /* Connection modules must be part of the same build as redis. */ - if (strcmp(REDIS_BUILD_ID_RAW, redisBuildIdRaw())) { + if (strcmp(REDIS_BUILD_ID_RAW, serverBuildIdRaw())) { serverLog(LL_NOTICE, "Connection type %s was not built together with the redis-server used.", CONN_TYPE_TLS); return REDISMODULE_ERR; } From f3ccfbb01f49a8d73ca140604e65682a0f1ce156 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Wed, 3 Apr 2024 17:04:52 -0400 Subject: [PATCH 45/98] Rename TLS test cert files to valkey (#186) This PR covers changing the redis.crt and redis.key to valkey certs for TLS testing. The files are generated by the gen-test-certs.sh script under tests/tls/. Also covers comments provided. Signed-off-by: hwware Co-authored-by: hwware --- TLS.md | 20 ++++++++++---------- deps/hiredis/test.sh | 4 ++-- tests/instances.tcl | 2 +- tests/support/server.tcl | 2 +- tests/unit/tls.tcl | 6 +++--- utils/gen-test-certs.sh | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/TLS.md b/TLS.md index b9bce7edc9..51bfeae08a 100644 --- a/TLS.md +++ b/TLS.md @@ -33,25 +33,25 @@ To run Redis test suite with TLS, you'll need TLS support for TCL (i.e. ### Running manually -To manually run a Redis server with TLS mode (assuming `gen-test-certs.sh` was +To manually run a Valkey server with TLS mode (assuming `gen-test-certs.sh` was invoked so sample certificates/keys are available): For TLS built-in mode: - ./src/redis-server --tls-port 6379 --port 0 \ - --tls-cert-file ./tests/tls/redis.crt \ - --tls-key-file ./tests/tls/redis.key \ + ./src/valkey-server --tls-port 6379 --port 0 \ + --tls-cert-file ./tests/tls/valkey.crt \ + --tls-key-file ./tests/tls/valkey.key \ --tls-ca-cert-file ./tests/tls/ca.crt For TLS module mode: - ./src/redis-server --tls-port 6379 --port 0 \ - --tls-cert-file ./tests/tls/redis.crt \ - --tls-key-file ./tests/tls/redis.key \ + ./src/valkey-server --tls-port 6379 --port 0 \ + --tls-cert-file ./tests/tls/valkey.crt \ + --tls-key-file ./tests/tls/valkey.key \ --tls-ca-cert-file ./tests/tls/ca.crt \ - --loadmodule src/redis-tls.so + --loadmodule src/valkey-tls.so -To connect to this Redis server with `redis-cli`: +To connect to this Redis server with `valkey-cli`: - ./src/redis-cli --tls \ + ./src/valkey-cli --tls \ --cert ./tests/tls/redis.crt \ --key ./tests/tls/redis.key \ --cacert ./tests/tls/ca.crt diff --git a/deps/hiredis/test.sh b/deps/hiredis/test.sh index 0a1afb9234..2ce46bb0c2 100755 --- a/deps/hiredis/test.sh +++ b/deps/hiredis/test.sh @@ -23,8 +23,8 @@ SOCK_FILE=${tmpdir}/hiredis-test-redis.sock if [ "$TEST_SSL" = "1" ]; then SSL_CA_CERT=${tmpdir}/ca.crt SSL_CA_KEY=${tmpdir}/ca.key - SSL_CERT=${tmpdir}/redis.crt - SSL_KEY=${tmpdir}/redis.key + SSL_CERT=${tmpdir}/valkey.crt + SSL_KEY=${tmpdir}/valkey.key openssl genrsa -out ${tmpdir}/ca.key 4096 openssl req \ diff --git a/tests/instances.tcl b/tests/instances.tcl index d4ecfbfd84..1450d7ee01 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -100,7 +100,7 @@ proc spawn_instance {type base_port count {conf {}} {base_conf_file ""}} { puts $cfg [format "tls-key-file %s/../../tls/server.key" [pwd]] puts $cfg [format "tls-client-cert-file %s/../../tls/client.crt" [pwd]] puts $cfg [format "tls-client-key-file %s/../../tls/client.key" [pwd]] - puts $cfg [format "tls-dh-params-file %s/../../tls/redis.dh" [pwd]] + puts $cfg [format "tls-dh-params-file %s/../../tls/valkey.dh" [pwd]] puts $cfg [format "tls-ca-cert-file %s/../../tls/ca.crt" [pwd]] } else { puts $cfg "port $port" diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 3cf41c2a2e..a4af3db174 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -486,7 +486,7 @@ proc start_server {options {code undefined}} { dict set config "tls-key-file" [format "%s/tests/tls/server.key" [pwd]] dict set config "tls-client-cert-file" [format "%s/tests/tls/client.crt" [pwd]] dict set config "tls-client-key-file" [format "%s/tests/tls/client.key" [pwd]] - dict set config "tls-dh-params-file" [format "%s/tests/tls/redis.dh" [pwd]] + dict set config "tls-dh-params-file" [format "%s/tests/tls/valkey.dh" [pwd]] dict set config "tls-ca-cert-file" [format "%s/tests/tls/ca.crt" [pwd]] dict set config "loglevel" "debug" } diff --git a/tests/unit/tls.tcl b/tests/unit/tls.tcl index 29fe39fbf7..834ba40b7f 100644 --- a/tests/unit/tls.tcl +++ b/tests/unit/tls.tcl @@ -100,10 +100,10 @@ start_server {tags {"tls"}} { set master_port [srv 0 port] # Use a non-restricted client/server cert for the replica - set redis_crt [format "%s/tests/tls/redis.crt" [pwd]] - set redis_key [format "%s/tests/tls/redis.key" [pwd]] + set valkey_crt [format "%s/tests/tls/valkey.crt" [pwd]] + set valkey_key [format "%s/tests/tls/valkey.key" [pwd]] - start_server [list overrides [list tls-cert-file $redis_crt tls-key-file $redis_key] \ + start_server [list overrides [list tls-cert-file $valkey_crt tls-key-file $valkey_key] \ omit [list tls-client-cert-file tls-client-key-file]] { set replica [srv 0 client] $replica replicaof $master_host $master_port diff --git a/utils/gen-test-certs.sh b/utils/gen-test-certs.sh index 6bc9d86071..2036a9b85f 100755 --- a/utils/gen-test-certs.sh +++ b/utils/gen-test-certs.sh @@ -3,10 +3,10 @@ # Generate some test certificates which are used by the regression test suite: # # tests/tls/ca.{crt,key} Self signed CA certificate. -# tests/tls/redis.{crt,key} A certificate with no key usage/policy restrictions. +# tests/tls/valkey.{crt,key} A certificate with no key usage/policy restrictions. # tests/tls/client.{crt,key} A certificate restricted for SSL client usage. # tests/tls/server.{crt,key} A certificate restricted for SSL server usage. -# tests/tls/redis.dh DH Params file. +# tests/tls/valkey.dh DH Params file. generate_cert() { local name=$1 @@ -53,6 +53,6 @@ _END_ generate_cert server "Server-only" "-extfile tests/tls/openssl.cnf -extensions server_cert" generate_cert client "Client-only" "-extfile tests/tls/openssl.cnf -extensions client_cert" -generate_cert redis "Generic-cert" +generate_cert valkey "Generic-cert" -[ -f tests/tls/redis.dh ] || openssl dhparam -out tests/tls/redis.dh 2048 +[ -f tests/tls/valkey.dh ] || openssl dhparam -out tests/tls/valkey.dh 2048 From e4d61c482538f333390b2e257e1b8b12fc2b3c94 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Wed, 3 Apr 2024 17:06:45 -0400 Subject: [PATCH 46/98] Rename cli benchmark check-aof and check-rdb src and object files to valkey respectively (#188) As part of earlier PRs binary names and some file names renamed to valkey, but still cli and benchmark and other source files still with redis name. So changed the file names and makefile accordingly. Signed-off-by: hwware Co-authored-by: hwware --- src/Makefile | 20 +++++++++---------- src/{redis-benchmark.c => valkey-benchmark.c} | 0 src/{redis-check-aof.c => valkey-check-aof.c} | 0 src/{redis-check-rdb.c => valkey-check-rdb.c} | 0 src/{redis-cli.c => valkey-cli.c} | 0 5 files changed, 10 insertions(+), 10 deletions(-) rename src/{redis-benchmark.c => valkey-benchmark.c} (100%) rename src/{redis-check-aof.c => valkey-check-aof.c} (100%) rename src/{redis-check-rdb.c => valkey-check-rdb.c} (100%) rename src/{redis-cli.c => valkey-cli.c} (100%) diff --git a/src/Makefile b/src/Makefile index 83255feee7..e54bb6b491 100644 --- a/src/Makefile +++ b/src/Makefile @@ -360,11 +360,11 @@ endif ENGINE_NAME=valkey SERVER_NAME=$(ENGINE_NAME)-server$(PROG_SUFFIX) ENGINE_SENTINEL_NAME=$(ENGINE_NAME)-sentinel$(PROG_SUFFIX) -ENGINE_SERVER_OBJ=threads_mngr.o adlist.o quicklist.o ae.o anet.o dict.o kvstore.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o cluster_legacy.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o +ENGINE_SERVER_OBJ=threads_mngr.o adlist.o quicklist.o ae.o anet.o dict.o kvstore.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o cluster_legacy.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o valkey-check-rdb.o valkey-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o ENGINE_CLI_NAME=$(ENGINE_NAME)-cli$(PROG_SUFFIX) -ENGINE_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o serverassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o +ENGINE_CLI_OBJ=anet.o adlist.o dict.o valkey-cli.o zmalloc.o release.o ae.o serverassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o ENGINE_BENCHMARK_NAME=$(ENGINE_NAME)-benchmark$(PROG_SUFFIX) -ENGINE_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o serverassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o +ENGINE_BENCHMARK_OBJ=ae.o anet.o valkey-benchmark.o adlist.o dict.o zmalloc.o serverassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o ENGINE_CHECK_RDB_NAME=$(ENGINE_NAME)-check-rdb$(PROG_SUFFIX) ENGINE_CHECK_AOF_NAME=$(ENGINE_NAME)-check-aof$(PROG_SUFFIX) ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(ENGINE_SERVER_OBJ) $(ENGINE_CLI_OBJ) $(ENGINE_BENCHMARK_OBJ))) @@ -413,31 +413,31 @@ ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS))) .make-prerequisites: persist-settings endif -# redis-server +# valkey-server $(SERVER_NAME): $(ENGINE_SERVER_OBJ) $(SERVER_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS) -# redis-sentinel +# valkey-sentinel $(ENGINE_SENTINEL_NAME): $(SERVER_NAME) $(ENGINE_INSTALL) $(SERVER_NAME) $(ENGINE_SENTINEL_NAME) -# redis-check-rdb +# valkey-check-rdb $(ENGINE_CHECK_RDB_NAME): $(SERVER_NAME) $(ENGINE_INSTALL) $(SERVER_NAME) $(ENGINE_CHECK_RDB_NAME) -# redis-check-aof +# valkey-check-aof $(ENGINE_CHECK_AOF_NAME): $(SERVER_NAME) $(ENGINE_INSTALL) $(SERVER_NAME) $(ENGINE_CHECK_AOF_NAME) -# redis-tls.so +# valkey-tls.so $(TLS_MODULE_NAME): $(SERVER_NAME) $(QUIET_CC)$(CC) -o $@ tls.c -shared -fPIC $(TLS_MODULE_CFLAGS) $(TLS_CLIENT_LIBS) -# redis-cli +# valkey-cli $(ENGINE_CLI_NAME): $(ENGINE_CLI_OBJ) $(SERVER_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS) -# redis-benchmark +# valkey-benchmark $(ENGINE_BENCHMARK_NAME): $(ENGINE_BENCHMARK_OBJ) $(SERVER_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS) diff --git a/src/redis-benchmark.c b/src/valkey-benchmark.c similarity index 100% rename from src/redis-benchmark.c rename to src/valkey-benchmark.c diff --git a/src/redis-check-aof.c b/src/valkey-check-aof.c similarity index 100% rename from src/redis-check-aof.c rename to src/valkey-check-aof.c diff --git a/src/redis-check-rdb.c b/src/valkey-check-rdb.c similarity index 100% rename from src/redis-check-rdb.c rename to src/valkey-check-rdb.c diff --git a/src/redis-cli.c b/src/valkey-cli.c similarity index 100% rename from src/redis-cli.c rename to src/valkey-cli.c From e1cb4c8a8bccfd62cdf76c40a7804110d336d039 Mon Sep 17 00:00:00 2001 From: Lipeng Zhu Date: Thu, 4 Apr 2024 05:20:06 +0800 Subject: [PATCH 47/98] Rename #include guards (#167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename include guard macros (redis -> valkey) and remove the leading double underscore. --------- Signed-off-by: Lipeng Zhu Signed-off-by: Viktor Söderqvist Co-authored-by: Viktor Söderqvist --- src/cli_commands.h | 4 ++-- src/commands.h | 4 ++-- src/connection.h | 4 ++-- src/connhelpers.h | 6 +++--- src/rand.h | 4 ++-- src/rio.h | 4 ++-- src/server.h | 4 ++-- src/serverassert.h | 4 ++-- src/util.h | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/cli_commands.h b/src/cli_commands.h index d8455116dc..3b24dfa4d6 100644 --- a/src/cli_commands.h +++ b/src/cli_commands.h @@ -2,8 +2,8 @@ * It contains alternative structs which omit the parts of the commands table * that are not suitable for redis-cli, e.g. the command proc. */ -#ifndef __REDIS_CLI_COMMANDS_H -#define __REDIS_CLI_COMMANDS_H +#ifndef VALKEY_CLI_COMMANDS_H +#define VALKEY_CLI_COMMANDS_H #include #include "commands.h" diff --git a/src/commands.h b/src/commands.h index f093781160..fe8bb680c2 100644 --- a/src/commands.h +++ b/src/commands.h @@ -1,5 +1,5 @@ -#ifndef __REDIS_COMMANDS_H -#define __REDIS_COMMANDS_H +#ifndef VALKEY_COMMANDS_H +#define VALKEY_COMMANDS_H /* Must be synced with ARG_TYPE_STR and generate-command-code.py */ typedef enum { diff --git a/src/connection.h b/src/connection.h index d0340d18f5..ac48214237 100644 --- a/src/connection.h +++ b/src/connection.h @@ -28,8 +28,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __REDIS_CONNECTION_H -#define __REDIS_CONNECTION_H +#ifndef VALKEY_CONNECTION_H +#define VALKEY_CONNECTION_H #include #include diff --git a/src/connhelpers.h b/src/connhelpers.h index b32e44dba0..28be1109b3 100644 --- a/src/connhelpers.h +++ b/src/connhelpers.h @@ -28,8 +28,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __REDIS_CONNHELPERS_H -#define __REDIS_CONNHELPERS_H +#ifndef VALKEY_CONNHELPERS_H +#define VALKEY_CONNHELPERS_H #include "connection.h" @@ -85,4 +85,4 @@ static inline int callHandler(connection *conn, ConnectionCallbackFunc handler) return 1; } -#endif /* __REDIS_CONNHELPERS_H */ +#endif /* VALKEY_CONNHELPERS_H */ diff --git a/src/rand.h b/src/rand.h index 9884915a97..eb885803cd 100644 --- a/src/rand.h +++ b/src/rand.h @@ -27,8 +27,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REDIS_RANDOM_H -#define REDIS_RANDOM_H +#ifndef VALKEY_RANDOM_H +#define VALKEY_RANDOM_H int32_t redisLrand48(void); void redisSrand48(int32_t seedval); diff --git a/src/rio.h b/src/rio.h index 2b71c5881e..edad7e7956 100644 --- a/src/rio.h +++ b/src/rio.h @@ -29,8 +29,8 @@ */ -#ifndef __REDIS_RIO_H -#define __REDIS_RIO_H +#ifndef VALKEY_RIO_H +#define VALKEY_RIO_H #include #include diff --git a/src/server.h b/src/server.h index ef492763b8..1ea1bd7f57 100644 --- a/src/server.h +++ b/src/server.h @@ -27,8 +27,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __REDIS_H -#define __REDIS_H +#ifndef VALKEY_H +#define VALKEY_H #include "fmacros.h" #include "config.h" diff --git a/src/serverassert.h b/src/serverassert.h index 1cbc9fb6cf..da1b7c7fa2 100644 --- a/src/serverassert.h +++ b/src/serverassert.h @@ -35,8 +35,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __REDIS_ASSERT_H__ -#define __REDIS_ASSERT_H__ +#ifndef VALKEY_ASSERT_H +#define VALKEY_ASSERT_H #include "config.h" diff --git a/src/util.h b/src/util.h index e924ba8cf6..727a7a909c 100644 --- a/src/util.h +++ b/src/util.h @@ -27,8 +27,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __REDIS_UTIL_H -#define __REDIS_UTIL_H +#ifndef VALKEY_UTIL_H +#define VALKEY_UTIL_H #include #include "sds.h" From 55de74e0dc9a14166c5c96d2282ae29f09785e59 Mon Sep 17 00:00:00 2001 From: Daniel House <76451671+daniel-house@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:23:34 -0400 Subject: [PATCH 48/98] The usage (--help) message now refers to valkey (#189) Fixing redis -> valkey in the output of valkey-server --help. Signed-off-by: Daniel House Co-authored-by: Daniel House --- src/server.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/server.c b/src/server.c index df5adac183..d6d4d22b81 100644 --- a/src/server.c +++ b/src/server.c @@ -6275,23 +6275,23 @@ sds getVersion(void) { } void usage(void) { - fprintf(stderr,"Usage: ./redis-server [/path/to/valkey.conf] [options] [-]\n"); - fprintf(stderr," ./redis-server - (read config from stdin)\n"); - fprintf(stderr," ./redis-server -v or --version\n"); - fprintf(stderr," ./redis-server -h or --help\n"); - fprintf(stderr," ./redis-server --test-memory \n"); - fprintf(stderr," ./redis-server --check-system\n"); + fprintf(stderr,"Usage: ./valkey-server [/path/to/valkey.conf] [options] [-]\n"); + fprintf(stderr," ./valkey-server - (read config from stdin)\n"); + fprintf(stderr," ./valkey-server -v or --version\n"); + fprintf(stderr," ./valkey-server -h or --help\n"); + fprintf(stderr," ./valkey-server --test-memory \n"); + fprintf(stderr," ./valkey-server --check-system\n"); fprintf(stderr,"\n"); fprintf(stderr,"Examples:\n"); - fprintf(stderr," ./redis-server (run the server with default conf)\n"); - fprintf(stderr," echo 'maxmemory 128mb' | ./redis-server -\n"); - fprintf(stderr," ./redis-server /etc/valkey/6379.conf\n"); - fprintf(stderr," ./redis-server --port 7777\n"); - fprintf(stderr," ./redis-server --port 7777 --replicaof 127.0.0.1 8888\n"); - fprintf(stderr," ./redis-server /etc/myvalkey.conf --loglevel verbose -\n"); - fprintf(stderr," ./redis-server /etc/myvalkey.conf --loglevel verbose\n\n"); + fprintf(stderr," ./valkey-server (run the server with default conf)\n"); + fprintf(stderr," echo 'maxmemory 128mb' | ./valkey-server -\n"); + fprintf(stderr," ./valkey-server /etc/valkey/6379.conf\n"); + fprintf(stderr," ./valkey-server --port 7777\n"); + fprintf(stderr," ./valkey-server --port 7777 --replicaof 127.0.0.1 8888\n"); + fprintf(stderr," ./valkey-server /etc/myvalkey.conf --loglevel verbose -\n"); + fprintf(stderr," ./valkey-server /etc/myvalkey.conf --loglevel verbose\n\n"); fprintf(stderr,"Sentinel mode:\n"); - fprintf(stderr," ./redis-server /etc/sentinel.conf --sentinel\n"); + fprintf(stderr," ./valkey-server /etc/sentinel.conf --sentinel\n"); exit(1); } From 39d0f457a2a332cd511e45a8b28e65524ff4dea6 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:52:36 -0700 Subject: [PATCH 49/98] Update versioning fields for compatibility (#47) New info information to be used to determine the valkey versioning info. Internally, introduce new define values for "SERVER_VERSION" which is different from the Redis compatibility version, "REDIS_VERSION". Add two new info fields: `server_version`: The Valkey server version `server_name`: Indicates that the server is valkey. Add one new RDB field: `server_ver`, which indicates the valkey version that produced the server. Add 3 new LUA globals: `SERVER_VERSION_NUM`, `SERVER_VERSION`, and `SERVER_NAME`. Which reflect the valkey version instead of the Redis compatibility version. Also clean up various places where Redis and configuration was being used that is no longer necessary. --------- Signed-off-by: Madelyn Olson --- src/cli_common.c | 2 +- src/config.c | 3 +-- src/debug.c | 2 +- src/lolwut.c | 4 ++-- src/lolwut5.c | 2 +- src/lolwut6.c | 2 +- src/mkreleasehdr.sh | 2 +- src/module.c | 2 +- src/networking.c | 2 +- src/rdb.c | 7 ++++++- src/script_lua.c | 14 ++++++++++++++ src/sentinel.c | 3 +-- src/server.c | 11 ++++++----- src/version.h | 10 ++++++++-- tests/unit/moduleapi/misc.tcl | 3 +-- 15 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/cli_common.c b/src/cli_common.c index 368906bcef..c55933418d 100644 --- a/src/cli_common.c +++ b/src/cli_common.c @@ -413,7 +413,7 @@ sds escapeJsonString(sds s, const char *p, size_t len) { } sds cliVersion(void) { - sds version = sdscatprintf(sdsempty(), "%s", REDIS_VERSION); + sds version = sdscatprintf(sdsempty(), "%s", SERVER_VERSION); /* Add git commit and working tree status when available. */ if (strtoll(serverGitSHA1(),NULL,16)) { diff --git a/src/config.c b/src/config.c index 8b193891cf..c009589e15 100644 --- a/src/config.c +++ b/src/config.c @@ -634,8 +634,7 @@ void loadServerConfigFromString(char *config) { loaderr: if (argv) sdsfreesplitres(argv,argc); - fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n", - REDIS_VERSION); + fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", SERVER_VERSION); if (i < totlines) { fprintf(stderr, "Reading the configuration file, at line %d\n", linenum); fprintf(stderr, ">>> '%s'\n", lines[i]); diff --git a/src/debug.c b/src/debug.c index 676a1c32dd..c64fba2b5b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2252,7 +2252,7 @@ static void sigsegvHandler(int sig, siginfo_t *info, void *secret) { bugReportStart(); serverLog(LL_WARNING, - "Redis %s crashed by signal: %d, si_code: %d", REDIS_VERSION, sig, info->si_code); + SERVER_NAME " %s crashed by signal: %d, si_code: %d", SERVER_VERSION, sig, info->si_code); if (sig == SIGSEGV || sig == SIGBUS) { serverLog(LL_WARNING, "Accessing address: %p", (void*)info->si_addr); diff --git a/src/lolwut.c b/src/lolwut.c index c014840e9a..08c1f58992 100644 --- a/src/lolwut.c +++ b/src/lolwut.c @@ -44,7 +44,7 @@ void lolwut6Command(client *c); * This is what unstable versions of Redis will display. */ void lolwutUnstableCommand(client *c) { sds rendered = sdsnew("Redis ver. "); - rendered = sdscat(rendered,REDIS_VERSION); + rendered = sdscat(rendered,SERVER_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); @@ -52,7 +52,7 @@ void lolwutUnstableCommand(client *c) { /* LOLWUT [VERSION ] [... version specific arguments ...] */ void lolwutCommand(client *c) { - char *v = REDIS_VERSION; + char *v = SERVER_VERSION; char verstr[64]; if (c->argc >= 3 && !strcasecmp(c->argv[1]->ptr,"version")) { diff --git a/src/lolwut5.c b/src/lolwut5.c index 1240168d0d..dcc7e7ad90 100644 --- a/src/lolwut5.c +++ b/src/lolwut5.c @@ -169,7 +169,7 @@ void lolwut5Command(client *c) { sds rendered = renderCanvas(canvas); rendered = sdscat(rendered, "\nGeorg Nees - schotter, plotter on paper, 1968. Redis ver. "); - rendered = sdscat(rendered,REDIS_VERSION); + rendered = sdscat(rendered,SERVER_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); diff --git a/src/lolwut6.c b/src/lolwut6.c index 1ba111c2d0..38733505a9 100644 --- a/src/lolwut6.c +++ b/src/lolwut6.c @@ -193,7 +193,7 @@ void lolwut6Command(client *c) { rendered = sdscat(rendered, "\nDedicated to the 8 bit game developers of past and present.\n" "Original 8 bit image from Plaguemon by hikikomori. Redis ver. "); - rendered = sdscat(rendered,REDIS_VERSION); + rendered = sdscat(rendered,SERVER_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); diff --git a/src/mkreleasehdr.sh b/src/mkreleasehdr.sh index 04bc45a169..b1371fcc09 100755 --- a/src/mkreleasehdr.sh +++ b/src/mkreleasehdr.sh @@ -12,5 +12,5 @@ echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h echo "#include \"version.h\"" >> release.h -echo "#define REDIS_BUILD_ID_RAW REDIS_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h +echo "#define REDIS_BUILD_ID_RAW SERVER_NAME SERVER_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h touch release.c # Force recompile of release.c diff --git a/src/module.c b/src/module.c index 44c983f2e3..eecb45fb48 100644 --- a/src/module.c +++ b/src/module.c @@ -13295,7 +13295,7 @@ int RM_GetKeyspaceNotificationFlagsAll(void) { * Example for 6.0.7 the return value will be 0x00060007. */ int RM_GetServerVersion(void) { - return REDIS_VERSION_NUM; + return SERVER_VERSION_NUM; } /** diff --git a/src/networking.c b/src/networking.c index 5bb7706e7d..0adbfeb452 100644 --- a/src/networking.c +++ b/src/networking.c @@ -3650,7 +3650,7 @@ void helloCommand(client *c) { addReplyBulkCString(c,"redis"); addReplyBulkCString(c,"version"); - addReplyBulkCString(c,REDIS_VERSION); + addReplyBulkCString(c,SERVER_VERSION); addReplyBulkCString(c,"proto"); addReplyLongLong(c,c->resp); diff --git a/src/rdb.c b/src/rdb.c index 1039340493..052d780d02 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1195,6 +1195,8 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { int aof_base = (rdbflags & RDBFLAGS_AOF_PREAMBLE) != 0; /* Add a few fields about the state when the RDB was created. */ + if (rdbSaveAuxFieldStrStr(rdb,"server-ver",SERVER_VERSION) == -1) return -1; + /* Print Redis version for backwards compatibility with redis. */ if (rdbSaveAuxFieldStrStr(rdb,"redis-ver",REDIS_VERSION) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"redis-bits",redis_bits) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"ctime",time(NULL)) == -1) return -1; @@ -3162,7 +3164,10 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin } else if (!strcasecmp(auxkey->ptr,"lua")) { /* Won't load the script back in memory anymore. */ } else if (!strcasecmp(auxkey->ptr,"redis-ver")) { - serverLog(LL_NOTICE,"Loading RDB produced by version %s", + serverLog(LL_NOTICE,"Loading RDB produced by Redis version %s", + (char*)auxval->ptr); + } else if (!strcasecmp(auxkey->ptr,"server-ver")) { + serverLog(LL_NOTICE,"Loading RDB produced by server version %s", (char*)auxval->ptr); } else if (!strcasecmp(auxkey->ptr,"ctime")) { time_t age = time(NULL)-strtol(auxval->ptr,NULL,10); diff --git a/src/script_lua.c b/src/script_lua.c index 1126422582..fbbd6e82fa 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -1383,6 +1383,7 @@ void luaSetTableProtectionRecursively(lua_State *lua) { } void luaRegisterVersion(lua_State* lua) { + /* For legacy compatibility reasons include Redis versions. */ lua_pushstring(lua,"REDIS_VERSION_NUM"); lua_pushnumber(lua,REDIS_VERSION_NUM); lua_settable(lua,-3); @@ -1390,6 +1391,19 @@ void luaRegisterVersion(lua_State* lua) { lua_pushstring(lua,"REDIS_VERSION"); lua_pushstring(lua,REDIS_VERSION); lua_settable(lua,-3); + + /* Now push the Valkey version information. */ + lua_pushstring(lua,"SERVER_VERSION_NUM"); + lua_pushnumber(lua,SERVER_VERSION_NUM); + lua_settable(lua,-3); + + lua_pushstring(lua,"SERVER_VERSION"); + lua_pushstring(lua,SERVER_VERSION); + lua_settable(lua,-3); + + lua_pushstring(lua,"SERVER_NAME"); + lua_pushstring(lua,SERVER_NAME); + lua_settable(lua,-3); } void luaRegisterLogFunction(lua_State* lua) { diff --git a/src/sentinel.c b/src/sentinel.c index cce5cc3b99..af27ee9c3b 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1846,8 +1846,7 @@ void loadSentinelConfigFromQueue(void) { return; loaderr: - fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n", - REDIS_VERSION); + fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", SERVER_VERSION); fprintf(stderr, "Reading the configuration file, at line %d\n", linenum); fprintf(stderr, ">>> '%s'\n", line); fprintf(stderr, "%s\n", err); diff --git a/src/server.c b/src/server.c index d6d4d22b81..5e35e93631 100644 --- a/src/server.c +++ b/src/server.c @@ -5585,6 +5585,8 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { info = sdscatfmt(info, "# Server\r\n" FMTARGS( "redis_version:%s\r\n", REDIS_VERSION, + "server_name:%s\r\n", SERVER_NAME, + "server_version:%s\r\n", SERVER_VERSION, "redis_git_sha1:%s\r\n", serverGitSHA1(), "redis_git_dirty:%i\r\n", strtol(serverGitDirty(),NULL,10) > 0, "redis_build_id:%s\r\n", serverBuildIdString(), @@ -6265,7 +6267,7 @@ void daemonize(void) { sds getVersion(void) { sds version = sdscatprintf(sdsempty(), "v=%s sha=%s:%d malloc=%s bits=%d build=%llx", - REDIS_VERSION, + SERVER_VERSION, serverGitSHA1(), atoi(serverGitDirty()) > 0, ZMALLOC_LIB, @@ -6319,7 +6321,7 @@ void redisAsciiArt(void) { ); } else { snprintf(buf,1024*16,ascii_logo, - REDIS_VERSION, + SERVER_VERSION, serverGitSHA1(), strtol(serverGitDirty(),NULL,10) > 0, (sizeof(long) == 8) ? "64" : "32", @@ -7153,9 +7155,8 @@ int main(int argc, char **argv) { if (background) daemonize(); serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo"); - serverLog(LL_NOTICE, - "Redis version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", - REDIS_VERSION, + serverLog(LL_NOTICE, SERVER_NAME " version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", + SERVER_VERSION, (sizeof(long) == 8) ? 64 : 32, serverGitSHA1(), strtol(serverGitDirty(),NULL,10) > 0, diff --git a/src/version.h b/src/version.h index 89aef53fcb..af46071dac 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1,8 @@ -#define REDIS_VERSION "255.255.255" -#define REDIS_VERSION_NUM 0x00ffffff +#define SERVER_NAME "valkey" +#define SERVER_VERSION "255.255.255" +#define SERVER_VERSION_NUM 0x00ffffff + +/* Redis compatibility version, should never + * exceed 7.2.x. */ +#define REDIS_VERSION "7.2.4" +#define REDIS_VERSION_NUM 0x00070204 diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index 41f9dd3fa1..ffcf9bd615 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -21,8 +21,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { } test {test redis version} { - set version [s redis_version] - assert_equal $version [r test.redisversion] + assert_equal [s server_version] [r test.redisversion] } test {test long double conversions} { From 9a02b775c18643e5dc41873f202c3f4200c28ad4 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Wed, 3 Apr 2024 19:17:38 -0400 Subject: [PATCH 50/98] Replace Valkey in runtest scripts error prints (#190) Replaced Redis with Valkey in runtest script's error prints. Signed-off-by: Shivshankar-Reddy --- runtest | 2 +- runtest-cluster | 2 +- runtest-moduleapi | 2 +- runtest-sentinel | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtest b/runtest index 88617c1a63..00949bc304 100755 --- a/runtest +++ b/runtest @@ -8,7 +8,7 @@ done if [ -z $TCLSH ] then - echo "You need tcl 8.5 or newer in order to run the Redis test" + echo "You need tcl 8.5 or newer in order to run the Valkey test" exit 1 fi $TCLSH tests/test_helper.tcl "${@}" diff --git a/runtest-cluster b/runtest-cluster index e465ce1863..85e8690b1c 100755 --- a/runtest-cluster +++ b/runtest-cluster @@ -8,7 +8,7 @@ done if [ -z $TCLSH ] then - echo "You need tcl 8.5 or newer in order to run the Redis Cluster test" + echo "You need tcl 8.5 or newer in order to run the Valkey Cluster test" exit 1 fi $TCLSH tests/cluster/run.tcl $* diff --git a/runtest-moduleapi b/runtest-moduleapi index 910d581f2f..4439cbcd03 100755 --- a/runtest-moduleapi +++ b/runtest-moduleapi @@ -9,7 +9,7 @@ done if [ -z $TCLSH ] then - echo "You need tcl 8.5 or newer in order to run the Redis ModuleApi test" + echo "You need tcl 8.5 or newer in order to run the Valkey ModuleApi test" exit 1 fi diff --git a/runtest-sentinel b/runtest-sentinel index 60d8c3ceab..3bbe9af3c8 100755 --- a/runtest-sentinel +++ b/runtest-sentinel @@ -8,7 +8,7 @@ done if [ -z $TCLSH ] then - echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" + echo "You need tcl 8.5 or newer in order to run the Valkey Sentinel test" exit 1 fi $TCLSH tests/sentinel/run.tcl $* From e3e1f9a372560b7c05c206cf363ea84d4f059d79 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:45:23 +0700 Subject: [PATCH 51/98] Rename 'redis' to 'server' and redisNodeFlags to clusterNodeFlags (#191) Rename additional instances of redis to server, as well as redisNodeFlags to clusterNodeFlags. --------- Signed-off-by: 0del --- src/bitops.c | 12 ++++---- src/cli_commands.h | 2 +- src/cluster_legacy.c | 8 +++--- src/commands.def | 2 +- src/rand.c | 4 +-- src/rand.h | 4 +-- src/script_lua.c | 6 ++-- src/server.c | 52 +++++++++++++++++----------------- src/server.h | 4 +-- src/valkey-cli.c | 4 +-- utils/generate-command-code.py | 2 +- 11 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/bitops.c b/src/bitops.c index bc76d9acb5..5b97c033aa 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -98,7 +98,7 @@ long long serverPopcount(void *s, long count) { * no zero bit is found, it returns count*8 assuming the string is zero * padded on the right. However if 'bit' is 1 it is possible that there is * not a single set bit in the bitmap. In this special case -1 is returned. */ -long long redisBitpos(void *s, unsigned long count, int bit) { +long long serverBitpos(void *s, unsigned long count, int bit) { unsigned long *l; unsigned char *c; unsigned long skipval, word = 0, one; @@ -181,7 +181,7 @@ long long redisBitpos(void *s, unsigned long count, int bit) { /* If we reached this point, there is a bug in the algorithm, since * the case of no match is handled as a special case before. */ - serverPanic("End of redisBitpos() reached."); + serverPanic("End of serverBitpos() reached."); return 0; /* Just to avoid warnings. */ } @@ -989,7 +989,7 @@ void bitposCommand(client *c) { if (bit) tmpchar = tmpchar & ~last_byte_neg_mask; else tmpchar = tmpchar | last_byte_neg_mask; } - pos = redisBitpos(&tmpchar,1,bit); + pos = serverBitpos(&tmpchar,1,bit); /* If there are no more bytes or we get valid pos, we can exit early */ if (bytes == 1 || (pos != -1 && pos != 8)) goto result; start++; @@ -998,7 +998,7 @@ void bitposCommand(client *c) { /* If the last byte has not bits in the range, we should exclude it */ long curbytes = bytes - (last_byte_neg_mask ? 1 : 0); if (curbytes > 0) { - pos = redisBitpos(p+start,curbytes,bit); + pos = serverBitpos(p+start,curbytes,bit); /* If there is no more bytes or we get valid pos, we can exit early */ if (bytes == curbytes || (pos != -1 && pos != (long long)curbytes<<3)) goto result; start += curbytes; @@ -1006,14 +1006,14 @@ void bitposCommand(client *c) { } if (bit) tmpchar = p[end] & ~last_byte_neg_mask; else tmpchar = p[end] | last_byte_neg_mask; - pos = redisBitpos(&tmpchar,1,bit); + pos = serverBitpos(&tmpchar,1,bit); result: /* If we are looking for clear bits, and the user specified an exact * range with start-end, we can't consider the right of the range as * zero padded (as we do when no explicit end is given). * - * So if redisBitpos() returns the first bit outside the range, + * So if serverBitpos() returns the first bit outside the range, * we return -1 to the caller, to mean, in the specified range there * is not a single "0" bit. */ if (end_given && bit == 0 && pos == (long long)bytes<<3) { diff --git a/src/cli_commands.h b/src/cli_commands.h index 3b24dfa4d6..4642272eb4 100644 --- a/src/cli_commands.h +++ b/src/cli_commands.h @@ -41,6 +41,6 @@ struct commandDocs { char *params; /* A string describing the syntax of the command arguments. */ }; -extern struct commandDocs redisCommandTable[]; +extern struct commandDocs serverCommandTable[]; #endif diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index edb510d6e1..5874433d7d 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -5242,12 +5242,12 @@ void clusterSetMaster(clusterNode *n) { * Nodes to string representation functions. * -------------------------------------------------------------------------- */ -struct redisNodeFlags { +struct clusterNodeFlags { uint16_t flag; char *name; }; -static struct redisNodeFlags redisNodeFlagsTable[] = { +static struct clusterNodeFlags clusterNodeFlagsTable[] = { {CLUSTER_NODE_MYSELF, "myself,"}, {CLUSTER_NODE_MASTER, "master,"}, {CLUSTER_NODE_SLAVE, "slave,"}, @@ -5262,9 +5262,9 @@ static struct redisNodeFlags redisNodeFlagsTable[] = { * string 'ci'. */ sds representClusterNodeFlags(sds ci, uint16_t flags) { size_t orig_len = sdslen(ci); - int i, size = sizeof(redisNodeFlagsTable)/sizeof(struct redisNodeFlags); + int i, size = sizeof(clusterNodeFlagsTable)/sizeof(struct clusterNodeFlags); for (i = 0; i < size; i++) { - struct redisNodeFlags *nodeflag = redisNodeFlagsTable + i; + struct clusterNodeFlags *nodeflag = clusterNodeFlagsTable + i; if (flags & nodeflag->flag) ci = sdscat(ci, nodeflag->name); } /* If no flag was added, add the "noflags" special flag. */ diff --git a/src/commands.def b/src/commands.def index fd94d22ebc..7007568b61 100644 --- a/src/commands.def +++ b/src/commands.def @@ -10653,7 +10653,7 @@ struct COMMAND_ARG WATCH_Args[] = { }; /* Main command table */ -struct COMMAND_STRUCT redisCommandTable[] = { +struct COMMAND_STRUCT serverCommandTable[] = { /* bitmap */ {MAKE_CMD("bitcount","Counts the number of set bits (population counting) in a string.","O(N)","2.6.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITCOUNT_History,1,BITCOUNT_Tips,0,bitcountCommand,-2,CMD_READONLY,ACL_CATEGORY_BITMAP,BITCOUNT_Keyspecs,1,NULL,2),.args=BITCOUNT_Args}, {MAKE_CMD("bitfield","Performs arbitrary bitfield integer operations on strings.","O(1) for each subcommand specified","3.2.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITFIELD_History,0,BITFIELD_Tips,0,bitfieldCommand,-2,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_BITMAP,BITFIELD_Keyspecs,1,bitfieldGetKeys,2),.args=BITFIELD_Args}, diff --git a/src/rand.c b/src/rand.c index e1e98e63b9..7cd264fb12 100644 --- a/src/rand.c +++ b/src/rand.c @@ -68,12 +68,12 @@ static uint32_t x[3] = { X0, X1, X2 }, a[3] = { A0, A1, A2 }, c = C; static void next(void); -int32_t redisLrand48(void) { +int32_t serverLrand48(void) { next(); return (((int32_t)x[2] << (N - 1)) + (x[1] >> 1)); } -void redisSrand48(int32_t seedval) { +void serverSrand48(int32_t seedval) { SEED(X0, LOW(seedval), HIGH(seedval)); } diff --git a/src/rand.h b/src/rand.h index eb885803cd..2726c92b7f 100644 --- a/src/rand.h +++ b/src/rand.h @@ -30,8 +30,8 @@ #ifndef VALKEY_RANDOM_H #define VALKEY_RANDOM_H -int32_t redisLrand48(void); -void redisSrand48(int32_t seedval); +int32_t serverLrand48(void); +void serverSrand48(int32_t seedval); #define REDIS_LRAND48_MAX INT32_MAX diff --git a/src/script_lua.c b/src/script_lua.c index fbbd6e82fa..fb0739d773 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -1542,11 +1542,11 @@ static void luaCreateArray(lua_State *lua, robj **elev, int elec) { * (for the same seed) in every arch. */ /* The following implementation is the one shipped with Lua itself but with - * rand() replaced by redisLrand48(). */ + * rand() replaced by serverLrand48(). */ static int redis_math_random (lua_State *L) { /* the `%' avoids the (rare) case of r==1, and is needed also because on some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ - lua_Number r = (lua_Number)(redisLrand48()%REDIS_LRAND48_MAX) / + lua_Number r = (lua_Number)(serverLrand48()%REDIS_LRAND48_MAX) / (lua_Number)REDIS_LRAND48_MAX; switch (lua_gettop(L)) { /* check number of arguments */ case 0: { /* no arguments */ @@ -1572,7 +1572,7 @@ static int redis_math_random (lua_State *L) { } static int redis_math_randomseed (lua_State *L) { - redisSrand48(luaL_checkint(L, 1)); + serverSrand48(luaL_checkint(L, 1)); return 0; } diff --git a/src/server.c b/src/server.c index 5e35e93631..2043dce04b 100644 --- a/src/server.c +++ b/src/server.c @@ -3060,7 +3060,7 @@ int populateCommandStructure(struct serverCommand *c) { return C_OK; } -extern struct serverCommand redisCommandTable[]; +extern struct serverCommand serverCommandTable[]; /* Populates the Redis Command Table dict from the static table in commands.c * which is auto generated from the json files in the commands folder. */ @@ -3069,7 +3069,7 @@ void populateCommandTable(void) { struct serverCommand *c; for (j = 0;; j++) { - c = redisCommandTable + j; + c = serverCommandTable + j; if (c->declared_name == NULL) break; @@ -6297,7 +6297,7 @@ void usage(void) { exit(1); } -void redisAsciiArt(void) { +void serverAsciiArt(void) { #include "asciilogo.h" char *buf = zmalloc(1024*16); char *mode; @@ -6695,7 +6695,7 @@ void loadDataFromDisk(void) { } } -void redisOutOfMemoryHandler(size_t allocation_size) { +void serverOutOfMemoryHandler(size_t allocation_size) { serverLog(LL_WARNING,"Out Of Memory allocating %zu bytes!", allocation_size); serverPanic("Redis aborting for OUT OF MEMORY. Allocating %zu bytes!", @@ -6705,7 +6705,7 @@ void redisOutOfMemoryHandler(size_t allocation_size) { /* Callback for sdstemplate on proc-title-template. See valkey.conf for * supported variables. */ -static sds redisProcTitleGetVariable(const sds varname, void *arg) +static sds serverProcTitleGetVariable(const sds varname, void *arg) { if (!strcmp(varname, "title")) { return sdsnew(arg); @@ -6735,7 +6735,7 @@ static sds redisProcTitleGetVariable(const sds varname, void *arg) /* Expand the specified proc-title-template string and return a newly * allocated sds, or NULL. */ static sds expandProcTitleTemplate(const char *template, const char *title) { - sds res = sdstemplate(template, redisProcTitleGetVariable, (void *) title); + sds res = sdstemplate(template, serverProcTitleGetVariable, (void *) title); if (!res) return NULL; return sdstrim(res, " "); @@ -6792,7 +6792,7 @@ int serverCommunicateSystemd(const char *sd_notify_msg) { } /* Attempt to set up upstart supervision. Returns 1 if successful. */ -static int redisSupervisedUpstart(void) { +static int serverSupervisedUpstart(void) { const char *upstart_job = getenv("UPSTART_JOB"); if (!upstart_job) { @@ -6808,7 +6808,7 @@ static int redisSupervisedUpstart(void) { } /* Attempt to set up systemd supervision. Returns 1 if successful. */ -static int redisSupervisedSystemd(void) { +static int serverSupervisedSystemd(void) { #ifndef HAVE_LIBSYSTEMD serverLog(LL_WARNING, "systemd supervision requested or auto-detected, but Redis is compiled without libsystemd support!"); @@ -6837,10 +6837,10 @@ int redisIsSupervised(int mode) { switch (mode) { case SUPERVISED_UPSTART: - ret = redisSupervisedUpstart(); + ret = serverSupervisedUpstart(); break; case SUPERVISED_SYSTEMD: - ret = redisSupervisedSystemd(); + ret = serverSupervisedSystemd(); break; default: break; @@ -6867,12 +6867,12 @@ int __test_num = 0; /* The flags are the following: * --accurate: Runs tests with more iterations. * --large-memory: Enables tests that consume more than 100mb. */ -typedef int redisTestProc(int argc, char **argv, int flags); -struct redisTest { +typedef int serverTestProc(int argc, char **argv, int flags); +struct serverTest { char *name; - redisTestProc *proc; + serverTestProc *proc; int failed; -} redisTests[] = { +} serverTests[] = { {"ziplist", ziplistTest}, {"quicklist", quicklistTest}, {"intset", intsetTest}, @@ -6887,11 +6887,11 @@ struct redisTest { {"listpack", listpackTest}, {"kvstore", kvstoreTest}, }; -redisTestProc *getTestProcByName(const char *name) { - int numtests = sizeof(redisTests)/sizeof(struct redisTest); +serverTestProc *getTestProcByName(const char *name) { + int numtests = sizeof(serverTests)/sizeof(struct serverTest); for (int j = 0; j < numtests; j++) { - if (!strcasecmp(name,redisTests[j].name)) { - return redisTests[j].proc; + if (!strcasecmp(name,serverTests[j].name)) { + return serverTests[j].proc; } } return NULL; @@ -6915,19 +6915,19 @@ int main(int argc, char **argv) { } if (!strcasecmp(argv[2], "all")) { - int numtests = sizeof(redisTests)/sizeof(struct redisTest); + int numtests = sizeof(serverTest)/sizeof(struct redisTest); for (j = 0; j < numtests; j++) { - redisTests[j].failed = (redisTests[j].proc(argc,argv,flags) != 0); + serverTests[j].failed = (serverTests[j].proc(argc,argv,flags) != 0); } /* Report tests result */ int failed_num = 0; for (j = 0; j < numtests; j++) { - if (redisTests[j].failed) { + if (serverTests[j].failed) { failed_num++; - printf("[failed] Test - %s\n", redisTests[j].name); + printf("[failed] Test - %s\n", serverTests[j].name); } else { - printf("[ok] Test - %s\n", redisTests[j].name); + printf("[ok] Test - %s\n", serverTests[j].name); } } @@ -6936,7 +6936,7 @@ int main(int argc, char **argv) { return failed_num == 0 ? 0 : 1; } else { - redisTestProc *proc = getTestProcByName(argv[2]); + serverTestProc *proc = getTestProcByName(argv[2]); if (!proc) return -1; /* test not found */ return proc(argc,argv,flags); } @@ -6950,7 +6950,7 @@ int main(int argc, char **argv) { spt_init(argc, argv); #endif tzset(); /* Populates 'timezone' global. */ - zmalloc_set_oom_handler(redisOutOfMemoryHandler); + zmalloc_set_oom_handler(serverOutOfMemoryHandler); /* To achieve entropy, in case of containers, their time() and getpid() can * be the same. But value of tv_usec is fast enough to make the difference */ @@ -7171,7 +7171,7 @@ int main(int argc, char **argv) { initServer(); if (background || server.pidfile) createPidFile(); if (server.set_proc_title) serverSetProcTitle(NULL); - redisAsciiArt(); + serverAsciiArt(); checkTcpBacklogSettings(); if (server.cluster_enabled) { clusterInit(); diff --git a/src/server.h b/src/server.h index 1ea1bd7f57..95836def5b 100644 --- a/src/server.h +++ b/src/server.h @@ -3781,9 +3781,9 @@ sds getVersion(void); _serverLog(level, __VA_ARGS__);\ } while(0) -#define redisDebug(fmt, ...) \ +#define serverDebug(fmt, ...) \ printf("DEBUG %s:%d > " fmt "\n", __FILE__, __LINE__, __VA_ARGS__) -#define redisDebugMark() \ +#define serverDebugMark() \ printf("-- MARK %s:%d --\n", __FILE__, __LINE__) int iAmMaster(void); diff --git a/src/valkey-cli.c b/src/valkey-cli.c index b8e7d9a8e8..3c0c8cd09f 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -878,10 +878,10 @@ static void cliLegacyInitHelp(dict *groups) { sds serverVersion = cliGetServerVersion(); /* Scan the commandDocs array and fill in the entries */ - helpEntriesLen = cliLegacyCountCommands(redisCommandTable, serverVersion); + helpEntriesLen = cliLegacyCountCommands(serverCommandTable, serverVersion); helpEntries = zmalloc(sizeof(helpEntry)*helpEntriesLen); - helpEntriesLen = cliLegacyInitCommandHelpEntries(redisCommandTable, groups, serverVersion); + helpEntriesLen = cliLegacyInitCommandHelpEntries(serverCommandTable, groups, serverVersion); cliInitGroupHelpEntries(groups); qsort(helpEntries, helpEntriesLen, sizeof(helpEntry), helpEntryCompare); diff --git a/utils/generate-command-code.py b/utils/generate-command-code.py index 236bf40cfa..673ef28466 100755 --- a/utils/generate-command-code.py +++ b/utils/generate-command-code.py @@ -611,7 +611,7 @@ def create_command(name, desc): command.write_internal_structs(f) f.write("/* Main command table */\n") - f.write("struct COMMAND_STRUCT redisCommandTable[] = {\n") + f.write("struct COMMAND_STRUCT serverCommandTable[] = {\n") curr_group = None for command in command_list: if curr_group != command.group: From 9c5e2bb226c797d1eb815cddc342d4ed19a05e1e Mon Sep 17 00:00:00 2001 From: Lipeng Zhu Date: Thu, 4 Apr 2024 16:46:17 +0800 Subject: [PATCH 52/98] Changes references to redis binaries in output of "--help", "--version" (#113) Rename output from redis-* to valkey-* for binaries: 1. `valkey-benchmark` 2. `valkey-cli` 3. `valkey-server` 4. `valkey-sentinel` 5. `valkey-check-rdb` 6. `valkey-check-aof` "--help" "--version" option. Signed-off-by: Lipeng Zhu --- src/server.c | 2 +- src/valkey-benchmark.c | 18 +++++++++--------- src/valkey-check-aof.c | 4 ++-- src/valkey-check-rdb.c | 2 +- src/valkey-cli.c | 26 +++++++++++++------------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/server.c b/src/server.c index 2043dce04b..f6db140403 100644 --- a/src/server.c +++ b/src/server.c @@ -7011,7 +7011,7 @@ int main(int argc, char **argv) { strcmp(argv[1], "--version") == 0) { sds version = getVersion(); - printf("Redis server %s\n", version); + printf("Valkey server %s\n", version); sdsfree(version); exit(0); } diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index 48d178109c..b099751233 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -1403,7 +1403,7 @@ int parseOptions(int argc, char **argv) { config.numclients = atoi(argv[++i]); } else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) { sds version = cliVersion(); - printf("redis-benchmark %s\n", version); + printf("valkey-benchmark %s\n", version); sdsfree(version); exit(0); } else if (!strcmp(argv[i],"-n")) { @@ -1585,12 +1585,12 @@ int parseOptions(int argc, char **argv) { printf( "%s%s%s", /* Split to avoid strings longer than 4095 (-Woverlength-strings). */ -"Usage: redis-benchmark [OPTIONS] [COMMAND ARGS...]\n\n" +"Usage: valkey-benchmark [OPTIONS] [COMMAND ARGS...]\n\n" "Options:\n" " -h Server hostname (default 127.0.0.1)\n" " -p Server port (default 6379)\n" " -s Server socket (overrides host and port)\n" -" -a Password for Redis Auth\n" +" -a Password for Valkey Auth\n" " --user Used to send ACL style 'AUTH username pass'. Needs -a.\n" " -u Server URI on format redis://user:password@host:port/dbnum\n" " User, password and dbnum are optional. For authentication\n" @@ -1637,17 +1637,17 @@ tls_usage, " --version Output version and exit.\n\n" "Examples:\n\n" " Run the benchmark with the default configuration against 127.0.0.1:6379:\n" -" $ redis-benchmark\n\n" +" $ valkey-benchmark\n\n" " Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:\n" -" $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20\n\n" +" $ valkey-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20\n\n" " Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:\n" -" $ redis-benchmark -t set -n 1000000 -r 100000000\n\n" +" $ valkey-benchmark -t set -n 1000000 -r 100000000\n\n" " Benchmark 127.0.0.1:6379 for a few commands producing CSV output:\n" -" $ redis-benchmark -t ping,set,get -n 100000 --csv\n\n" +" $ valkey-benchmark -t ping,set,get -n 100000 --csv\n\n" " Benchmark a specific command line:\n" -" $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call(\"ping\")' 0\n\n" +" $ valkey-benchmark -r 10000 -n 10000 eval 'return redis.call(\"ping\")' 0\n\n" " Fill a list with 10000 random elements:\n" -" $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__\n\n" +" $ valkey-benchmark -r 10000 -n 10000 lpush mylist __rand_int__\n\n" " On user specified command lines __rand_int__ is replaced with a random integer\n" " with a range of values selected by the -r option.\n" ); diff --git a/src/valkey-check-aof.c b/src/valkey-check-aof.c index 0cc9c7b3fa..cf2888cb90 100644 --- a/src/valkey-check-aof.c +++ b/src/valkey-check-aof.c @@ -200,7 +200,7 @@ int processAnnotations(FILE *fp, char *filename, int last_file) { printf("Failed to truncate AOF %s to timestamp %ld to offset %ld because it is not the last file.\n", filename, to_timestamp, (long int)epos); printf("If you insist, please delete all files after this file according to the manifest " - "file and delete the corresponding records in manifest file manually. Then re-run redis-check-aof.\n"); + "file and delete the corresponding records in manifest file manually. Then re-run valkey-check-aof.\n"); exit(1); } /* Truncate remaining AOF if exceeding 'to_timestamp' */ @@ -526,7 +526,7 @@ int redis_check_aof_main(int argc, char **argv) { } else if (argc == 2) { if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { sds version = getVersion(); - printf("redis-check-aof %s\n", version); + printf("valkey-check-aof %s\n", version); sdsfree(version); exit(0); } diff --git a/src/valkey-check-rdb.c b/src/valkey-check-rdb.c index ffc201cb24..f938a48664 100644 --- a/src/valkey-check-rdb.c +++ b/src/valkey-check-rdb.c @@ -416,7 +416,7 @@ int redis_check_rdb_main(int argc, char **argv, FILE *fp) { exit(1); } else if (!strcmp(argv[1],"-v") || !strcmp(argv[1], "--version")) { sds version = getVersion(); - printf("redis-check-rdb %s\n", version); + printf("valkey-check-rdb %s\n", version); sdsfree(version); exit(0); } diff --git a/src/valkey-cli.c b/src/valkey-cli.c index 3c0c8cd09f..ba16d03fa7 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -2904,7 +2904,7 @@ static int parseOptions(int argc, char **argv) { #endif } else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) { sds version = cliVersion(); - printf("redis-cli %s\n", version); + printf("valkey-cli %s\n", version); sdsfree(version); exit(0); } else if (!strcmp(argv[i],"-2")) { @@ -3023,9 +3023,9 @@ static void usage(int err) { ""; fprintf(target, -"redis-cli %s\n" +"valkey-cli %s\n" "\n" -"Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]\n" +"Usage: valkey-cli [OPTIONS] [cmd [arg [arg ...]]]\n" " -h Server hostname (default: 127.0.0.1).\n" " -p Server port (default: 6379).\n" " -t Server connection timeout in seconds (decimals allowed).\n" @@ -3130,19 +3130,19 @@ version,tls_usage); " Use --cluster help to list all available cluster manager commands.\n" "\n" "Examples:\n" -" redis-cli -u redis://default:PASSWORD@localhost:6379/0\n" -" cat /etc/passwd | redis-cli -x set mypasswd\n" -" redis-cli -D \"\" --raw dump key > key.dump && redis-cli -X dump_tag restore key2 0 dump_tag replace < key.dump\n" -" redis-cli -r 100 lpush mylist x\n" -" redis-cli -r 100 -i 1 info | grep used_memory_human:\n" -" redis-cli --quoted-input set '\"null-\\x00-separated\"' value\n" -" redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3\n" -" redis-cli --scan --pattern '*:12345*'\n" -" redis-cli --scan --pattern '*:12345*' --count 100\n" +" valkey-cli -u redis://default:PASSWORD@localhost:6379/0\n" +" cat /etc/passwd | valkey-cli -x set mypasswd\n" +" valkey-cli -D \"\" --raw dump key > key.dump && valkey-cli -X dump_tag restore key2 0 dump_tag replace < key.dump\n" +" valkey-cli -r 100 lpush mylist x\n" +" valkey-cli -r 100 -i 1 info | grep used_memory_human:\n" +" valkey-cli --quoted-input set '\"null-\\x00-separated\"' value\n" +" valkey-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3\n" +" valkey-cli --scan --pattern '*:12345*'\n" +" valkey-cli --scan --pattern '*:12345*' --count 100\n" "\n" " (Note: when using --eval the comma separates KEYS[] from ARGV[] items)\n" "\n" -"When no command is given, redis-cli starts in interactive mode.\n" +"When no command is given, valkey-cli starts in interactive mode.\n" "Type \"help\" in interactive mode for information on available commands\n" "and settings.\n" "\n"); From 48184ae2dbb42e786de13f9ea6c99bfd0e1dbdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Thu, 4 Apr 2024 16:42:14 +0200 Subject: [PATCH 53/98] In CONTIBUTING.md, mention how to link PR to issue (#197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This little suggestion can help contributors to link their PRs to issues. This, in turn, helps the maintainers. Signed-off-by: Viktor Söderqvist --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5969bce874..58bec521fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -104,4 +104,7 @@ view, and so forth. This helps. 4. For minor fixes - open a pull request on GitHub. +To link a pull request to an existing issue, please write "Fixes #xyz" somewhere +in the pull request description, where xyz is the issue number. + Thanks! From 6ea6a693e20ef5db2c154336756dfda0128acb85 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:21:11 +0700 Subject: [PATCH 54/98] Rename 'redis' to 'server' functions missing (#203) related: https://github.com/valkey-io/valkey/issues/144 --------- Signed-off-by: 0del --- src/server.c | 4 ++-- src/valkey-benchmark.c | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/server.c b/src/server.c index f6db140403..cd08829440 100644 --- a/src/server.c +++ b/src/server.c @@ -6822,7 +6822,7 @@ static int serverSupervisedSystemd(void) { #endif } -int redisIsSupervised(int mode) { +int serverIsSupervised(int mode) { int ret = 0; if (mode == SUPERVISED_AUTODETECT) { @@ -7150,7 +7150,7 @@ int main(int argc, char **argv) { #endif /* __linux__ */ /* Daemonize if needed */ - server.supervised = redisIsSupervised(server.supervised_mode); + server.supervised = serverIsSupervised(server.supervised_mode); int background = server.daemonize && !server.supervised; if (background) daemonize(); diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index b099751233..1a7b9f6c56 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -76,7 +76,7 @@ struct benchmarkThread; struct clusterNode; -struct redisConfig; +struct serverConfig; static struct config { aeEventLoop *el; @@ -115,7 +115,7 @@ static struct config { int cluster_mode; int cluster_node_count; struct clusterNode **cluster_nodes; - struct redisConfig *redis_config; + struct serverConfig *redis_config; struct hdr_histogram* latency_histogram; struct hdr_histogram* current_sec_latency_histogram; serverAtomic int is_fetching_slots; @@ -175,13 +175,13 @@ typedef struct clusterNode { * strings are the source node IDs. */ int migrating_count; /* Length of the migrating array (migrating slots*2) */ int importing_count; /* Length of the importing array (importing slots*2) */ - struct redisConfig *redis_config; + struct serverConfig *redis_config; } clusterNode; -typedef struct redisConfig { +typedef struct serverConfig { sds save; sds appendonly; -} redisConfig; +} serverConfig; /* Prototypes */ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask); @@ -191,11 +191,11 @@ static void freeBenchmarkThread(benchmarkThread *thread); static void freeBenchmarkThreads(void); static void *execBenchmarkThread(void *ptr); static clusterNode *createClusterNode(char *ip, int port); -static redisConfig *getRedisConfig(const char *ip, int port, +static serverConfig *getServerConfig(const char *ip, int port, const char *hostsocket); static redisContext *getRedisContext(const char *ip, int port, const char *hostsocket); -static void freeRedisConfig(redisConfig *cfg); +static void freeServerConfig(serverConfig *cfg); static int fetchClusterSlotsConfiguration(client c); static void updateClusterSlotsConfiguration(void); int showThroughput(struct aeEventLoop *eventLoop, long long id, @@ -292,16 +292,16 @@ static redisContext *getRedisContext(const char *ip, int port, -static redisConfig *getRedisConfig(const char *ip, int port, +static serverConfig *getServerConfig(const char *ip, int port, const char *hostsocket) { - redisConfig *cfg = zcalloc(sizeof(*cfg)); + serverConfig *cfg = zcalloc(sizeof(*cfg)); if (!cfg) return NULL; redisContext *c = NULL; redisReply *reply = NULL, *sub_reply = NULL; c = getRedisContext(ip, port, hostsocket); if (c == NULL) { - freeRedisConfig(cfg); + freeServerConfig(cfg); exit(1); } redisAppendCommand(c, "CONFIG GET %s", "save"); @@ -340,11 +340,11 @@ static redisConfig *getRedisConfig(const char *ip, int port, } freeReplyObject(reply); redisFree(c); - freeRedisConfig(cfg); + freeServerConfig(cfg); if (abort_test) exit(1); return NULL; } -static void freeRedisConfig(redisConfig *cfg) { +static void freeServerConfig(serverConfig *cfg) { if (cfg->save) sdsfree(cfg->save); if (cfg->appendonly) sdsfree(cfg->appendonly); zfree(cfg); @@ -870,7 +870,7 @@ static void showLatencyReport(void) { int m ; for (m = 0; m < config.cluster_node_count; m++) { clusterNode *node = config.cluster_nodes[m]; - redisConfig *cfg = node->redis_config; + serverConfig *cfg = node->redis_config; if (cfg == NULL) continue; printf(" node [%d] configuration:\n",m ); printf(" save: %s\n", @@ -1071,7 +1071,7 @@ static void freeClusterNode(clusterNode *node) { * config.conn_info.hostip and config.conn_info.hostport, then the node ip has been * allocated by fetchClusterConfiguration, so it must be freed. */ if (node->ip && strcmp(node->ip, config.conn_info.hostip) != 0) sdsfree(node->ip); - if (node->redis_config != NULL) freeRedisConfig(node->redis_config); + if (node->redis_config != NULL) freeServerConfig(node->redis_config); zfree(node->slots); zfree(node); } @@ -1803,7 +1803,7 @@ int main(int argc, char **argv) { printf("Master %d: ", i); if (node->name) printf("%s ", node->name); printf("%s:%d\n", node->ip, node->port); - node->redis_config = getRedisConfig(node->ip, node->port, NULL); + node->redis_config = getServerConfig(node->ip, node->port, NULL); if (node->redis_config == NULL) { fprintf(stderr, "WARNING: Could not fetch node CONFIG %s:%d\n", node->ip, node->port); @@ -1816,7 +1816,7 @@ int main(int argc, char **argv) { config.num_threads = config.cluster_node_count; } else { config.redis_config = - getRedisConfig(config.conn_info.hostip, config.conn_info.hostport, config.hostsocket); + getServerConfig(config.conn_info.hostip, config.conn_info.hostport, config.hostsocket); if (config.redis_config == NULL) { fprintf(stderr, "WARNING: Could not fetch server CONFIG\n"); } @@ -1884,7 +1884,7 @@ int main(int argc, char **argv) { sdsfreesplitres(sds_args, argc); sdsfree(title); - if (config.redis_config != NULL) freeRedisConfig(config.redis_config); + if (config.redis_config != NULL) freeServerConfig(config.redis_config); zfree(argvlen); return 0; } @@ -2041,7 +2041,7 @@ int main(int argc, char **argv) { zfree(data); freeCliConnInfo(config.conn_info); - if (config.redis_config != NULL) freeRedisConfig(config.redis_config); + if (config.redis_config != NULL) freeServerConfig(config.redis_config); return 0; } From a0b09763d0c1fb5000b0bbcb18c4d545670ebb53 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Thu, 4 Apr 2024 12:40:04 -0400 Subject: [PATCH 55/98] Update remaning redis to valkey in TLS.md (#201) Updated TLS.md to remove references to Redis and replace them with Valkey. Signed-off-by: hwware --- TLS.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/TLS.md b/TLS.md index 51bfeae08a..c87975f204 100644 --- a/TLS.md +++ b/TLS.md @@ -9,27 +9,27 @@ Getting Started To build with TLS support you'll need OpenSSL development libraries (e.g. libssl-dev on Debian/Ubuntu). -To build TLS support as Redis built-in: +To build TLS support as Valkey built-in: Run `make BUILD_TLS=yes`. -Or to build TLS as Redis module: +Or to build TLS as Valkey module: Run `make BUILD_TLS=module`. Note that sentinel mode does not support TLS module. ### Tests -To run Redis test suite with TLS, you'll need TLS support for TCL (i.e. +To run Valkey test suite with TLS, you'll need TLS support for TCL (i.e. `tcl-tls` package on Debian/Ubuntu). 1. Run `./utils/gen-test-certs.sh` to generate a root CA and a server certificate. -2. Run `./runtest --tls` or `./runtest-cluster --tls` to run Redis and Redis +2. Run `./runtest --tls` or `./runtest-cluster --tls` to run Valkey and Valkey Cluster tests in TLS mode. 3. Run `./runtest --tls-module` or `./runtest-cluster --tls-module` to - run Redis and Redis cluster tests in TLS mode with Redis module. + run Valkey and Valkey cluster tests in TLS mode with Valkey module. ### Running manually @@ -49,18 +49,18 @@ For TLS module mode: --tls-ca-cert-file ./tests/tls/ca.crt \ --loadmodule src/valkey-tls.so -To connect to this Redis server with `valkey-cli`: +To connect to this Valkey server with `valkey-cli`: ./src/valkey-cli --tls \ - --cert ./tests/tls/redis.crt \ - --key ./tests/tls/redis.key \ + --cert ./tests/tls/valkey.crt \ + --key ./tests/tls/valkey.key \ --cacert ./tests/tls/ca.crt This will disable TCP and enable TLS on port 6379. It's also possible to have both TCP and TLS available, but you'll need to assign different ports. To make a Replica connect to the master using TLS, use `--tls-replication yes`, -and to make Redis Cluster use TLS across nodes use `--tls-cluster yes`. +and to make Valkey Cluster use TLS across nodes use `--tls-cluster yes`. Connections ----------- @@ -85,18 +85,18 @@ but there are probably other good reasons to improve that part anyway. To-Do List ---------- -- [ ] redis-benchmark support. The current implementation is a mix of using +- [ ] valkey-benchmark support. The current implementation is a mix of using hiredis for parsing and basic networking (establishing connections), but directly manipulating sockets for most actions. This will need to be cleaned up for proper TLS support. The best approach is probably to migrate to hiredis async mode. -- [ ] redis-cli `--slave` and `--rdb` support. +- [ ] valkey-cli `--slave` and `--rdb` support. Multi-port ---------- Consider the implications of allowing TLS to be configured on a separate port, -making Redis listening on multiple ports: +making Valkey listening on multiple ports: 1. Startup banner port notification 2. Proctitle From 29621bc356116051c09d2ba7b8a405eeaa04be95 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Thu, 4 Apr 2024 14:54:49 -0400 Subject: [PATCH 56/98] Update Valkey keyword in sentinel.conf (#171) Mostly comments, but one pre-filled config in this template config file is changed: pidfile /var/run/valkey-sentinel.pid --------- Signed-off-by: hwware --- sentinel.conf | 53 ++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/sentinel.conf b/sentinel.conf index 0180558b4f..36a21e9331 100644 --- a/sentinel.conf +++ b/sentinel.conf @@ -9,15 +9,15 @@ protected-mode no # The port that this sentinel instance will run on port 26379 -# By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it. -# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when +# By default Valkey Sentinel does not run as a daemon. Use 'yes' if you need it. +# Note that Valkey will write a pid file in /var/run/valkey-sentinel.pid when # daemonized. daemonize no -# When running daemonized, Redis Sentinel writes a pid file in -# /var/run/redis-sentinel.pid by default. You can specify a custom pid file +# When running daemonized, Valkey Sentinel writes a pid file in +# /var/run/valkey-sentinel.pid by default. You can specify a custom pid file # location here. -pidfile /var/run/redis-sentinel.pid +pidfile /var/run/valkey-sentinel.pid # Specify the server verbosity level. # This can be one of: @@ -67,12 +67,12 @@ logfile "" # dir # Every long running process should have a well-defined working directory. -# For Redis Sentinel to chdir to /tmp at startup is the simplest thing +# For Valkey Sentinel to chdir to /tmp at startup is the simplest thing # for the process to don't interfere with administrative tasks such as # unmounting filesystems. dir /tmp -# sentinel monitor +# sentinel monitor # # Tells Sentinel to monitor this master, and to consider it in O_DOWN # (Objectively Down) state only if at least sentinels agree. @@ -94,16 +94,16 @@ sentinel monitor mymaster 127.0.0.1 6379 2 # sentinel auth-pass # # Set the password to use to authenticate with the master and replicas. -# Useful if there is a password set in the Redis instances to monitor. +# Useful if there is a password set in the Valkey instances to monitor. # # Note that the master password is also used for replicas, so it is not # possible to set a different password in masters and replicas instances # if you want to be able to monitor these instances with Sentinel. # -# However you can have Redis instances without the authentication enabled -# mixed with Redis instances requiring the authentication (as long as the +# However you can have Valkey instances without the authentication enabled +# mixed with Valkey instances requiring the authentication (as long as the # password set is the same for all the instances requiring the password) as -# the AUTH command will have no effect in Redis instances with authentication +# the AUTH command will have no effect in Valkey instances with authentication # switched off. # # Example: @@ -113,10 +113,10 @@ sentinel monitor mymaster 127.0.0.1 6379 2 # sentinel auth-user # # This is useful in order to authenticate to instances having ACL capabilities, -# that is, running Redis 6.0 or greater. When just auth-pass is provided the -# Sentinel instance will authenticate to Redis using the old "AUTH " +# that is, running Valkey. When just auth-pass is provided the +# Sentinel instance will authenticate to Valkey using the old "AUTH " # method. When also an username is provided, it will use "AUTH ". -# In the Redis servers side, the ACL to provide just minimal access to +# In the Valkey servers side, the ACL to provide just minimal access to # Sentinel instances, should be configured along the following lines: # # user sentinel-user >somepassword +client +subscribe +publish \ @@ -132,9 +132,6 @@ sentinel monitor mymaster 127.0.0.1 6379 2 # Default is 30 seconds. sentinel down-after-milliseconds mymaster 30000 -# IMPORTANT NOTE: starting with Redis 6.2 ACL capability is supported for -# Sentinel mode, please refer to the Redis website https://redis.io/topics/acl -# for more details. # Sentinel's ACL users are defined in the following format: # @@ -145,7 +142,7 @@ sentinel down-after-milliseconds mymaster 30000 # user worker +@admin +@connection ~* on >ffa9203c493aa99 # # For more information about ACL configuration please refer to the Redis -# website at https://redis.io/topics/acl and redis server configuration +# website at https://valkey.io/topics/acl and valkey server configuration # template valkey.conf. # ACL LOG @@ -166,7 +163,7 @@ acllog-max-len 128 # The format of the external ACL user file is exactly the same as the # format that is used inside valkey.conf to describe users. # -# aclfile /etc/redis/sentinel-users.acl +# aclfile /etc/valkey/sentinel-users.acl # requirepass # @@ -174,9 +171,9 @@ acllog-max-len 128 # so Sentinel will try to authenticate with the same password to all the # other Sentinels. So you need to configure all your Sentinels in a given # group with the same "requirepass" password. Check the following documentation -# for more info: https://redis.io/topics/sentinel +# for more info: https://valkey.io/topics/sentinel # -# IMPORTANT NOTE: starting with Redis 6.2 "requirepass" is a compatibility +# IMPORTANT NOTE: "requirepass" is a compatibility # layer on top of the ACL system. The option effect will be just setting # the password for the default user. Clients will still authenticate using # AUTH as usually, or more explicitly with AUTH default @@ -259,7 +256,7 @@ sentinel failover-timeout mymaster 180000 # generated in the WARNING level (for instance -sdown, -odown, and so forth). # This script should notify the system administrator via email, SMS, or any # other messaging system, that there is something wrong with the monitored -# Redis systems. +# Valkey systems. # # The script is called with just two arguments: the first is the event type # and the second the event description. @@ -269,7 +266,7 @@ sentinel failover-timeout mymaster 180000 # # Example: # -# sentinel notification-script mymaster /var/redis/notify.sh +# sentinel notification-script mymaster /var/valkey/notify.sh # CLIENTS RECONFIGURATION SCRIPT # @@ -294,7 +291,7 @@ sentinel failover-timeout mymaster 180000 # # Example: # -# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh +# sentinel client-reconfig-script mymaster /var/valkey/reconfig.sh # SECURITY # @@ -305,13 +302,13 @@ sentinel failover-timeout mymaster 180000 sentinel deny-scripts-reconfig yes -# REDIS COMMANDS RENAMING (DEPRECATED) +# VALKEY COMMANDS RENAMING (DEPRECATED) # # WARNING: avoid using this option if possible, instead use ACLs. # -# Sometimes the Redis server has certain commands, that are needed for Sentinel +# Sometimes the Valkey server has certain commands, that are needed for Sentinel # to work correctly, renamed to unguessable strings. This is often the case -# of CONFIG and SLAVEOF in the context of providers that provide Redis as +# of CONFIG and SLAVEOF in the context of providers that provide Valkey as # a service, and don't want the customers to reconfigure the instances outside # of the administration console. # @@ -335,7 +332,7 @@ sentinel deny-scripts-reconfig yes # HOSTNAMES SUPPORT # # Normally Sentinel uses only IP addresses and requires SENTINEL MONITOR -# to specify an IP address. Also, it requires the Redis replica-announce-ip +# to specify an IP address. Also, it requires the Valkey replica-announce-ip # keyword to specify only IP addresses. # # You may enable hostnames support by enabling resolve-hostnames. Note From 4646d0825e3d08285dbbaec71af6848b40034cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Thu, 4 Apr 2024 23:18:37 +0200 Subject: [PATCH 57/98] Redis in HELP commands (#216) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the word Redis in the output of COMMAND HELP and DEBUG HELP. --------- Signed-off-by: Viktor Söderqvist --- src/debug.c | 10 +++++----- src/server.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/debug.c b/src/debug.c index c64fba2b5b..bdae441005 100644 --- a/src/debug.c +++ b/src/debug.c @@ -410,14 +410,14 @@ void debugCommand(client *c) { "DIGEST-VALUE [ ...]", " Output a hex signature of the values of all the specified keys.", "ERROR ", -" Return a Redis protocol error with as message. Useful for clients", -" unit tests to simulate Redis errors.", +" Return a RESP protocol error with as message. Useful for clients", +" unit tests to simulate error replies.", "LEAK ", " Create a memory leak of the input string.", "LOG ", " Write to the server log.", "HTSTATS [full]", -" Return hash table statistics of the specified Redis database.", +" Return hash table statistics of the specified database.", "HTSTATS-KEY [full]", " Like HTSTATS but for the hash table stored at 's value.", "LOADAOF", @@ -468,7 +468,7 @@ void debugCommand(client *c) { " Crash the server with sigsegv.", "SET-ACTIVE-EXPIRE <0|1>", " Setting it to 0 disables expiring keys in background when they are not", -" accessed (otherwise the Redis behavior). Setting it to 1 reenables back the", +" accessed (otherwise the behavior). Setting it to 1 reenables back the", " default.", "QUICKLIST-PACKED-THRESHOLD ", " Sets the threshold for elements to be inserted as plain vs packed nodes", @@ -480,7 +480,7 @@ void debugCommand(client *c) { "STRINGMATCH-TEST", " Run a fuzz tester against the stringmatchlen() function.", "STRUCTSIZE", -" Return the size of different Redis core C structures.", +" Return the size of different core C structures.", "LISTPACK ", " Show low level info about the listpack encoding of .", "QUICKLIST [<0|1>]", diff --git a/src/server.c b/src/server.c index cd08829440..0c4e5999ae 100644 --- a/src/server.c +++ b/src/server.c @@ -5303,23 +5303,23 @@ void commandGetKeysCommand(client *c) { void commandHelpCommand(client *c) { const char *help[] = { "(no subcommand)", -" Return details about all Redis commands.", +" Return details about all commands.", "COUNT", -" Return the total number of commands in this Redis server.", +" Return the total number of commands in this server.", "LIST", -" Return a list of all commands in this Redis server.", +" Return a list of all commands in this server.", "INFO [ ...]", -" Return details about multiple Redis commands.", +" Return details about multiple commands.", " If no command names are given, documentation details for all", " commands are returned.", "DOCS [ ...]", -" Return documentation details about multiple Redis commands.", +" Return documentation details about multiple commands.", " If no command names are given, documentation details for all", " commands are returned.", "GETKEYS ", -" Return the keys from a full Redis command.", +" Return the keys from a full command.", "GETKEYSANDFLAGS ", -" Return the keys and the access flags from a full Redis command.", +" Return the keys and the access flags from a full command.", NULL }; From bb1a3fffe73bb37a5bb63044128917a0bc091230 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Thu, 4 Apr 2024 17:37:15 -0400 Subject: [PATCH 58/98] Fix CI break issue due to serverTests merged issue (#218) Here is the latest CI run result for this PR https://github.com/hwware/placeholderkv/actions/runs/8561152261 Signed-off-by: hwware --- src/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.c b/src/server.c index 0c4e5999ae..e2e906e69e 100644 --- a/src/server.c +++ b/src/server.c @@ -6915,7 +6915,7 @@ int main(int argc, char **argv) { } if (!strcasecmp(argv[2], "all")) { - int numtests = sizeof(serverTest)/sizeof(struct redisTest); + int numtests = sizeof(serverTests)/sizeof(struct serverTest); for (j = 0; j < numtests; j++) { serverTests[j].failed = (serverTests[j].proc(argc,argv,flags) != 0); } From 490f4ebb65c94538e89d8e6fbfc5fd50b21725bc Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Thu, 4 Apr 2024 21:41:45 -0400 Subject: [PATCH 59/98] Update runtest test name and test filename (#214) Update runtest test name and test filename Signed-off-by: hwware --- tests/integration/aof-multi-part.tcl | 10 +++++----- tests/integration/aof.tcl | 18 +++++++++--------- ...edis-benchmark.tcl => valkey-benchmark.tcl} | 0 .../{redis-cli.tcl => valkey-cli.tcl} | 0 tests/test_helper.tcl | 4 ++-- tests/unit/cluster/cli.tcl | 14 +++++++------- tests/unit/functions.tcl | 2 +- tests/unit/introspection.tcl | 14 +++++++------- tests/unit/other.tcl | 2 +- tests/unit/scripting.tcl | 4 ++-- 10 files changed, 34 insertions(+), 34 deletions(-) rename tests/integration/{redis-benchmark.tcl => valkey-benchmark.tcl} (100%) rename tests/integration/{redis-cli.tcl => valkey-cli.tcl} (100%) diff --git a/tests/integration/aof-multi-part.tcl b/tests/integration/aof-multi-part.tcl index bdd0382339..383dbeb73e 100644 --- a/tests/integration/aof-multi-part.tcl +++ b/tests/integration/aof-multi-part.tcl @@ -590,7 +590,7 @@ tags {"external:skip"} { clean_aof_persistence $aof_dirpath } - test {Multi Part AOF can upgrade when when two redis share the same server dir} { + test {Multi Part AOF can upgrade when when two servers share the same server dir} { create_aof $server_path $aof_old_name_old_path { append_to_aof [formatCommand set k1 v1] append_to_aof [formatCommand set k2 v2] @@ -609,7 +609,7 @@ tags {"external:skip"} { start_server [list overrides [list dir $server_path appendonly yes appendfilename appendonly.aof2]] { set redis2 [redis [srv host] [srv port] 0 $::tls] - test "Multi Part AOF can upgrade when when two redis share the same server dir (redis1)" { + test "Multi Part AOF can upgrade when when two servers share the same server dir (server1)" { wait_done_loading $redis1 assert_equal v1 [$redis1 get k1] assert_equal v2 [$redis1 get k2] @@ -640,7 +640,7 @@ tags {"external:skip"} { assert {$d1 eq $d2} } - test "Multi Part AOF can upgrade when when two redis share the same server dir (redis2)" { + test "Multi Part AOF can upgrade when when two servers share the same server dir (server2)" { wait_done_loading $redis2 assert_equal 0 [$redis2 exists k1] @@ -700,7 +700,7 @@ tags {"external:skip"} { clean_aof_persistence $aof_dirpath } - test {Multi Part AOF can create BASE (RDB format) when redis starts from empty} { + test {Multi Part AOF can create BASE (RDB format) when server starts from empty} { start_server_aof [list dir $server_path] { set client [redis [srv host] [srv port] 0 $::tls] wait_done_loading $client @@ -723,7 +723,7 @@ tags {"external:skip"} { clean_aof_persistence $aof_dirpath } - test {Multi Part AOF can create BASE (AOF format) when redis starts from empty} { + test {Multi Part AOF can create BASE (AOF format) when server starts from empty} { start_server_aof [list dir $server_path aof-use-rdb-preamble no] { set client [redis [srv host] [srv port] 0 $::tls] wait_done_loading $client diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 31afee7268..6006a00ff9 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -104,7 +104,7 @@ tags {"aof external:skip"} { } } - ## Test that redis-check-aof indeed sees this AOF is not valid + ## Test that valkey-check-aof indeed sees this AOF is not valid test "Short read: Utility should confirm the AOF is not valid" { catch { exec src/valkey-check-aof $aof_manifest_file @@ -469,7 +469,7 @@ tags {"aof external:skip"} { } } - test {Test redis-check-aof for old style resp AOF} { + test {Test valkey-check-aof for old style resp AOF} { create_aof $aof_dirpath $aof_file { append_to_aof [formatCommand set foo hello] append_to_aof [formatCommand set bar world] @@ -481,7 +481,7 @@ tags {"aof external:skip"} { assert_match "*Start checking Old-Style AOF*is valid*" $result } - test {Test redis-check-aof for old style resp AOF - has data in the same format as manifest} { + test {Test valkey-check-aof for old style resp AOF - has data in the same format as manifest} { create_aof $aof_dirpath $aof_file { append_to_aof [formatCommand set file file] append_to_aof [formatCommand set "file appendonly.aof.2.base.rdb seq 2 type b" "file appendonly.aof.2.base.rdb seq 2 type b"] @@ -493,14 +493,14 @@ tags {"aof external:skip"} { assert_match "*Start checking Old-Style AOF*is valid*" $result } - test {Test redis-check-aof for old style rdb-preamble AOF} { + test {Test valkey-check-aof for old style rdb-preamble AOF} { catch { exec src/valkey-check-aof tests/assets/rdb-preamble.aof } result assert_match "*Start checking Old-Style AOF*RDB preamble is OK, proceeding with AOF tail*is valid*" $result } - test {Test redis-check-aof for Multi Part AOF with resp AOF base} { + test {Test valkey-check-aof for Multi Part AOF with resp AOF base} { create_aof $aof_dirpath $aof_base_file { append_to_aof [formatCommand set foo hello] append_to_aof [formatCommand set bar world] @@ -522,7 +522,7 @@ tags {"aof external:skip"} { assert_match "*Start checking Multi Part AOF*Start to check BASE AOF (RESP format)*BASE AOF*is valid*Start to check INCR files*INCR AOF*is valid*All AOF files and manifest are valid*" $result } - test {Test redis-check-aof for Multi Part AOF with rdb-preamble AOF base} { + test {Test valkey-check-aof for Multi Part AOF with rdb-preamble AOF base} { exec cp tests/assets/rdb-preamble.aof $aof_base_file create_aof $aof_dirpath $aof_file { @@ -541,7 +541,7 @@ tags {"aof external:skip"} { assert_match "*Start checking Multi Part AOF*Start to check BASE AOF (RDB format)*DB preamble is OK, proceeding with AOF tail*BASE AOF*is valid*Start to check INCR files*INCR AOF*is valid*All AOF files and manifest are valid*" $result } - test {Test redis-check-aof for Multi Part AOF contains a format error} { + test {Test valkey-check-aof for Multi Part AOF contains a format error} { create_aof_manifest $aof_dirpath $aof_manifest_file { append_to_manifest "file appendonly.aof.1.base.aof seq 1 type b\n" append_to_manifest "file appendonly.aof.1.incr.aof seq 1 type i\n" @@ -554,7 +554,7 @@ tags {"aof external:skip"} { assert_match "*Invalid AOF manifest file format*" $result } - test {Test redis-check-aof only truncates the last file for Multi Part AOF in fix mode} { + test {Test valkey-check-aof only truncates the last file for Multi Part AOF in fix mode} { create_aof $aof_dirpath $aof_base_file { append_to_aof [formatCommand set foo hello] append_to_aof [formatCommand multi] @@ -582,7 +582,7 @@ tags {"aof external:skip"} { assert_match "*Failed to truncate AOF*because it is not the last file*" $result } - test {Test redis-check-aof only truncates the last file for Multi Part AOF in truncate-to-timestamp mode} { + test {Test valkey-check-aof only truncates the last file for Multi Part AOF in truncate-to-timestamp mode} { create_aof $aof_dirpath $aof_base_file { append_to_aof "#TS:1628217470\r\n" append_to_aof [formatCommand set foo1 bar1] diff --git a/tests/integration/redis-benchmark.tcl b/tests/integration/valkey-benchmark.tcl similarity index 100% rename from tests/integration/redis-benchmark.tcl rename to tests/integration/valkey-benchmark.tcl diff --git a/tests/integration/redis-cli.tcl b/tests/integration/valkey-cli.tcl similarity index 100% rename from tests/integration/redis-cli.tcl rename to tests/integration/valkey-cli.tcl diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 3e51541580..6d9ca6299a 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -64,8 +64,8 @@ set ::all_tests { integration/psync2-pingoff integration/psync2-master-restart integration/failover - integration/redis-cli - integration/redis-benchmark + integration/valkey-cli + integration/valkey-benchmark integration/dismiss-mem unit/pubsub unit/pubsubshard diff --git a/tests/unit/cluster/cli.tcl b/tests/unit/cluster/cli.tcl index 136984da88..734dd19c9f 100644 --- a/tests/unit/cluster/cli.tcl +++ b/tests/unit/cluster/cli.tcl @@ -156,14 +156,14 @@ start_multiple_servers 3 [list overrides $base_conf] { } ;# stop servers -# Test redis-cli -- cluster create, add-node, call. +# Test valkey-cli -- cluster create, add-node, call. # Test that functions are propagated on add-node start_multiple_servers 5 [list overrides $base_conf] { set node4_rd [redis_client -3] set node5_rd [redis_client -4] - test {Functions are added to new node on redis-cli cluster add-node} { + test {Functions are added to new node on valkey-cli cluster add-node} { exec src/valkey-cli --cluster-yes --cluster create \ 127.0.0.1:[srv 0 port] \ 127.0.0.1:[srv -1 port] \ @@ -221,9 +221,9 @@ start_multiple_servers 5 [list overrides $base_conf] { } } ;# stop servers -# Test redis-cli --cluster create, add-node. +# Test valkey-cli --cluster create, add-node. # Test that one slot can be migrated to and then away from the new node. -test {Migrate the last slot away from a node using redis-cli} { +test {Migrate the last slot away from a node using valkey-cli} { start_multiple_servers 4 [list overrides $base_conf] { # Create a cluster of 3 nodes @@ -329,7 +329,7 @@ test {Migrate the last slot away from a node using redis-cli} { foreach ip_or_localhost {127.0.0.1 localhost} { -# Test redis-cli --cluster create, add-node with cluster-port. +# Test valkey-cli --cluster create, add-node with cluster-port. # Create five nodes, three with custom cluster_port and two with default values. start_server [list overrides [list cluster-enabled yes cluster-node-timeout 1 cluster-port [find_available_port $::baseport $::portcount]]] { start_server [list overrides [list cluster-enabled yes cluster-node-timeout 1]] { @@ -340,7 +340,7 @@ start_server [list overrides [list cluster-enabled yes cluster-node-timeout 1 cl # The first three are used to test --cluster create. # The last two are used to test --cluster add-node - test "redis-cli -4 --cluster create using $ip_or_localhost with cluster-port" { + test "valkey-cli -4 --cluster create using $ip_or_localhost with cluster-port" { exec src/valkey-cli -4 --cluster-yes --cluster create \ $ip_or_localhost:[srv 0 port] \ $ip_or_localhost:[srv -1 port] \ @@ -360,7 +360,7 @@ start_server [list overrides [list cluster-enabled yes cluster-node-timeout 1 cl assert_equal 3 [CI 2 cluster_known_nodes] } - test "redis-cli -4 --cluster add-node using $ip_or_localhost with cluster-port" { + test "valkey-cli -4 --cluster add-node using $ip_or_localhost with cluster-port" { # Adding node to the cluster (without cluster-port) exec src/valkey-cli -4 --cluster-yes --cluster add-node \ $ip_or_localhost:[srv -3 port] \ diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 90d4bb8017..58ac0c8888 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -1106,7 +1106,7 @@ start_server {tags {"scripting"}} { set _ {} } {} {external:skip} - test {FUNCTION - redis version api} { + test {FUNCTION - valkey version api} { r FUNCTION load replace {#!lua name=test local version = redis.REDIS_VERSION_NUM diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 8e077992f3..1e6e38625c 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -706,7 +706,7 @@ start_server {tags {"introspection"}} { assert {[dict exists $res bind]} } - test {redis-server command line arguments - error cases} { + test {valkey-server command line arguments - error cases} { # Take '--invalid' as the option. catch {exec src/valkey-server --invalid} err assert_match {*Bad directive or wrong number of arguments*} $err @@ -749,14 +749,14 @@ start_server {tags {"introspection"}} { assert_match {*'replicaof "--127.0.0.1"'*wrong number of arguments*} $err } {} {external:skip} - test {redis-server command line arguments - allow passing option name and option value in the same arg} { + test {valkey-server command line arguments - allow passing option name and option value in the same arg} { start_server {config "default.conf" args {"--maxmemory 700mb" "--maxmemory-policy volatile-lru"}} { assert_match [r config get maxmemory] {maxmemory 734003200} assert_match [r config get maxmemory-policy] {maxmemory-policy volatile-lru} } } {} {external:skip} - test {redis-server command line arguments - wrong usage that we support anyway} { + test {valkey-server command line arguments - wrong usage that we support anyway} { start_server {config "default.conf" args {loglevel verbose "--maxmemory '700mb'" "--maxmemory-policy 'volatile-lru'"}} { assert_match [r config get loglevel] {loglevel verbose} assert_match [r config get maxmemory] {maxmemory 734003200} @@ -764,21 +764,21 @@ start_server {tags {"introspection"}} { } } {} {external:skip} - test {redis-server command line arguments - allow option value to use the `--` prefix} { + test {valkey-server command line arguments - allow option value to use the `--` prefix} { start_server {config "default.conf" args {--proc-title-template --my--title--template --loglevel verbose}} { assert_match [r config get proc-title-template] {proc-title-template --my--title--template} assert_match [r config get loglevel] {loglevel verbose} } } {} {external:skip} - test {redis-server command line arguments - option name and option value in the same arg and `--` prefix} { + test {valkey-server command line arguments - option name and option value in the same arg and `--` prefix} { start_server {config "default.conf" args {"--proc-title-template --my--title--template" "--loglevel verbose"}} { assert_match [r config get proc-title-template] {proc-title-template --my--title--template} assert_match [r config get loglevel] {loglevel verbose} } } {} {external:skip} - test {redis-server command line arguments - save with empty input} { + test {valkey-server command line arguments - save with empty input} { start_server {config "default.conf" args {--save --loglevel verbose}} { assert_match [r config get save] {save {}} assert_match [r config get loglevel] {loglevel verbose} @@ -807,7 +807,7 @@ start_server {tags {"introspection"}} { } {} {external:skip} - test {redis-server command line arguments - take one bulk string with spaces for MULTI_ARG configs parsing} { + test {valkey-server command line arguments - take one bulk string with spaces for MULTI_ARG configs parsing} { start_server {config "default.conf" args {--shutdown-on-sigint nosave force now --shutdown-on-sigterm "nosave force"}} { assert_match [r config get shutdown-on-sigint] {shutdown-on-sigint {nosave now force}} assert_match [r config get shutdown-on-sigterm] {shutdown-on-sigterm {nosave force}} diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index 4fab1db041..422fc76d6a 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -356,7 +356,7 @@ start_server {tags {"other"}} { } start_server {tags {"other external:skip"}} { - test {Don't rehash if redis has child process} { + test {Don't rehash if server has child process} { r config set save "" r config set rdb-key-save-delay 1000000 diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 2f6d1c237d..f494e05db8 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -67,7 +67,7 @@ start_server {tags {"scripting"}} { run_script {local a = {}; setmetatable(a,{__index=function() foo() end}) return a} 0 } {} - test {EVAL - Return table with a metatable that call redis} { + test {EVAL - Return table with a metatable that call server} { run_script {local a = {}; setmetatable(a,{__index=function() redis.call('set', 'x', '1') end}) return a} 1 x # make sure x was not set r get x @@ -1042,7 +1042,7 @@ start_server {tags {"scripting"}} { set _ $e } {*Attempt to modify a readonly table*} - test "Try trick readonly table on redis table" { + test "Try trick readonly table on valkey table" { catch { run_script { redis.call = function() return 1 end From 47444c67de854a3d547e2d0cb81ce41b29babc5d Mon Sep 17 00:00:00 2001 From: Siddhartha Sankar Mondal Date: Fri, 5 Apr 2024 19:54:28 +0200 Subject: [PATCH 60/98] Update Makefile comments to relect name change (#106) Update the comments in the Makefile to reflect the new names. Signed-off-by: Siddhartha Mondal --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index e54bb6b491..0c70e8a22d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -311,7 +311,7 @@ ifeq ($(BUILD_TLS),yes) endif TLS_MODULE= -TLS_MODULE_NAME:=redis-tls$(PROG_SUFFIX).so +TLS_MODULE_NAME:=valkey-tls$(PROG_SUFFIX).so TLS_MODULE_CFLAGS:=$(FINAL_CFLAGS) ifeq ($(BUILD_TLS),module) FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) From 7f5bcc96f018c67191f68c50bde3797fe0614ac5 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Fri, 5 Apr 2024 16:46:33 -0400 Subject: [PATCH 61/98] Update some valkey-cli related in tcl (#236) Signed-off-by: hwware --- tests/cluster/tests/04-resharding.tcl | 2 +- tests/cluster/tests/12-replica-migration-2.tcl | 4 ++-- .../cluster/tests/12.1-replica-migration-3.tcl | 2 +- tests/cluster/tests/includes/utils.tcl | 6 +++--- tests/integration/valkey-cli.tcl | 8 ++++---- tests/support/cli.tcl | 18 +++++++++--------- tests/unit/networking.tcl | 10 +++++----- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/cluster/tests/04-resharding.tcl b/tests/cluster/tests/04-resharding.tcl index f7cb7e4988..babedd9724 100644 --- a/tests/cluster/tests/04-resharding.tcl +++ b/tests/cluster/tests/04-resharding.tcl @@ -90,7 +90,7 @@ test "Cluster consistency during live resharding" { --cluster-to $target \ --cluster-slots 100 \ --cluster-yes \ - {*}[rediscli_tls_config "../../../tests"] \ + {*}[valkeycli_tls_config "../../../tests"] \ | [info nameofexecutable] \ ../tests/helpers/onlydots.tcl \ &] 0] diff --git a/tests/cluster/tests/12-replica-migration-2.tcl b/tests/cluster/tests/12-replica-migration-2.tcl index 5c3edeb8e5..54681f96c1 100644 --- a/tests/cluster/tests/12-replica-migration-2.tcl +++ b/tests/cluster/tests/12-replica-migration-2.tcl @@ -40,7 +40,7 @@ test "Resharding all the master #0 slots away from it" { set output [exec \ ../../../src/valkey-cli --cluster rebalance \ 127.0.0.1:[get_instance_attrib redis 0 port] \ - {*}[rediscli_tls_config "../../../tests"] \ + {*}[valkeycli_tls_config "../../../tests"] \ --cluster-weight ${master0_id}=0 >@ stdout ] } @@ -61,7 +61,7 @@ test "Resharding back some slot to master #0" { set output [exec \ ../../../src/valkey-cli --cluster rebalance \ 127.0.0.1:[get_instance_attrib redis 0 port] \ - {*}[rediscli_tls_config "../../../tests"] \ + {*}[valkeycli_tls_config "../../../tests"] \ --cluster-weight ${master0_id}=.01 \ --cluster-use-empty-masters >@ stdout] } diff --git a/tests/cluster/tests/12.1-replica-migration-3.tcl b/tests/cluster/tests/12.1-replica-migration-3.tcl index 3515425e14..86f4ac318a 100644 --- a/tests/cluster/tests/12.1-replica-migration-3.tcl +++ b/tests/cluster/tests/12.1-replica-migration-3.tcl @@ -39,7 +39,7 @@ test "Resharding all the master #0 slots away from it" { set output [exec \ ../../../src/valkey-cli --cluster rebalance \ 127.0.0.1:[get_instance_attrib redis 0 port] \ - {*}[rediscli_tls_config "../../../tests"] \ + {*}[valkeycli_tls_config "../../../tests"] \ --cluster-weight ${master0_id}=0 >@ stdout ] } diff --git a/tests/cluster/tests/includes/utils.tcl b/tests/cluster/tests/includes/utils.tcl index f0c6d94b3c..e8925ebfc4 100644 --- a/tests/cluster/tests/includes/utils.tcl +++ b/tests/cluster/tests/includes/utils.tcl @@ -8,7 +8,7 @@ proc config_set_all_nodes {keyword value} { proc fix_cluster {addr} { set code [catch { - exec ../../../src/valkey-cli {*}[rediscli_tls_config "../../../tests"] --cluster fix $addr << yes + exec ../../../src/valkey-cli {*}[valkeycli_tls_config "../../../tests"] --cluster fix $addr << yes } result] if {$code != 0} { puts "redis-cli --cluster fix returns non-zero exit code, output below:\n$result" @@ -17,7 +17,7 @@ proc fix_cluster {addr} { # but we can ignore that and rely on the check below. assert_cluster_state ok wait_for_condition 100 100 { - [catch {exec ../../../src/valkey-cli {*}[rediscli_tls_config "../../../tests"] --cluster check $addr} result] == 0 + [catch {exec ../../../src/valkey-cli {*}[valkeycli_tls_config "../../../tests"] --cluster check $addr} result] == 0 } else { puts "redis-cli --cluster check returns non-zero exit code, output below:\n$result" fail "Cluster could not settle with configuration" @@ -28,7 +28,7 @@ proc wait_cluster_stable {} { wait_for_condition 1000 50 { [catch {exec ../../../src/valkey-cli --cluster \ check 127.0.0.1:[get_instance_attrib redis 0 port] \ - {*}[rediscli_tls_config "../../../tests"] \ + {*}[valkeycli_tls_config "../../../tests"] \ }] == 0 } else { fail "Cluster doesn't stabilize" diff --git a/tests/integration/valkey-cli.tcl b/tests/integration/valkey-cli.tcl index da82dda652..19b6e00bae 100644 --- a/tests/integration/valkey-cli.tcl +++ b/tests/integration/valkey-cli.tcl @@ -12,7 +12,7 @@ start_server {tags {"cli"}} { set opts "-n $::dbnum" } set ::env(TERM) dumb - set cmdline [rediscli [srv host] [srv port] $opts] + set cmdline [valkeycli [srv host] [srv port] $opts] if {$infile ne ""} { set cmdline "$cmdline < $infile" set mode "r" @@ -92,7 +92,7 @@ start_server {tags {"cli"}} { } proc _run_cli {host port db opts args} { - set cmd [rediscli $host $port [list -n $db {*}$args]] + set cmd [valkeycli $host $port [list -n $db {*}$args]] foreach {key value} $opts { if {$key eq "pipe"} { set cmd "sh -c \"$value | $cmd\"" @@ -580,7 +580,7 @@ if {!$::tls} { ;# fake_redis_node doesn't support TLS } test "DUMP RESTORE with -x option" { - set cmdline [rediscli [srv host] [srv port]] + set cmdline [valkeycli [srv host] [srv port]] exec {*}$cmdline DEL set new_set exec {*}$cmdline SADD set 1 2 3 4 5 6 @@ -594,7 +594,7 @@ if {!$::tls} { ;# fake_redis_node doesn't support TLS } test "DUMP RESTORE with -X option" { - set cmdline [rediscli [srv host] [srv port]] + set cmdline [valkeycli [srv host] [srv port]] exec {*}$cmdline DEL zset new_zset exec {*}$cmdline ZADD zset 1 a 2 b 3 c diff --git a/tests/support/cli.tcl b/tests/support/cli.tcl index 4bd693369b..c1c2bdb5a7 100644 --- a/tests/support/cli.tcl +++ b/tests/support/cli.tcl @@ -1,4 +1,4 @@ -proc rediscli_tls_config {testsdir} { +proc valkeycli_tls_config {testsdir} { set tlsdir [file join $testsdir tls] set cert [file join $tlsdir client.crt] set key [file join $tlsdir client.key] @@ -11,23 +11,23 @@ proc rediscli_tls_config {testsdir} { } } -# Returns command line for executing redis-cli -proc rediscli {host port {opts {}}} { +# Returns command line for executing valkey-cli +proc valkeycli {host port {opts {}}} { set cmd [list src/valkey-cli -h $host -p $port] - lappend cmd {*}[rediscli_tls_config "tests"] + lappend cmd {*}[valkeycli_tls_config "tests"] lappend cmd {*}$opts return $cmd } -# Returns command line for executing redis-cli with a unix socket address -proc rediscli_unixsocket {unixsocket {opts {}}} { +# Returns command line for executing valkey-cli with a unix socket address +proc valkeycli_unixsocket {unixsocket {opts {}}} { return [list src/valkey-cli -s $unixsocket {*}$opts] } -# Run redis-cli with specified args on the server of specified level. +# Run valkey-cli with specified args on the server of specified level. # Returns output broken down into individual lines. -proc rediscli_exec {level args} { - set cmd [rediscli_unixsocket [srv $level unixsocket] $args] +proc valkeycli_exec {level args} { + set cmd [valkeycli_unixsocket [srv $level unixsocket] $args] set fd [open "|$cmd" "r"] set ret [lrange [split [read $fd] "\n"] 0 end-1] close $fd diff --git a/tests/unit/networking.tcl b/tests/unit/networking.tcl index 79d6e399d0..5224fa00a6 100644 --- a/tests/unit/networking.tcl +++ b/tests/unit/networking.tcl @@ -121,18 +121,18 @@ start_server {config "minimal.conf" tags {"external:skip"}} { # Make sure bind parameter is as expected and server handles binding # accordingly. - # (it seems that rediscli_exec behaves differently in RESP3, possibly - # because CONFIG GET returns a dict instead of a list so redis-cli emits + # (it seems that valkeycli_exec behaves differently in RESP3, possibly + # because CONFIG GET returns a dict instead of a list so valkey-cli emits # it in a single line) if {$::force_resp3} { - assert_equal {{bind }} [rediscli_exec 0 config get bind] + assert_equal {{bind }} [valkeycli_exec 0 config get bind] } else { - assert_equal {bind {}} [rediscli_exec 0 config get bind] + assert_equal {bind {}} [valkeycli_exec 0 config get bind] } catch {reconnect 0} err assert_match {*connection refused*} $err - assert_equal {OK} [rediscli_exec 0 config set bind *] + assert_equal {OK} [valkeycli_exec 0 config set bind *] reconnect 0 r ping } {PONG} From 906c8e8f90d7e6c8af082a45f18c9e805b3fa333 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Fri, 5 Apr 2024 17:50:42 -0400 Subject: [PATCH 62/98] delete cluster fail time script (#237) --- utils/cluster_fail_time.tcl | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 utils/cluster_fail_time.tcl diff --git a/utils/cluster_fail_time.tcl b/utils/cluster_fail_time.tcl deleted file mode 100644 index 87399495f8..0000000000 --- a/utils/cluster_fail_time.tcl +++ /dev/null @@ -1,50 +0,0 @@ -# This simple script is used in order to estimate the average PFAIL->FAIL -# state switch after a failure. - -set ::sleep_time 10 ; # How much to sleep to trigger PFAIL. -set ::fail_port 30016 ; # Node to put in sleep. -set ::other_port 30001 ; # Node to use to monitor the flag switch. - -proc avg vector { - set sum 0.0 - foreach x $vector { - set sum [expr {$sum+$x}] - } - expr {$sum/[llength $vector]} -} - -set samples {} -while 1 { - exec redis-cli -p $::fail_port debug sleep $::sleep_time > /dev/null & - - # Wait for fail? to appear. - while 1 { - set output [exec redis-cli -p $::other_port cluster nodes] - if {[string match {*fail\?*} $output]} break - after 100 - } - - puts "FAIL?" - set start [clock milliseconds] - - # Wait for fail? to disappear. - while 1 { - set output [exec redis-cli -p $::other_port cluster nodes] - if {![string match {*fail\?*} $output]} break - after 100 - } - - puts "FAIL" - set now [clock milliseconds] - set elapsed [expr {$now-$start}] - puts $elapsed - lappend samples $elapsed - - puts "AVG([llength $samples]): [avg $samples]" - - # Wait for the instance to be available again. - exec redis-cli -p $::fail_port ping - - # Wait for the fail flag to be cleared. - after 2000 -} From aaec321213605e6315d85f2e617b4f33420b8df7 Mon Sep 17 00:00:00 2001 From: Ping Xie Date: Fri, 5 Apr 2024 16:59:55 -0700 Subject: [PATCH 63/98] Remove REDISMODULE_ prefixes and introduce compatibility header (#194) Fix #146 Removed REDISMODULE_ prefixes from the core source code to align with the new SERVERMODULE_ naming convention. Added a new 'redismodule.h' header file to ensure full backward compatibility with existing modules. This compatibility layer maps all legacy REDISMODULE_ prefixed identifiers to their new SERVERMODULE_ equivalents, allowing existing Redis modules to function without modification. --------- Signed-off-by: Ping Xie --- src/aof.c | 2 +- src/call_reply.c | 112 +- src/call_reply.h | 2 +- src/config.c | 6 +- src/db.c | 18 +- src/debug.c | 2 +- src/functions.h | 2 +- src/module.c | 5656 ++++++++++++++++++------------------ src/modules/Makefile | 16 +- src/modules/helloacl.c | 58 +- src/modules/helloblock.c | 42 +- src/modules/hellocluster.c | 38 +- src/modules/hellodict.c | 32 +- src/modules/hellohook.c | 24 +- src/modules/hellotimer.c | 24 +- src/modules/hellotype.c | 94 +- src/modules/helloworld.c | 220 +- src/networking.c | 12 +- src/rdb.c | 44 +- src/redismodule.h | 2408 +++++---------- src/replication.c | 48 +- src/server.c | 24 +- src/server.h | 98 +- src/tls.c | 24 +- src/valkeymodule.h | 1698 +++++++++++ 25 files changed, 5728 insertions(+), 4976 deletions(-) create mode 100644 src/valkeymodule.h diff --git a/src/aof.c b/src/aof.c index c775d5b612..ab24770b9a 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2211,7 +2211,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) { * that is exported by a module and is not handled by Redis itself. * The function returns 0 on error, 1 on success. */ int rewriteModuleObject(rio *r, robj *key, robj *o, int dbid) { - RedisModuleIO io; + ValkeyModuleIO io; moduleValue *mv = o->ptr; moduleType *mt = mv->type; moduleInitIOContext(io,mt,r,key,dbid); diff --git a/src/call_reply.c b/src/call_reply.c index ccd1b36d45..0afaf4469e 100644 --- a/src/call_reply.c +++ b/src/call_reply.c @@ -73,55 +73,55 @@ static void callReplySetSharedData(CallReply *rep, int type, const char *proto, static void callReplyNull(void *ctx, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, REPLY_FLAG_RESP3); } static void callReplyNullBulkString(void *ctx, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, 0); } static void callReplyNullArray(void *ctx, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, 0); } static void callReplyBulkString(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_STRING, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_STRING, proto, proto_len, 0); rep->len = len; rep->val.str = str; } static void callReplyError(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_ERROR, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_ERROR, proto, proto_len, 0); rep->len = len; rep->val.str = str; } static void callReplySimpleStr(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_STRING, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_STRING, proto, proto_len, 0); rep->len = len; rep->val.str = str; } static void callReplyLong(void *ctx, long long val, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_INTEGER, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_INTEGER, proto, proto_len, 0); rep->val.ll = val; } static void callReplyDouble(void *ctx, double val, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_DOUBLE, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_DOUBLE, proto, proto_len, REPLY_FLAG_RESP3); rep->val.d = val; } static void callReplyVerbatimString(void *ctx, const char *format, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3); rep->len = len; rep->val.verbatim_str.str = str; rep->val.verbatim_str.format = format; @@ -129,14 +129,14 @@ static void callReplyVerbatimString(void *ctx, const char *format, const char *s static void callReplyBigNumber(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_BIG_NUMBER, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_BIG_NUMBER, proto, proto_len, REPLY_FLAG_RESP3); rep->len = len; rep->val.str = str; } static void callReplyBool(void *ctx, int val, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3); rep->val.ll = val; } @@ -164,7 +164,7 @@ static void callReplyAttribute(ReplyParser *parser, void *ctx, size_t len, const /* Continue parsing the attribute reply */ rep->attribute->len = len; - rep->attribute->type = REDISMODULE_REPLY_ATTRIBUTE; + rep->attribute->type = VALKEYMODULE_REPLY_ATTRIBUTE; callReplyParseCollection(parser, rep->attribute, len, proto, 2); rep->attribute->flags |= REPLY_FLAG_PARSED | REPLY_FLAG_RESP3; rep->attribute->private_data = rep->private_data; @@ -180,39 +180,39 @@ static void callReplyAttribute(ReplyParser *parser, void *ctx, size_t len, const static void callReplyArray(ReplyParser *parser, void *ctx, size_t len, const char *proto) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_ARRAY; + rep->type = VALKEYMODULE_REPLY_ARRAY; callReplyParseCollection(parser, rep, len, proto, 1); } static void callReplySet(ReplyParser *parser, void *ctx, size_t len, const char *proto) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_SET; + rep->type = VALKEYMODULE_REPLY_SET; callReplyParseCollection(parser, rep, len, proto, 1); rep->flags |= REPLY_FLAG_RESP3; } static void callReplyMap(ReplyParser *parser, void *ctx, size_t len, const char *proto) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_MAP; + rep->type = VALKEYMODULE_REPLY_MAP; callReplyParseCollection(parser, rep, len, proto, 2); rep->flags |= REPLY_FLAG_RESP3; } static void callReplyParseError(void *ctx) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_UNKNOWN; + rep->type = VALKEYMODULE_REPLY_UNKNOWN; } /* Recursively free the current call reply and its sub-replies. */ static void freeCallReplyInternal(CallReply *rep) { - if (rep->type == REDISMODULE_REPLY_ARRAY || rep->type == REDISMODULE_REPLY_SET) { + if (rep->type == VALKEYMODULE_REPLY_ARRAY || rep->type == VALKEYMODULE_REPLY_SET) { for (size_t i = 0 ; i < rep->len ; ++i) { freeCallReplyInternal(rep->val.array + i); } zfree(rep->val.array); } - if (rep->type == REDISMODULE_REPLY_MAP || rep->type == REDISMODULE_REPLY_ATTRIBUTE) { + if (rep->type == VALKEYMODULE_REPLY_MAP || rep->type == VALKEYMODULE_REPLY_ATTRIBUTE) { for (size_t i = 0 ; i < rep->len ; ++i) { freeCallReplyInternal(rep->val.array + i * 2); freeCallReplyInternal(rep->val.array + i * 2 + 1); @@ -234,7 +234,7 @@ void freeCallReply(CallReply *rep) { return; } if (rep->flags & REPLY_FLAG_PARSED) { - if (rep->type == REDISMODULE_REPLY_PROMISE) { + if (rep->type == VALKEYMODULE_REPLY_PROMISE) { zfree(rep); return; } @@ -248,7 +248,7 @@ void freeCallReply(CallReply *rep) { CallReply *callReplyCreatePromise(void *private_data) { CallReply *res = zmalloc(sizeof(*res)); - res->type = REDISMODULE_REPLY_PROMISE; + res->type = VALKEYMODULE_REPLY_PROMISE; /* Mark the reply as parsed so there will be not attempt to parse * it when calling reply API such as freeCallReply. * Also mark the reply as root so freeCallReply will not ignore it. */ @@ -289,16 +289,16 @@ static void callReplyParse(CallReply *rep) { rep->flags |= REPLY_FLAG_PARSED; } -/* Return the call reply type (REDISMODULE_REPLY_...). */ +/* Return the call reply type (VALKEYMODULE_REPLY_...). */ int callReplyType(CallReply *rep) { - if (!rep) return REDISMODULE_REPLY_UNKNOWN; + if (!rep) return VALKEYMODULE_REPLY_UNKNOWN; callReplyParse(rep); return rep->type; } /* Return reply string as buffer and len. Applicable to: - * - REDISMODULE_REPLY_STRING - * - REDISMODULE_REPLY_ERROR + * - VALKEYMODULE_REPLY_STRING + * - VALKEYMODULE_REPLY_ERROR * * The return value is borrowed from CallReply, so it must not be freed * explicitly or used after CallReply itself is freed. @@ -308,56 +308,56 @@ int callReplyType(CallReply *rep) { */ const char *callReplyGetString(CallReply *rep, size_t *len) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_STRING && - rep->type != REDISMODULE_REPLY_ERROR) return NULL; + if (rep->type != VALKEYMODULE_REPLY_STRING && + rep->type != VALKEYMODULE_REPLY_ERROR) return NULL; if (len) *len = rep->len; return rep->val.str; } /* Return a long long reply value. Applicable to: - * - REDISMODULE_REPLY_INTEGER + * - VALKEYMODULE_REPLY_INTEGER */ long long callReplyGetLongLong(CallReply *rep) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_INTEGER) return LLONG_MIN; + if (rep->type != VALKEYMODULE_REPLY_INTEGER) return LLONG_MIN; return rep->val.ll; } /* Return a double reply value. Applicable to: - * - REDISMODULE_REPLY_DOUBLE + * - VALKEYMODULE_REPLY_DOUBLE */ double callReplyGetDouble(CallReply *rep) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_DOUBLE) return LLONG_MIN; + if (rep->type != VALKEYMODULE_REPLY_DOUBLE) return LLONG_MIN; return rep->val.d; } /* Return a reply Boolean value. Applicable to: - * - REDISMODULE_REPLY_BOOL + * - VALKEYMODULE_REPLY_BOOL */ int callReplyGetBool(CallReply *rep) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_BOOL) return INT_MIN; + if (rep->type != VALKEYMODULE_REPLY_BOOL) return INT_MIN; return rep->val.ll; } /* Return reply length. Applicable to: - * - REDISMODULE_REPLY_STRING - * - REDISMODULE_REPLY_ERROR - * - REDISMODULE_REPLY_ARRAY - * - REDISMODULE_REPLY_SET - * - REDISMODULE_REPLY_MAP - * - REDISMODULE_REPLY_ATTRIBUTE + * - VALKEYMODULE_REPLY_STRING + * - VALKEYMODULE_REPLY_ERROR + * - VALKEYMODULE_REPLY_ARRAY + * - VALKEYMODULE_REPLY_SET + * - VALKEYMODULE_REPLY_MAP + * - VALKEYMODULE_REPLY_ATTRIBUTE */ size_t callReplyGetLen(CallReply *rep) { callReplyParse(rep); switch(rep->type) { - case REDISMODULE_REPLY_STRING: - case REDISMODULE_REPLY_ERROR: - case REDISMODULE_REPLY_ARRAY: - case REDISMODULE_REPLY_SET: - case REDISMODULE_REPLY_MAP: - case REDISMODULE_REPLY_ATTRIBUTE: + case VALKEYMODULE_REPLY_STRING: + case VALKEYMODULE_REPLY_ERROR: + case VALKEYMODULE_REPLY_ARRAY: + case VALKEYMODULE_REPLY_SET: + case VALKEYMODULE_REPLY_MAP: + case VALKEYMODULE_REPLY_ATTRIBUTE: return rep->len; default: return 0; @@ -370,26 +370,26 @@ static CallReply *callReplyGetCollectionElement(CallReply *rep, size_t idx, int } /* Return a reply array element at a given index. Applicable to: - * - REDISMODULE_REPLY_ARRAY + * - VALKEYMODULE_REPLY_ARRAY * * The return value is borrowed from CallReply, so it must not be freed * explicitly or used after CallReply itself is freed. */ CallReply *callReplyGetArrayElement(CallReply *rep, size_t idx) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_ARRAY) return NULL; + if (rep->type != VALKEYMODULE_REPLY_ARRAY) return NULL; return callReplyGetCollectionElement(rep, idx, 1); } /* Return a reply set element at a given index. Applicable to: - * - REDISMODULE_REPLY_SET + * - VALKEYMODULE_REPLY_SET * * The return value is borrowed from CallReply, so it must not be freed * explicitly or used after CallReply itself is freed. */ CallReply *callReplyGetSetElement(CallReply *rep, size_t idx) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_SET) return NULL; + if (rep->type != VALKEYMODULE_REPLY_SET) return NULL; return callReplyGetCollectionElement(rep, idx, 1); } @@ -403,7 +403,7 @@ static int callReplyGetMapElementInternal(CallReply *rep, size_t idx, CallReply } /* Retrieve a map reply key and value at a given index. Applicable to: - * - REDISMODULE_REPLY_MAP + * - VALKEYMODULE_REPLY_MAP * * The key and value are returned by reference through key and val, * which may also be NULL if not needed. @@ -415,7 +415,7 @@ static int callReplyGetMapElementInternal(CallReply *rep, size_t idx, CallReply * explicitly or used after CallReply itself is freed. */ int callReplyGetMapElement(CallReply *rep, size_t idx, CallReply **key, CallReply **val) { - return callReplyGetMapElementInternal(rep, idx, key, val, REDISMODULE_REPLY_MAP); + return callReplyGetMapElementInternal(rep, idx, key, val, VALKEYMODULE_REPLY_MAP); } /* Return reply attribute, or NULL if it does not exist. Applicable to all replies. @@ -428,7 +428,7 @@ CallReply *callReplyGetAttribute(CallReply *rep) { } /* Retrieve attribute reply key and value at a given index. Applicable to: - * - REDISMODULE_REPLY_ATTRIBUTE + * - VALKEYMODULE_REPLY_ATTRIBUTE * * The key and value are returned by reference through key and val, * which may also be NULL if not needed. @@ -440,11 +440,11 @@ CallReply *callReplyGetAttribute(CallReply *rep) { * explicitly or used after CallReply itself is freed. */ int callReplyGetAttributeElement(CallReply *rep, size_t idx, CallReply **key, CallReply **val) { - return callReplyGetMapElementInternal(rep, idx, key, val, REDISMODULE_REPLY_MAP); + return callReplyGetMapElementInternal(rep, idx, key, val, VALKEYMODULE_REPLY_MAP); } /* Return a big number reply value. Applicable to: - * - REDISMODULE_REPLY_BIG_NUMBER + * - VALKEYMODULE_REPLY_BIG_NUMBER * * The returned values are borrowed from CallReply, so they must not be freed * explicitly or used after CallReply itself is freed. @@ -457,13 +457,13 @@ int callReplyGetAttributeElement(CallReply *rep, size_t idx, CallReply **key, Ca */ const char *callReplyGetBigNumber(CallReply *rep, size_t *len) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_BIG_NUMBER) return NULL; + if (rep->type != VALKEYMODULE_REPLY_BIG_NUMBER) return NULL; *len = rep->len; return rep->val.str; } /* Return a verbatim string reply value. Applicable to: - * - REDISMODULE_REPLY_VERBATIM_STRING + * - VALKEYMODULE_REPLY_VERBATIM_STRING * * If format is non-NULL, the verbatim reply format is also returned by value. * @@ -478,7 +478,7 @@ const char *callReplyGetBigNumber(CallReply *rep, size_t *len) { */ const char *callReplyGetVerbatim(CallReply *rep, size_t *len, const char **format){ callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_VERBATIM_STRING) return NULL; + if (rep->type != VALKEYMODULE_REPLY_VERBATIM_STRING) return NULL; *len = rep->len; if (format) *format = rep->val.verbatim_str.format; return rep->val.verbatim_str.str; diff --git a/src/call_reply.h b/src/call_reply.h index 657f24735c..3ca1dd7c4f 100644 --- a/src/call_reply.h +++ b/src/call_reply.h @@ -33,7 +33,7 @@ #include "resp_parser.h" typedef struct CallReply CallReply; -typedef void (*RedisModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data); +typedef void (*ValkeyModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data); CallReply *callReplyCreate(sds reply, list *deferred_error_list, void *private_data); CallReply *callReplyCreateError(sds reply, void *private_data); diff --git a/src/config.c b/src/config.c index c009589e15..eee7835924 100644 --- a/src/config.c +++ b/src/config.c @@ -934,8 +934,8 @@ void configSetCommand(client *c) { goto err; } - RedisModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names}; - moduleFireServerEvent(REDISMODULE_EVENT_CONFIG, REDISMODULE_SUBEVENT_CONFIG_CHANGE, &cc); + ValkeyModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names}; + moduleFireServerEvent(VALKEYMODULE_EVENT_CONFIG, VALKEYMODULE_SUBEVENT_CONFIG_CHANGE, &cc); addReply(c,shared.ok); goto end; @@ -1588,7 +1588,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) { dictIterator *di = dictGetIterator(modules); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); line = sdsnew("loadmodule "); line = sdscatsds(line, module->loadmod->path); for (int i = 0; i < module->loadmod->argc; i++) { diff --git a/src/db.c b/src/db.c index f58bde45df..886f27c0b9 100644 --- a/src/db.c +++ b/src/db.c @@ -524,7 +524,7 @@ long long emptyDbStructure(serverDb *dbarray, int dbnum, int async, long long emptyData(int dbnum, int flags, void(callback)(dict*)) { int async = (flags & EMPTYDB_ASYNC); int with_functions = !(flags & EMPTYDB_NOFUNCTIONS); - RedisModuleFlushInfoV1 fi = {REDISMODULE_FLUSHINFO_VERSION,!async,dbnum}; + ValkeyModuleFlushInfoV1 fi = {VALKEYMODULE_FLUSHINFO_VERSION,!async,dbnum}; long long removed = 0; if (dbnum < -1 || dbnum >= server.dbnum) { @@ -533,8 +533,8 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { } /* Fire the flushdb modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_FLUSHDB, - REDISMODULE_SUBEVENT_FLUSHDB_START, + moduleFireServerEvent(VALKEYMODULE_EVENT_FLUSHDB, + VALKEYMODULE_SUBEVENT_FLUSHDB_START, &fi); /* Make sure the WATCHed keys are affected by the FLUSH* commands. @@ -554,8 +554,8 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { /* Also fire the end event. Note that this event will fire almost * immediately after the start event if the flush is asynchronous. */ - moduleFireServerEvent(REDISMODULE_EVENT_FLUSHDB, - REDISMODULE_SUBEVENT_FLUSHDB_END, + moduleFireServerEvent(VALKEYMODULE_EVENT_FLUSHDB, + VALKEYMODULE_SUBEVENT_FLUSHDB_END, &fi); return removed; @@ -865,7 +865,7 @@ int objectTypeCompare(robj *o, long long target) { return 1; } /* module type compare */ - long long mt = (long long)REDISMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id); + long long mt = (long long)VALKEYMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id); if (target != -mt) return 0; else @@ -951,7 +951,7 @@ long long getObjectTypeByName(char *name) { } moduleType *mt = moduleTypeLookupModuleByNameIgnoreCase(name); - if (mt != NULL) return -(REDISMODULE_TYPE_SIGN(mt->id)); + if (mt != NULL) return -(VALKEYMODULE_TYPE_SIGN(mt->id)); return LLONG_MAX; } @@ -1680,8 +1680,8 @@ void swapdbCommand(client *c) { addReplyError(c,"DB index is out of range"); return; } else { - RedisModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2}; - moduleFireServerEvent(REDISMODULE_EVENT_SWAPDB,0,&si); + ValkeyModuleSwapDbInfo si = {VALKEYMODULE_SWAPDBINFO_VERSION,id1,id2}; + moduleFireServerEvent(VALKEYMODULE_EVENT_SWAPDB,0,&si); server.dirty++; addReply(c,shared.ok); } diff --git a/src/debug.c b/src/debug.c index bdae441005..adce284c2b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -258,7 +258,7 @@ void xorObjectDigest(serverDb *db, robj *keyobj, unsigned char *digest, robj *o) } streamIteratorStop(&si); } else if (o->type == OBJ_MODULE) { - RedisModuleDigest md = {{0},{0},keyobj,db->id}; + ValkeyModuleDigest md = {{0},{0},keyobj,db->id}; moduleValue *mv = o->ptr; moduleType *mt = mv->type; moduleInitDigestContext(md); diff --git a/src/functions.h b/src/functions.h index bb0ea4cb24..5228560859 100644 --- a/src/functions.h +++ b/src/functions.h @@ -50,7 +50,7 @@ #include "server.h" #include "script.h" -#include "redismodule.h" +#include "valkeymodule.h" typedef struct functionLibInfo functionLibInfo; diff --git a/src/module.c b/src/module.c index eecb45fb48..3e48b32836 100644 --- a/src/module.c +++ b/src/module.c @@ -33,8 +33,8 @@ * The comments in this file are used to generate the API documentation on the * Redis website. * - * Each function starting with RM_ and preceded by a block comment is included - * in the API documentation. To hide an RM_ function, put a blank line between + * Each function starting with VM_ and preceded by a block comment is included + * in the API documentation. To hide a VM_ function, put a blank line between * the comment and the function definition or put the comment inside the * function body. * @@ -47,7 +47,7 @@ * the generated a API documentation. * * The documentation comments may contain markdown formatting. Some automatic - * replacements are done, such as the replacement of RM with RedisModule in + * replacements are done, such as the replacement of RM with ValkeyModule in * function names. For details, see the script src/modules/gendoc.rb. * -------------------------------------------------------------------------- */ @@ -60,6 +60,7 @@ #include "call_reply.h" #include "hdr_histogram.h" #include "crc16_slottable.h" +#include "valkeymodule.h" #include #include #include @@ -72,8 +73,8 @@ * pointers that have an API the module can call with them) * -------------------------------------------------------------------------- */ -struct RedisModuleInfoCtx { - struct RedisModule *module; +struct ValkeyModuleInfoCtx { + struct ValkeyModule *module; dict *requested_sections; sds info; /* info string we collected so far */ int sections; /* number of sections we collected so far */ @@ -85,13 +86,13 @@ struct RedisModuleInfoCtx { * the server.sharedapi dictionary, mapping names of APIs exported by * modules for other modules to use, to their structure specifying the * function pointer that can be called. */ -struct RedisModuleSharedAPI { +struct ValkeyModuleSharedAPI { void *func; - RedisModule *module; + ValkeyModule *module; }; -typedef struct RedisModuleSharedAPI RedisModuleSharedAPI; +typedef struct ValkeyModuleSharedAPI ValkeyModuleSharedAPI; -dict *modules; /* Hash table of modules. SDS -> RedisModule ptr.*/ +dict *modules; /* Hash table of modules. SDS -> ValkeyModule ptr.*/ /* Entries in the context->amqueue array, representing objects to free * when the callback returns. */ @@ -101,12 +102,12 @@ struct AutoMemEntry { }; /* AutoMemEntry type field values. */ -#define REDISMODULE_AM_KEY 0 -#define REDISMODULE_AM_STRING 1 -#define REDISMODULE_AM_REPLY 2 -#define REDISMODULE_AM_FREED 3 /* Explicitly freed by user already. */ -#define REDISMODULE_AM_DICT 4 -#define REDISMODULE_AM_INFO 5 +#define VALKEYMODULE_AM_KEY 0 +#define VALKEYMODULE_AM_STRING 1 +#define VALKEYMODULE_AM_REPLY 2 +#define VALKEYMODULE_AM_FREED 3 /* Explicitly freed by user already. */ +#define VALKEYMODULE_AM_DICT 4 +#define VALKEYMODULE_AM_INFO 5 /* The pool allocator block. Redis Modules can allocate memory via this special * allocator that will automatically release it all once the callback returns. @@ -121,15 +122,15 @@ struct AutoMemEntry { * Allocations are always rounded to the size of the void pointer in order * to always return aligned memory chunks. */ -#define REDISMODULE_POOL_ALLOC_MIN_SIZE (1024*8) -#define REDISMODULE_POOL_ALLOC_ALIGN (sizeof(void*)) +#define VALKEYMODULE_POOL_ALLOC_MIN_SIZE (1024*8) +#define VALKEYMODULE_POOL_ALLOC_ALIGN (sizeof(void*)) -typedef struct RedisModulePoolAllocBlock { +typedef struct ValkeyModulePoolAllocBlock { uint32_t size; uint32_t used; - struct RedisModulePoolAllocBlock *next; + struct ValkeyModulePoolAllocBlock *next; char memory[]; -} RedisModulePoolAllocBlock; +} ValkeyModulePoolAllocBlock; /* This structure represents the context in which Redis modules operate. * Most APIs module can access, get a pointer to the context, so that the API @@ -139,56 +140,56 @@ typedef struct RedisModulePoolAllocBlock { * Note that not all the context structure is always filled with actual values * but only the fields needed in a given context. */ -struct RedisModuleBlockedClient; -struct RedisModuleUser; +struct ValkeyModuleBlockedClient; +struct ValkeyModuleUser; -struct RedisModuleCtx { +struct ValkeyModuleCtx { void *getapifuncptr; /* NOTE: Must be the first field. */ - struct RedisModule *module; /* Module reference. */ + struct ValkeyModule *module; /* Module reference. */ client *client; /* Client calling a command. */ - struct RedisModuleBlockedClient *blocked_client; /* Blocked client for + struct ValkeyModuleBlockedClient *blocked_client; /* Blocked client for thread safe context. */ struct AutoMemEntry *amqueue; /* Auto memory queue of objects to free. */ int amqueue_len; /* Number of slots in amqueue. */ int amqueue_used; /* Number of used slots in amqueue. */ - int flags; /* REDISMODULE_CTX_... flags. */ - void **postponed_arrays; /* To set with RM_ReplySetArrayLength(). */ + int flags; /* VALKEYMODULE_CTX_... flags. */ + void **postponed_arrays; /* To set with VM_ReplySetArrayLength(). */ int postponed_arrays_count; /* Number of entries in postponed_arrays. */ void *blocked_privdata; /* Privdata set when unblocking a client. */ - RedisModuleString *blocked_ready_key; /* Key ready when the reply callback + ValkeyModuleString *blocked_ready_key; /* Key ready when the reply callback gets called for clients blocked on keys. */ - /* Used if there is the REDISMODULE_CTX_KEYS_POS_REQUEST or - * REDISMODULE_CTX_CHANNEL_POS_REQUEST flag set. */ + /* Used if there is the VALKEYMODULE_CTX_KEYS_POS_REQUEST or + * VALKEYMODULE_CTX_CHANNEL_POS_REQUEST flag set. */ getKeysResult *keys_result; - struct RedisModulePoolAllocBlock *pa_head; + struct ValkeyModulePoolAllocBlock *pa_head; long long next_yield_time; - const struct RedisModuleUser *user; /* RedisModuleUser commands executed via - RM_Call should be executed as, if set */ + const struct ValkeyModuleUser *user; /* ValkeyModuleUser commands executed via + VM_Call should be executed as, if set */ }; -typedef struct RedisModuleCtx RedisModuleCtx; - -#define REDISMODULE_CTX_NONE (0) -#define REDISMODULE_CTX_AUTO_MEMORY (1<<0) -#define REDISMODULE_CTX_KEYS_POS_REQUEST (1<<1) -#define REDISMODULE_CTX_BLOCKED_REPLY (1<<2) -#define REDISMODULE_CTX_BLOCKED_TIMEOUT (1<<3) -#define REDISMODULE_CTX_THREAD_SAFE (1<<4) -#define REDISMODULE_CTX_BLOCKED_DISCONNECTED (1<<5) -#define REDISMODULE_CTX_TEMP_CLIENT (1<<6) /* Return client object to the pool +typedef struct ValkeyModuleCtx ValkeyModuleCtx; + +#define VALKEYMODULE_CTX_NONE (0) +#define VALKEYMODULE_CTX_AUTO_MEMORY (1<<0) +#define VALKEYMODULE_CTX_KEYS_POS_REQUEST (1<<1) +#define VALKEYMODULE_CTX_BLOCKED_REPLY (1<<2) +#define VALKEYMODULE_CTX_BLOCKED_TIMEOUT (1<<3) +#define VALKEYMODULE_CTX_THREAD_SAFE (1<<4) +#define VALKEYMODULE_CTX_BLOCKED_DISCONNECTED (1<<5) +#define VALKEYMODULE_CTX_TEMP_CLIENT (1<<6) /* Return client object to the pool when the context is destroyed */ -#define REDISMODULE_CTX_NEW_CLIENT (1<<7) /* Free client object when the +#define VALKEYMODULE_CTX_NEW_CLIENT (1<<7) /* Free client object when the context is destroyed */ -#define REDISMODULE_CTX_CHANNELS_POS_REQUEST (1<<8) -#define REDISMODULE_CTX_COMMAND (1<<9) /* Context created to serve a command from call() or AOF (which calls cmd->proc directly) */ +#define VALKEYMODULE_CTX_CHANNELS_POS_REQUEST (1<<8) +#define VALKEYMODULE_CTX_COMMAND (1<<9) /* Context created to serve a command from call() or AOF (which calls cmd->proc directly) */ -/* This represents a Redis key opened with RM_OpenKey(). */ -struct RedisModuleKey { - RedisModuleCtx *ctx; +/* This represents a Redis key opened with VM_OpenKey(). */ +struct ValkeyModuleKey { + ValkeyModuleCtx *ctx; serverDb *db; robj *key; /* Key name object. */ robj *value; /* Value object, or NULL if the key was not found. */ @@ -203,7 +204,7 @@ struct RedisModuleKey { } list; struct { /* Zset iterator, use only if value->type == OBJ_ZSET */ - uint32_t type; /* REDISMODULE_ZSET_RANGE_* */ + uint32_t type; /* VALKEYMODULE_ZSET_RANGE_* */ zrangespec rs; /* Score range. */ zlexrangespec lrs; /* Lex range. */ uint32_t start; /* Start pos for positional ranges. */ @@ -221,69 +222,69 @@ struct RedisModuleKey { } u; }; -/* RedisModuleKey 'ztype' values. */ -#define REDISMODULE_ZSET_RANGE_NONE 0 /* This must always be 0. */ -#define REDISMODULE_ZSET_RANGE_LEX 1 -#define REDISMODULE_ZSET_RANGE_SCORE 2 -#define REDISMODULE_ZSET_RANGE_POS 3 +/* ValkeyModuleKey 'ztype' values. */ +#define VALKEYMODULE_ZSET_RANGE_NONE 0 /* This must always be 0. */ +#define VALKEYMODULE_ZSET_RANGE_LEX 1 +#define VALKEYMODULE_ZSET_RANGE_SCORE 2 +#define VALKEYMODULE_ZSET_RANGE_POS 3 /* Function pointer type of a function representing a command inside * a Redis module. */ -struct RedisModuleBlockedClient; -typedef int (*RedisModuleCmdFunc) (RedisModuleCtx *ctx, void **argv, int argc); -typedef int (*RedisModuleAuthCallback)(RedisModuleCtx *ctx, void *username, void *password, RedisModuleString **err); -typedef void (*RedisModuleDisconnectFunc) (RedisModuleCtx *ctx, struct RedisModuleBlockedClient *bc); +struct ValkeyModuleBlockedClient; +typedef int (*ValkeyModuleCmdFunc) (ValkeyModuleCtx *ctx, void **argv, int argc); +typedef int (*ValkeyModuleAuthCallback)(ValkeyModuleCtx *ctx, void *username, void *password, ValkeyModuleString **err); +typedef void (*ValkeyModuleDisconnectFunc) (ValkeyModuleCtx *ctx, struct ValkeyModuleBlockedClient *bc); /* This struct holds the information about a command registered by a module.*/ -struct RedisModuleCommand { - struct RedisModule *module; - RedisModuleCmdFunc func; +struct ValkeyModuleCommand { + struct ValkeyModule *module; + ValkeyModuleCmdFunc func; struct serverCommand *rediscmd; }; -typedef struct RedisModuleCommand RedisModuleCommand; +typedef struct ValkeyModuleCommand ValkeyModuleCommand; -#define REDISMODULE_REPLYFLAG_NONE 0 -#define REDISMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */ -#define REDISMODULE_REPLYFLAG_NESTED (1<<1) /* Nested reply object. No proto +#define VALKEYMODULE_REPLYFLAG_NONE 0 +#define VALKEYMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */ +#define VALKEYMODULE_REPLYFLAG_NESTED (1<<1) /* Nested reply object. No proto or struct free. */ -/* Reply of RM_Call() function. The function is filled in a lazy +/* Reply of VM_Call() function. The function is filled in a lazy * way depending on the function called on the reply structure. By default * only the type, proto and protolen are filled. */ -typedef struct CallReply RedisModuleCallReply; +typedef struct CallReply ValkeyModuleCallReply; /* Structure to hold the module auth callback & the Module implementing it. */ -typedef struct RedisModuleAuthCtx { - struct RedisModule *module; - RedisModuleAuthCallback auth_cb; -} RedisModuleAuthCtx; +typedef struct ValkeyModuleAuthCtx { + struct ValkeyModule *module; + ValkeyModuleAuthCallback auth_cb; +} ValkeyModuleAuthCtx; /* Structure representing a blocked client. We get a pointer to such * an object when blocking from modules. */ -typedef struct RedisModuleBlockedClient { +typedef struct ValkeyModuleBlockedClient { client *client; /* Pointer to the blocked client. or NULL if the client was destroyed during the life of this object. */ - RedisModule *module; /* Module blocking the client. */ - RedisModuleCmdFunc reply_callback; /* Reply callback on normal completion.*/ - RedisModuleAuthCallback auth_reply_cb; /* Reply callback on completing blocking + ValkeyModule *module; /* Module blocking the client. */ + ValkeyModuleCmdFunc reply_callback; /* Reply callback on normal completion.*/ + ValkeyModuleAuthCallback auth_reply_cb; /* Reply callback on completing blocking module authentication. */ - RedisModuleCmdFunc timeout_callback; /* Reply callback on timeout. */ - RedisModuleDisconnectFunc disconnect_callback; /* Called on disconnection.*/ - void (*free_privdata)(RedisModuleCtx*,void*);/* privdata cleanup callback.*/ + ValkeyModuleCmdFunc timeout_callback; /* Reply callback on timeout. */ + ValkeyModuleDisconnectFunc disconnect_callback; /* Called on disconnection.*/ + void (*free_privdata)(ValkeyModuleCtx*,void*);/* privdata cleanup callback.*/ void *privdata; /* Module private data that may be used by the reply or timeout callback. It is set via the - RedisModule_UnblockClient() API. */ + ValkeyModule_UnblockClient() API. */ client *thread_safe_ctx_client; /* Fake client to be used for thread safe context so that no lock is required. */ client *reply_client; /* Fake client used to accumulate replies in thread safe contexts. */ int dbid; /* Database number selected by the original client. */ - int blocked_on_keys; /* If blocked via RM_BlockClientOnKeys(). */ + int blocked_on_keys; /* If blocked via VM_BlockClientOnKeys(). */ int unblocked; /* Already on the moduleUnblocked list. */ monotime background_timer; /* Timer tracking the start of background work */ uint64_t background_duration; /* Current command background time duration. Used for measuring latency of blocking cmds */ -} RedisModuleBlockedClient; +} ValkeyModuleBlockedClient; /* This is a list of Module Auth Contexts. Each time a Module registers a callback, a new ctx is * added to this list. Multiple modules can register auth callbacks and the same Module can have @@ -308,33 +309,33 @@ static size_t moduleTempClientMinCount = 0; /* Min client count in pool since static pthread_mutex_t moduleGIL = PTHREAD_MUTEX_INITIALIZER; /* Function pointer type for keyspace event notification subscriptions from modules. */ -typedef int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key); +typedef int (*ValkeyModuleNotificationFunc) (ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key); /* Function pointer type for post jobs */ -typedef void (*RedisModulePostNotificationJobFunc) (RedisModuleCtx *ctx, void *pd); +typedef void (*ValkeyModulePostNotificationJobFunc) (ValkeyModuleCtx *ctx, void *pd); /* Keyspace notification subscriber information. - * See RM_SubscribeToKeyspaceEvents() for more information. */ -typedef struct RedisModuleKeyspaceSubscriber { + * See VM_SubscribeToKeyspaceEvents() for more information. */ +typedef struct ValkeyModuleKeyspaceSubscriber { /* The module subscribed to the event */ - RedisModule *module; + ValkeyModule *module; /* Notification callback in the module*/ - RedisModuleNotificationFunc notify_callback; + ValkeyModuleNotificationFunc notify_callback; /* A bit mask of the events the module is interested in */ int event_mask; /* Active flag set on entry, to avoid reentrant subscribers * calling themselves */ int active; -} RedisModuleKeyspaceSubscriber; +} ValkeyModuleKeyspaceSubscriber; -typedef struct RedisModulePostExecUnitJob { +typedef struct ValkeyModulePostExecUnitJob { /* The module subscribed to the event */ - RedisModule *module; - RedisModulePostNotificationJobFunc callback; + ValkeyModule *module; + ValkeyModulePostNotificationJobFunc callback; void *pd; void (*free_pd)(void*); int dbid; -} RedisModulePostExecUnitJob; +} ValkeyModulePostExecUnitJob; /* The module keyspace notification subscribers list */ static list *moduleKeyspaceSubscribers; @@ -343,168 +344,168 @@ static list *moduleKeyspaceSubscribers; static list *modulePostExecUnitJobs; /* Data structures related to the exported dictionary data structure. */ -typedef struct RedisModuleDict { +typedef struct ValkeyModuleDict { rax *rax; /* The radix tree. */ -} RedisModuleDict; +} ValkeyModuleDict; -typedef struct RedisModuleDictIter { - RedisModuleDict *dict; +typedef struct ValkeyModuleDictIter { + ValkeyModuleDict *dict; raxIterator ri; -} RedisModuleDictIter; +} ValkeyModuleDictIter; -typedef struct RedisModuleCommandFilterCtx { - RedisModuleString **argv; +typedef struct ValkeyModuleCommandFilterCtx { + ValkeyModuleString **argv; int argv_len; int argc; client *c; -} RedisModuleCommandFilterCtx; +} ValkeyModuleCommandFilterCtx; -typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter); +typedef void (*ValkeyModuleCommandFilterFunc) (ValkeyModuleCommandFilterCtx *filter); -typedef struct RedisModuleCommandFilter { +typedef struct ValkeyModuleCommandFilter { /* The module that registered the filter */ - RedisModule *module; + ValkeyModule *module; /* Filter callback function */ - RedisModuleCommandFilterFunc callback; - /* REDISMODULE_CMDFILTER_* flags */ + ValkeyModuleCommandFilterFunc callback; + /* VALKEYMODULE_CMDFILTER_* flags */ int flags; -} RedisModuleCommandFilter; +} ValkeyModuleCommandFilter; /* Registered filters */ static list *moduleCommandFilters; -typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); +typedef void (*ValkeyModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); -static struct RedisModuleForkInfo { - RedisModuleForkDoneHandler done_handler; +static struct ValkeyModuleForkInfo { + ValkeyModuleForkDoneHandler done_handler; void* done_handler_user_data; } moduleForkInfo = {0}; -typedef struct RedisModuleServerInfoData { +typedef struct ValkeyModuleServerInfoData { rax *rax; /* parsed info data. */ -} RedisModuleServerInfoData; +} ValkeyModuleServerInfoData; /* Flags for moduleCreateArgvFromUserFormat(). */ -#define REDISMODULE_ARGV_REPLICATE (1<<0) -#define REDISMODULE_ARGV_NO_AOF (1<<1) -#define REDISMODULE_ARGV_NO_REPLICAS (1<<2) -#define REDISMODULE_ARGV_RESP_3 (1<<3) -#define REDISMODULE_ARGV_RESP_AUTO (1<<4) -#define REDISMODULE_ARGV_RUN_AS_USER (1<<5) -#define REDISMODULE_ARGV_SCRIPT_MODE (1<<6) -#define REDISMODULE_ARGV_NO_WRITES (1<<7) -#define REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS (1<<8) -#define REDISMODULE_ARGV_RESPECT_DENY_OOM (1<<9) -#define REDISMODULE_ARGV_DRY_RUN (1<<10) -#define REDISMODULE_ARGV_ALLOW_BLOCK (1<<11) +#define VALKEYMODULE_ARGV_REPLICATE (1<<0) +#define VALKEYMODULE_ARGV_NO_AOF (1<<1) +#define VALKEYMODULE_ARGV_NO_REPLICAS (1<<2) +#define VALKEYMODULE_ARGV_RESP_3 (1<<3) +#define VALKEYMODULE_ARGV_RESP_AUTO (1<<4) +#define VALKEYMODULE_ARGV_RUN_AS_USER (1<<5) +#define VALKEYMODULE_ARGV_SCRIPT_MODE (1<<6) +#define VALKEYMODULE_ARGV_NO_WRITES (1<<7) +#define VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS (1<<8) +#define VALKEYMODULE_ARGV_RESPECT_DENY_OOM (1<<9) +#define VALKEYMODULE_ARGV_DRY_RUN (1<<10) +#define VALKEYMODULE_ARGV_ALLOW_BLOCK (1<<11) /* Determine whether Redis should signalModifiedKey implicitly. * In case 'ctx' has no 'module' member (and therefore no module->options), * we assume default behavior, that is, Redis signals. - * (see RM_GetThreadSafeContext) */ + * (see VM_GetThreadSafeContext) */ #define SHOULD_SIGNAL_MODIFIED_KEYS(ctx) \ - ((ctx)->module? !((ctx)->module->options & REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) : 1) + ((ctx)->module? !((ctx)->module->options & VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) : 1) /* Server events hooks data structures and defines: this modules API * allow modules to subscribe to certain events in Redis, such as * the start and end of an RDB or AOF save, the change of role in replication, * and similar other events. */ -typedef struct RedisModuleEventListener { - RedisModule *module; - RedisModuleEvent event; - RedisModuleEventCallback callback; -} RedisModuleEventListener; +typedef struct ValkeyModuleEventListener { + ValkeyModule *module; + ValkeyModuleEvent event; + ValkeyModuleEventCallback callback; +} ValkeyModuleEventListener; -list *RedisModule_EventListeners; /* Global list of all the active events. */ +list *ValkeyModule_EventListeners; /* Global list of all the active events. */ /* Data structures related to the redis module users */ -/* This is the object returned by RM_CreateModuleUser(). The module API is +/* This is the object returned by VM_CreateModuleUser(). The module API is * able to create users, set ACLs to such users, and later authenticate * clients using such newly created users. */ -typedef struct RedisModuleUser { +typedef struct ValkeyModuleUser { user *user; /* Reference to the real redis user */ int free_user; /* Indicates that user should also be freed when this object is freed */ -} RedisModuleUser; +} ValkeyModuleUser; /* This is a structure used to export some meta-information such as dbid to the module. */ -typedef struct RedisModuleKeyOptCtx { +typedef struct ValkeyModuleKeyOptCtx { struct serverObject *from_key, *to_key; /* Optional name of key processed, NULL when unknown. In most cases, only 'from_key' is valid, but in callbacks such as `copy2`, both 'from_key' and 'to_key' are valid. */ int from_dbid, to_dbid; /* The dbid of the key being processed, -1 when unknown. In most cases, only 'from_dbid' is valid, but in callbacks such as `copy2`, 'from_dbid' and 'to_dbid' are both valid. */ -} RedisModuleKeyOptCtx; +} ValkeyModuleKeyOptCtx; /* Data structures related to redis module configurations */ -/* The function signatures for module config get callbacks. These are identical to the ones exposed in redismodule.h. */ -typedef RedisModuleString * (*RedisModuleConfigGetStringFunc)(const char *name, void *privdata); -typedef long long (*RedisModuleConfigGetNumericFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetBoolFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetEnumFunc)(const char *name, void *privdata); -/* The function signatures for module config set callbacks. These are identical to the ones exposed in redismodule.h. */ -typedef int (*RedisModuleConfigSetStringFunc)(const char *name, RedisModuleString *val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -/* Apply signature, identical to redismodule.h */ -typedef int (*RedisModuleConfigApplyFunc)(RedisModuleCtx *ctx, void *privdata, RedisModuleString **err); +/* The function signatures for module config get callbacks. These are identical to the ones exposed in valkeymodule.h. */ +typedef ValkeyModuleString * (*ValkeyModuleConfigGetStringFunc)(const char *name, void *privdata); +typedef long long (*ValkeyModuleConfigGetNumericFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetBoolFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetEnumFunc)(const char *name, void *privdata); +/* The function signatures for module config set callbacks. These are identical to the ones exposed in valkeymodule.h. */ +typedef int (*ValkeyModuleConfigSetStringFunc)(const char *name, ValkeyModuleString *val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +/* Apply signature, identical to valkeymodule.h */ +typedef int (*ValkeyModuleConfigApplyFunc)(ValkeyModuleCtx *ctx, void *privdata, ValkeyModuleString **err); /* Struct representing a module config. These are stored in a list in the module struct */ struct ModuleConfig { sds name; /* Name of config without the module name appended to the front */ void *privdata; /* Optional data passed into the module config callbacks */ union get_fn { /* The get callback specified by the module */ - RedisModuleConfigGetStringFunc get_string; - RedisModuleConfigGetNumericFunc get_numeric; - RedisModuleConfigGetBoolFunc get_bool; - RedisModuleConfigGetEnumFunc get_enum; + ValkeyModuleConfigGetStringFunc get_string; + ValkeyModuleConfigGetNumericFunc get_numeric; + ValkeyModuleConfigGetBoolFunc get_bool; + ValkeyModuleConfigGetEnumFunc get_enum; } get_fn; union set_fn { /* The set callback specified by the module */ - RedisModuleConfigSetStringFunc set_string; - RedisModuleConfigSetNumericFunc set_numeric; - RedisModuleConfigSetBoolFunc set_bool; - RedisModuleConfigSetEnumFunc set_enum; + ValkeyModuleConfigSetStringFunc set_string; + ValkeyModuleConfigSetNumericFunc set_numeric; + ValkeyModuleConfigSetBoolFunc set_bool; + ValkeyModuleConfigSetEnumFunc set_enum; } set_fn; - RedisModuleConfigApplyFunc apply_fn; - RedisModule *module; + ValkeyModuleConfigApplyFunc apply_fn; + ValkeyModule *module; }; -typedef struct RedisModuleAsyncRMCallPromise{ +typedef struct ValkeyModuleAsyncRMCallPromise{ size_t ref_count; void *private_data; - RedisModule *module; - RedisModuleOnUnblocked on_unblocked; + ValkeyModule *module; + ValkeyModuleOnUnblocked on_unblocked; client *c; - RedisModuleCtx *ctx; -} RedisModuleAsyncRMCallPromise; + ValkeyModuleCtx *ctx; +} ValkeyModuleAsyncRMCallPromise; /* -------------------------------------------------------------------------- * Prototypes * -------------------------------------------------------------------------- */ -void RM_FreeCallReply(RedisModuleCallReply *reply); -void RM_CloseKey(RedisModuleKey *key); -void autoMemoryCollect(RedisModuleCtx *ctx); +void VM_FreeCallReply(ValkeyModuleCallReply *reply); +void VM_CloseKey(ValkeyModuleKey *key); +void autoMemoryCollect(ValkeyModuleCtx *ctx); robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int *argcp, int *flags, va_list ap); -void RM_ZsetRangeStop(RedisModuleKey *kp); -static void zsetKeyReset(RedisModuleKey *key); -static void moduleInitKeyTypeSpecific(RedisModuleKey *key); -void RM_FreeDict(RedisModuleCtx *ctx, RedisModuleDict *d); -void RM_FreeServerInfo(RedisModuleCtx *ctx, RedisModuleServerInfoData *data); - -/* Helpers for RM_SetCommandInfo. */ -static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info); +void VM_ZsetRangeStop(ValkeyModuleKey *kp); +static void zsetKeyReset(ValkeyModuleKey *key); +static void moduleInitKeyTypeSpecific(ValkeyModuleKey *key); +void VM_FreeDict(ValkeyModuleCtx *ctx, ValkeyModuleDict *d); +void VM_FreeServerInfo(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data); + +/* Helpers for VM_SetCommandInfo. */ +static int moduleValidateCommandInfo(const ValkeyModuleCommandInfo *info); static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api); -static int moduleValidateCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version); -static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version); -static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); +static int moduleValidateCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version); +static struct serverCommandArg *moduleCopyCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version); +static serverCommandArgType moduleConvertArgType(ValkeyModuleCommandArgType type, int *error); static int moduleConvertArgFlags(int flags); -void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags); +void moduleCreateContext(ValkeyModuleCtx *out_ctx, ValkeyModule *module, int ctx_flags); /* Common helper functions. */ int moduleVerifyResourceName(const char *name); @@ -521,10 +522,10 @@ int moduleVerifyResourceName(const char *name); * and in general is taken into account as memory allocated by Redis. * You should avoid using malloc(). * This function panics if unable to allocate enough memory. */ -void *RM_Alloc(size_t bytes) { +void *VM_Alloc(size_t bytes) { /* Use 'zmalloc_usable()' instead of 'zmalloc()' to allow the compiler * to recognize the additional memory size, which means that modules can - * use the memory reported by 'RM_MallocUsableSize()' safely. In theory this + * use the memory reported by 'VM_MallocUsableSize()' safely. In theory this * isn't really needed since this API can't be inlined (not even for embedded * modules like TLS (we use function pointers for module APIs), and the API doesn't * have the malloc_size attribute, but it's hard to predict how smart future compilers @@ -532,9 +533,9 @@ void *RM_Alloc(size_t bytes) { return zmalloc_usable(bytes,NULL); } -/* Similar to RM_Alloc, but returns NULL in case of allocation failure, instead +/* Similar to VM_Alloc, but returns NULL in case of allocation failure, instead * of panicking. */ -void *RM_TryAlloc(size_t bytes) { +void *VM_TryAlloc(size_t bytes) { return ztrymalloc_usable(bytes,NULL); } @@ -542,36 +543,36 @@ void *RM_TryAlloc(size_t bytes) { * Redis INFO memory, used for keys eviction according to maxmemory settings * and in general is taken into account as memory allocated by Redis. * You should avoid using calloc() directly. */ -void *RM_Calloc(size_t nmemb, size_t size) { +void *VM_Calloc(size_t nmemb, size_t size) { return zcalloc_usable(nmemb*size,NULL); } -/* Similar to RM_Calloc, but returns NULL in case of allocation failure, instead +/* Similar to VM_Calloc, but returns NULL in case of allocation failure, instead * of panicking. */ -void *RM_TryCalloc(size_t nmemb, size_t size) { +void *VM_TryCalloc(size_t nmemb, size_t size) { return ztrycalloc_usable(nmemb*size,NULL); } -/* Use like realloc() for memory obtained with RedisModule_Alloc(). */ -void* RM_Realloc(void *ptr, size_t bytes) { +/* Use like realloc() for memory obtained with ValkeyModule_Alloc(). */ +void* VM_Realloc(void *ptr, size_t bytes) { return zrealloc_usable(ptr,bytes,NULL); } -/* Similar to RM_Realloc, but returns NULL in case of allocation failure, +/* Similar to VM_Realloc, but returns NULL in case of allocation failure, * instead of panicking. */ -void *RM_TryRealloc(void *ptr, size_t bytes) { +void *VM_TryRealloc(void *ptr, size_t bytes) { return ztryrealloc_usable(ptr,bytes,NULL); } -/* Use like free() for memory obtained by RedisModule_Alloc() and - * RedisModule_Realloc(). However you should never try to free with - * RedisModule_Free() memory allocated with malloc() inside your module. */ -void RM_Free(void *ptr) { +/* Use like free() for memory obtained by ValkeyModule_Alloc() and + * ValkeyModule_Realloc(). However you should never try to free with + * ValkeyModule_Free() memory allocated with malloc() inside your module. */ +void VM_Free(void *ptr) { zfree(ptr); } -/* Like strdup() but returns memory allocated with RedisModule_Alloc(). */ -char *RM_Strdup(const char *str) { +/* Like strdup() but returns memory allocated with ValkeyModule_Alloc(). */ +char *VM_Strdup(const char *str) { return zstrdup(str); } @@ -580,8 +581,8 @@ char *RM_Strdup(const char *str) { * -------------------------------------------------------------------------- */ /* Release the chain of blocks used for pool allocations. */ -void poolAllocRelease(RedisModuleCtx *ctx) { - RedisModulePoolAllocBlock *head = ctx->pa_head, *next; +void poolAllocRelease(ValkeyModuleCtx *ctx) { + ValkeyModulePoolAllocBlock *head = ctx->pa_head, *next; while(head != NULL) { next = head->next; @@ -603,14 +604,14 @@ void poolAllocRelease(RedisModuleCtx *ctx) { * pool allocator is not a good idea. * * The function returns NULL if `bytes` is 0. */ -void *RM_PoolAlloc(RedisModuleCtx *ctx, size_t bytes) { +void *VM_PoolAlloc(ValkeyModuleCtx *ctx, size_t bytes) { if (bytes == 0) return NULL; - RedisModulePoolAllocBlock *b = ctx->pa_head; + ValkeyModulePoolAllocBlock *b = ctx->pa_head; size_t left = b ? b->size - b->used : 0; /* Fix alignment. */ if (left >= bytes) { - size_t alignment = REDISMODULE_POOL_ALLOC_ALIGN; + size_t alignment = VALKEYMODULE_POOL_ALLOC_ALIGN; while (bytes < alignment && alignment/2 >= bytes) alignment /= 2; if (b->used % alignment) b->used += alignment - (b->used % alignment); @@ -619,7 +620,7 @@ void *RM_PoolAlloc(RedisModuleCtx *ctx, size_t bytes) { /* Create a new block if needed. */ if (left < bytes) { - size_t blocksize = REDISMODULE_POOL_ALLOC_MIN_SIZE; + size_t blocksize = VALKEYMODULE_POOL_ALLOC_MIN_SIZE; if (blocksize < bytes) blocksize = bytes; b = zmalloc(sizeof(*b) + blocksize); b->size = blocksize; @@ -652,12 +653,12 @@ client *moduleAllocTempClient(void) { return c; } -static void freeRedisModuleAsyncRMCallPromise(RedisModuleAsyncRMCallPromise *promise) { +static void freeRedisModuleAsyncRMCallPromise(ValkeyModuleAsyncRMCallPromise *promise) { if (--promise->ref_count > 0) { return; } /* When the promise is finally freed it can not have a client attached to it. - * Either releasing the client or RM_CallReplyPromiseAbort would have removed it. */ + * Either releasing the client or VM_CallReplyPromiseAbort would have removed it. */ serverAssert(!promise->c); zfree(promise); } @@ -677,7 +678,7 @@ void moduleReleaseTempClient(client *c) { c->user = NULL; /* Root user */ c->cmd = c->lastcmd = c->realcmd = NULL; if (c->bstate.async_rm_call_handle) { - RedisModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; + ValkeyModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; promise->c = NULL; /* Remove the client from the promise so it will no longer be possible to abort it. */ freeRedisModuleAsyncRMCallPromise(promise); c->bstate.async_rm_call_handle = NULL; @@ -689,44 +690,44 @@ void moduleReleaseTempClient(client *c) { * opened for writing where the `.value` member is set to NULL because the * key was found to be non existing. * - * On success REDISMODULE_OK is returned and the key is populated with + * On success VALKEYMODULE_OK is returned and the key is populated with * the value of the specified type. The function fails and returns - * REDISMODULE_ERR if: + * VALKEYMODULE_ERR if: * * 1. The key is not open for writing. * 2. The key is not empty. * 3. The specified type is unknown. */ -int moduleCreateEmptyKey(RedisModuleKey *key, int type) { +int moduleCreateEmptyKey(ValkeyModuleKey *key, int type) { robj *obj; /* The key must be open for writing and non existing to proceed. */ - if (!(key->mode & REDISMODULE_WRITE) || key->value) - return REDISMODULE_ERR; + if (!(key->mode & VALKEYMODULE_WRITE) || key->value) + return VALKEYMODULE_ERR; switch(type) { - case REDISMODULE_KEYTYPE_LIST: + case VALKEYMODULE_KEYTYPE_LIST: obj = createListListpackObject(); break; - case REDISMODULE_KEYTYPE_ZSET: + case VALKEYMODULE_KEYTYPE_ZSET: obj = createZsetListpackObject(); break; - case REDISMODULE_KEYTYPE_HASH: + case VALKEYMODULE_KEYTYPE_HASH: obj = createHashObject(); break; - case REDISMODULE_KEYTYPE_STREAM: + case VALKEYMODULE_KEYTYPE_STREAM: obj = createStreamObject(); break; - default: return REDISMODULE_ERR; + default: return VALKEYMODULE_ERR; } dbAdd(key->db,key->key,obj); key->value = obj; moduleInitKeyTypeSpecific(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Frees key->iter and sets it to NULL. */ -static void moduleFreeKeyIterator(RedisModuleKey *key) { +static void moduleFreeKeyIterator(ValkeyModuleKey *key) { serverAssert(key->iter != NULL); switch (key->value->type) { case OBJ_LIST: listTypeReleaseIterator(key->iter); break; @@ -742,7 +743,7 @@ static void moduleFreeKeyIterator(RedisModuleKey *key) { /* Callback for listTypeTryConversion(). * Frees list iterator and sets it to NULL. */ static void moduleFreeListIterator(void *data) { - RedisModuleKey *key = (RedisModuleKey*)data; + ValkeyModuleKey *key = (ValkeyModuleKey*)data; serverAssert(key->value->type == OBJ_LIST); if (key->iter) moduleFreeKeyIterator(key); } @@ -757,8 +758,8 @@ static void moduleFreeListIterator(void *data) { * * The function returns 1 if the key value object is found empty and is * deleted, otherwise 0 is returned. */ -int moduleDelKeyIfEmpty(RedisModuleKey *key) { - if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL) return 0; +int moduleDelKeyIfEmpty(ValkeyModuleKey *key) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->value == NULL) return 0; int isempty; robj *o = key->value; @@ -784,24 +785,24 @@ int moduleDelKeyIfEmpty(RedisModuleKey *key) { /* -------------------------------------------------------------------------- * Service API exported to modules * - * Note that all the exported APIs are called RM_ in the core - * and RedisModule_ in the module side (defined as function - * pointers in redismodule.h). In this way the dynamic linker does not + * Note that all the exported APIs are called VM_ in the core + * and ValkeyModule_ in the module side (defined as function + * pointers in valkeymodule.h). In this way the dynamic linker does not * mess with our global function pointers, overriding it with the symbols * defined in the main executable having the same names. * -------------------------------------------------------------------------- */ -int RM_GetApi(const char *funcname, void **targetPtrPtr) { +int VM_GetApi(const char *funcname, void **targetPtrPtr) { /* Lookup the requested module API and store the function pointer into the - * target pointer. The function returns REDISMODULE_ERR if there is no such - * named API, otherwise REDISMODULE_OK. + * target pointer. The function returns VALKEYMODULE_ERR if there is no such + * named API, otherwise VALKEYMODULE_OK. * * This function is not meant to be used by modules developer, it is only - * used implicitly by including redismodule.h. */ + * used implicitly by including valkeymodule.h. */ dictEntry *he = dictFind(server.moduleapi, funcname); - if (!he) return REDISMODULE_ERR; + if (!he) return VALKEYMODULE_ERR; *targetPtrPtr = dictGetVal(he); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void modulePostExecutionUnitOperations(void) { @@ -818,9 +819,9 @@ void modulePostExecutionUnitOperations(void) { } /* Free the context after the user function was called. */ -void moduleFreeContext(RedisModuleCtx *ctx) { +void moduleFreeContext(ValkeyModuleCtx *ctx) { /* See comment in moduleCreateContext */ - if (!(ctx->flags & (REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_COMMAND))) { + if (!(ctx->flags & (VALKEYMODULE_CTX_THREAD_SAFE|VALKEYMODULE_CTX_COMMAND))) { exitExecutionUnit(); postExecutionUnitOperations(); } @@ -831,8 +832,8 @@ void moduleFreeContext(RedisModuleCtx *ctx) { ctx->postponed_arrays_count = 0; serverLog(LL_WARNING, "API misuse detected in module %s: " - "RedisModule_ReplyWith*(REDISMODULE_POSTPONED_LEN) " - "not matched by the same number of RedisModule_SetReply*Len() " + "ValkeyModule_ReplyWith*(VALKEYMODULE_POSTPONED_LEN) " + "not matched by the same number of ValkeyModule_SetReply*Len() " "calls.", ctx->module->name); } @@ -840,13 +841,13 @@ void moduleFreeContext(RedisModuleCtx *ctx) { * If this context created a new client (e.g detached context), we free it. * If the client is assigned manually, e.g ctx->client = someClientInstance, * none of these flags will be set and we do not attempt to free it. */ - if (ctx->flags & REDISMODULE_CTX_TEMP_CLIENT) + if (ctx->flags & VALKEYMODULE_CTX_TEMP_CLIENT) moduleReleaseTempClient(ctx->client); - else if (ctx->flags & REDISMODULE_CTX_NEW_CLIENT) + else if (ctx->flags & VALKEYMODULE_CTX_NEW_CLIENT) freeClient(ctx->client); } -static CallReply *moduleParseReply(client *c, RedisModuleCtx *ctx) { +static CallReply *moduleParseReply(client *c, ValkeyModuleCtx *ctx) { /* Convert the result of the Redis command into a module reply. */ sds proto = sdsnewlen(c->buf,c->bufpos); c->bufpos = 0; @@ -862,15 +863,15 @@ static CallReply *moduleParseReply(client *c, RedisModuleCtx *ctx) { } void moduleCallCommandUnblockedHandler(client *c) { - RedisModuleCtx ctx; - RedisModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; + ValkeyModuleCtx ctx; + ValkeyModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; serverAssert(promise); - RedisModule *module = promise->module; + ValkeyModule *module = promise->module; if (!promise->on_unblocked) { moduleReleaseTempClient(c); return; /* module did not set any unblock callback. */ } - moduleCreateContext(&ctx, module, REDISMODULE_CTX_TEMP_CLIENT); + moduleCreateContext(&ctx, module, VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, c->db->id); CallReply *reply = moduleParseReply(c, NULL); @@ -884,18 +885,18 @@ void moduleCallCommandUnblockedHandler(client *c) { /* Create a module ctx and keep track of the nesting level. * - * Note: When creating ctx for threads (RM_GetThreadSafeContext and - * RM_GetDetachedThreadSafeContext) we do not bump up the nesting level + * Note: When creating ctx for threads (VM_GetThreadSafeContext and + * VM_GetDetachedThreadSafeContext) we do not bump up the nesting level * because we only need to track of nesting level in the main thread * (only the main thread uses propagatePendingCommands) */ -void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags) { - memset(out_ctx, 0 ,sizeof(RedisModuleCtx)); - out_ctx->getapifuncptr = (void*)(unsigned long)&RM_GetApi; +void moduleCreateContext(ValkeyModuleCtx *out_ctx, ValkeyModule *module, int ctx_flags) { + memset(out_ctx, 0 ,sizeof(ValkeyModuleCtx)); + out_ctx->getapifuncptr = (void*)(unsigned long)&VM_GetApi; out_ctx->module = module; out_ctx->flags = ctx_flags; - if (ctx_flags & REDISMODULE_CTX_TEMP_CLIENT) + if (ctx_flags & VALKEYMODULE_CTX_TEMP_CLIENT) out_ctx->client = moduleAllocTempClient(); - else if (ctx_flags & REDISMODULE_CTX_NEW_CLIENT) + else if (ctx_flags & VALKEYMODULE_CTX_NEW_CLIENT) out_ctx->client = createClient(NULL); /* Calculate the initial yield time for long blocked contexts. @@ -917,17 +918,17 @@ void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_f * call() and in the latter we don't care about execution_nesting * 2. If we are running in a thread (execution_nesting will be dealt with * when locking/unlocking the GIL) */ - if (!(ctx_flags & (REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_COMMAND))) { + if (!(ctx_flags & (VALKEYMODULE_CTX_THREAD_SAFE|VALKEYMODULE_CTX_COMMAND))) { enterExecutionUnit(1, 0); } } /* This Redis command binds the normal Redis command invocation with commands * exported by modules. */ -void RedisModuleCommandDispatcher(client *c) { - RedisModuleCommand *cp = c->cmd->module_cmd; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_COMMAND); +void ValkeyModuleCommandDispatcher(client *c) { + ValkeyModuleCommand *cp = c->cmd->module_cmd; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cp->module, VALKEYMODULE_CTX_COMMAND); ctx.client = c; cp->func(&ctx,(void**)c->argv,c->argc); @@ -958,18 +959,18 @@ void RedisModuleCommandDispatcher(client *c) { * * In order to accomplish its work, the module command is called, flagging * the context in a way that the command can recognize this is a special - * "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */ + * "get keys" call by calling ValkeyModule_IsKeysPositionRequest(ctx). */ int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { - RedisModuleCommand *cp = cmd->module_cmd; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_KEYS_POS_REQUEST); + ValkeyModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cp->module, VALKEYMODULE_CTX_KEYS_POS_REQUEST); /* Initialize getKeysResult */ getKeysPrepareResult(result, MAX_KEYS_BUFFER); ctx.keys_result = result; cp->func(&ctx,(void**)argv,argc); - /* We currently always use the array allocated by RM_KeyAtPos() and don't try + /* We currently always use the array allocated by VM_KeyAtPos() and don't try * to optimize for the pre-allocated buffer. */ moduleFreeContext(&ctx); @@ -980,16 +981,16 @@ int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, * moduleGetCommandKeysViaAPI, for modules that declare "getchannels-api" * during registration. Unlike keys, this is the only way to declare channels. */ int moduleGetCommandChannelsViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { - RedisModuleCommand *cp = cmd->module_cmd; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_CHANNELS_POS_REQUEST); + ValkeyModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cp->module, VALKEYMODULE_CTX_CHANNELS_POS_REQUEST); /* Initialize getKeysResult */ getKeysPrepareResult(result, MAX_KEYS_BUFFER); ctx.keys_result = result; cp->func(&ctx,(void**)argv,argc); - /* We currently always use the array allocated by RM_RM_ChannelAtPosWithFlags() and don't try + /* We currently always use the array allocated by VM_RM_ChannelAtPosWithFlags() and don't try * to optimize for the pre-allocated buffer. */ moduleFreeContext(&ctx); return result->numkeys; @@ -1006,32 +1007,32 @@ int moduleGetCommandChannelsViaAPI(struct serverCommand *cmd, robj **argv, int a /* Return non-zero if a module command, that was declared with the * flag "getkeys-api", is called in a special way to get the keys positions * and not to get executed. Otherwise zero is returned. */ -int RM_IsKeysPositionRequest(RedisModuleCtx *ctx) { - return (ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) != 0; +int VM_IsKeysPositionRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_KEYS_POS_REQUEST) != 0; } /* When a module command is called in order to obtain the position of * keys, since it was flagged as "getkeys-api" during the registration, * the command implementation checks for this special call using the - * RedisModule_IsKeysPositionRequest() API and uses this function in + * ValkeyModule_IsKeysPositionRequest() API and uses this function in * order to report keys. * - * The supported flags are the ones used by RM_SetCommandInfo, see REDISMODULE_CMD_KEY_*. + * The supported flags are the ones used by VM_SetCommandInfo, see VALKEYMODULE_CMD_KEY_*. * * * The following is an example of how it could be used: * - * if (RedisModule_IsKeysPositionRequest(ctx)) { - * RedisModule_KeyAtPosWithFlags(ctx, 2, REDISMODULE_CMD_KEY_RO | REDISMODULE_CMD_KEY_ACCESS); - * RedisModule_KeyAtPosWithFlags(ctx, 1, REDISMODULE_CMD_KEY_RW | REDISMODULE_CMD_KEY_UPDATE | REDISMODULE_CMD_KEY_ACCESS); + * if (ValkeyModule_IsKeysPositionRequest(ctx)) { + * ValkeyModule_KeyAtPosWithFlags(ctx, 2, VALKEYMODULE_CMD_KEY_RO | VALKEYMODULE_CMD_KEY_ACCESS); + * ValkeyModule_KeyAtPosWithFlags(ctx, 1, VALKEYMODULE_CMD_KEY_RW | VALKEYMODULE_CMD_KEY_UPDATE | VALKEYMODULE_CMD_KEY_ACCESS); * } * * Note: in the example above the get keys API could have been handled by key-specs (preferred). * Implementing the getkeys-api is required only when is it not possible to declare key-specs that cover all keys. * */ -void RM_KeyAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { - if (!(ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return; +void VM_KeyAtPosWithFlags(ValkeyModuleCtx *ctx, int pos, int flags) { + if (!(ctx->flags & VALKEYMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return; if (pos <= 0) return; getKeysResult *res = ctx->keys_result; @@ -1047,50 +1048,50 @@ void RM_KeyAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { res->numkeys++; } -/* This API existed before RM_KeyAtPosWithFlags was added, now deprecated and +/* This API existed before VM_KeyAtPosWithFlags was added, now deprecated and * can be used for compatibility with older versions, before key-specs and flags * were introduced. */ -void RM_KeyAtPos(RedisModuleCtx *ctx, int pos) { +void VM_KeyAtPos(ValkeyModuleCtx *ctx, int pos) { /* Default flags require full access */ int flags = moduleConvertKeySpecsFlags(CMD_KEY_FULL_ACCESS, 0); - RM_KeyAtPosWithFlags(ctx, pos, flags); + VM_KeyAtPosWithFlags(ctx, pos, flags); } /* Return non-zero if a module command, that was declared with the * flag "getchannels-api", is called in a special way to get the channel positions * and not to get executed. Otherwise zero is returned. */ -int RM_IsChannelsPositionRequest(RedisModuleCtx *ctx) { - return (ctx->flags & REDISMODULE_CTX_CHANNELS_POS_REQUEST) != 0; +int VM_IsChannelsPositionRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_CHANNELS_POS_REQUEST) != 0; } /* When a module command is called in order to obtain the position of * channels, since it was flagged as "getchannels-api" during the * registration, the command implementation checks for this special call - * using the RedisModule_IsChannelsPositionRequest() API and uses this + * using the ValkeyModule_IsChannelsPositionRequest() API and uses this * function in order to report the channels. * * The supported flags are: - * * REDISMODULE_CMD_CHANNEL_SUBSCRIBE: This command will subscribe to the channel. - * * REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE: This command will unsubscribe from this channel. - * * REDISMODULE_CMD_CHANNEL_PUBLISH: This command will publish to this channel. - * * REDISMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any + * * VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE: This command will subscribe to the channel. + * * VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE: This command will unsubscribe from this channel. + * * VALKEYMODULE_CMD_CHANNEL_PUBLISH: This command will publish to this channel. + * * VALKEYMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any * channel specified by the pattern. This is the same access * used by the PSUBSCRIBE and PUNSUBSCRIBE commands available * in Redis. Not intended to be used with PUBLISH permissions. * * The following is an example of how it could be used: * - * if (RedisModule_IsChannelsPositionRequest(ctx)) { - * RedisModule_ChannelAtPosWithFlags(ctx, 1, REDISMODULE_CMD_CHANNEL_SUBSCRIBE | REDISMODULE_CMD_CHANNEL_PATTERN); - * RedisModule_ChannelAtPosWithFlags(ctx, 1, REDISMODULE_CMD_CHANNEL_PUBLISH); + * if (ValkeyModule_IsChannelsPositionRequest(ctx)) { + * ValkeyModule_ChannelAtPosWithFlags(ctx, 1, VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE | VALKEYMODULE_CMD_CHANNEL_PATTERN); + * ValkeyModule_ChannelAtPosWithFlags(ctx, 1, VALKEYMODULE_CMD_CHANNEL_PUBLISH); * } * * Note: One usage of declaring channels is for evaluating ACL permissions. In this context, * unsubscribing is always allowed, so commands will only be checked against subscribe and - * publish permissions. This is preferred over using RM_ACLCheckChannelPermissions, since + * publish permissions. This is preferred over using VM_ACLCheckChannelPermissions, since * it allows the ACLs to be checked before the command is executed. */ -void RM_ChannelAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { - if (!(ctx->flags & REDISMODULE_CTX_CHANNELS_POS_REQUEST) || !ctx->keys_result) return; +void VM_ChannelAtPosWithFlags(ValkeyModuleCtx *ctx, int pos, int flags) { + if (!(ctx->flags & VALKEYMODULE_CTX_CHANNELS_POS_REQUEST) || !ctx->keys_result) return; if (pos <= 0) return; getKeysResult *res = ctx->keys_result; @@ -1102,10 +1103,10 @@ void RM_ChannelAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { } int new_flags = 0; - if (flags & REDISMODULE_CMD_CHANNEL_SUBSCRIBE) new_flags |= CMD_CHANNEL_SUBSCRIBE; - if (flags & REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE) new_flags |= CMD_CHANNEL_UNSUBSCRIBE; - if (flags & REDISMODULE_CMD_CHANNEL_PUBLISH) new_flags |= CMD_CHANNEL_PUBLISH; - if (flags & REDISMODULE_CMD_CHANNEL_PATTERN) new_flags |= CMD_CHANNEL_PATTERN; + if (flags & VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE) new_flags |= CMD_CHANNEL_SUBSCRIBE; + if (flags & VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE) new_flags |= CMD_CHANNEL_UNSUBSCRIBE; + if (flags & VALKEYMODULE_CMD_CHANNEL_PUBLISH) new_flags |= CMD_CHANNEL_PUBLISH; + if (flags & VALKEYMODULE_CMD_CHANNEL_PATTERN) new_flags |= CMD_CHANNEL_PATTERN; res->keys[res->numkeys].pos = pos; res->keys[res->numkeys].flags = new_flags; @@ -1132,7 +1133,7 @@ int isCommandNameValid(const char *name) { return 1; } -/* Helper for RM_CreateCommand(). Turns a string representing command +/* Helper for VM_CreateCommand(). Turns a string representing command * flags into the command flags used by the Redis core. * * It returns the set of flags, or -1 if unknown flags are found. */ @@ -1169,29 +1170,29 @@ int64_t commandFlagsFromString(char *s) { return flags; } -RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep); +ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds declared_name, sds fullname, ValkeyModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep); /* Register a new command in the Redis server, that will be handled by - * calling the function pointer 'cmdfunc' using the RedisModule calling + * calling the function pointer 'cmdfunc' using the ValkeyModule calling * convention. * - * The function returns REDISMODULE_ERR in these cases: - * - If creation of module command is called outside the RedisModule_OnLoad. + * The function returns VALKEYMODULE_ERR in these cases: + * - If creation of module command is called outside the ValkeyModule_OnLoad. * - The specified command is already busy. * - The command name contains some chars that are not allowed. * - A set of invalid flags were passed. * - * Otherwise REDISMODULE_OK is returned and the new command is registered. + * Otherwise VALKEYMODULE_OK is returned and the new command is registered. * * This function must be called during the initialization of the module - * inside the RedisModule_OnLoad() function. Calling this function outside + * inside the ValkeyModule_OnLoad() function. Calling this function outside * of the initialization function is not defined. * * The command function type is the following: * - * int MyCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc); + * int MyCommand_RedisCommand(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc); * - * And is supposed to always return REDISMODULE_OK. + * And is supposed to always return VALKEYMODULE_OK. * * The set of flags 'strflags' specify the behavior of the command, and should * be passed as a C string composed of space separated words, like for @@ -1243,7 +1244,7 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * * **"blocking"**: The command has the potential to block the client. * * **"allow-busy"**: Permit the command while the server is blocked either by * a script or by a slow module command, see - * RM_Yield. + * VM_Yield. * * **"getchannels-api"**: The command implements the interface to return * the arguments that are channels. * @@ -1265,32 +1266,32 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * NOTE: The scheme described above serves a limited purpose and can * only be used to find keys that exist at constant indices. * For non-trivial key arguments, you may pass 0,0,0 and use - * RedisModule_SetCommandInfo to set key specs using a more advanced scheme and use - * RedisModule_SetCommandACLCategories to set Redis ACL categories of the commands. */ -int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { + * ValkeyModule_SetCommandInfo to set key specs using a more advanced scheme and use + * ValkeyModule_SetCommandACLCategories to set Redis ACL categories of the commands. */ +int VM_CreateCommand(ValkeyModuleCtx *ctx, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!ctx->module->onload) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0; - if (flags == -1) return REDISMODULE_ERR; + if (flags == -1) return VALKEYMODULE_ERR; if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Check if the command name is valid. */ if (!isCommandNameValid(name)) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Check if the command name is busy. */ if (lookupCommandByCString(name) != NULL) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; sds declared_name = sdsnew(name); - RedisModuleCommand *cp = moduleCreateCommandProxy(ctx->module, declared_name, sdsdup(declared_name), cmdfunc, flags, firstkey, lastkey, keystep); + ValkeyModuleCommand *cp = moduleCreateCommandProxy(ctx->module, declared_name, sdsdup(declared_name), cmdfunc, flags, firstkey, lastkey, keystep); cp->rediscmd->arity = cmdfunc ? -1 : -2; /* Default value, can be changed later via dedicated API */ serverAssert(dictAdd(server.commands, sdsdup(declared_name), cp->rediscmd) == DICT_OK); serverAssert(dictAdd(server.orig_commands, sdsdup(declared_name), cp->rediscmd) == DICT_OK); cp->rediscmd->id = ACLGetCommandID(declared_name); /* ID used for ACL. */ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* A proxy that help create a module command / subcommand. @@ -1300,9 +1301,9 @@ int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc c * * Function will take the ownership of both 'declared_name' and 'fullname' SDS. */ -RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) { +ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds declared_name, sds fullname, ValkeyModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) { struct serverCommand *rediscmd; - RedisModuleCommand *cp; + ValkeyModuleCommand *cp; /* Create a command "proxy", which is a structure that is referenced * in the command table, so that the generic command that works as @@ -1315,7 +1316,7 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec cp->rediscmd->declared_name = declared_name; /* SDS for module commands */ cp->rediscmd->fullname = fullname; cp->rediscmd->group = COMMAND_GROUP_MODULE; - cp->rediscmd->proc = RedisModuleCommandDispatcher; + cp->rediscmd->proc = ValkeyModuleCommandDispatcher; cp->rediscmd->flags = flags | CMD_MODULE; cp->rediscmd->module_cmd = cp; if (firstkey != 0) { @@ -1351,101 +1352,101 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * * The command is not a module command * * The command doesn't belong to the calling module */ -RedisModuleCommand *RM_GetCommand(RedisModuleCtx *ctx, const char *name) { +ValkeyModuleCommand *VM_GetCommand(ValkeyModuleCtx *ctx, const char *name) { struct serverCommand *cmd = lookupCommandByCString(name); if (!cmd || !(cmd->flags & CMD_MODULE)) return NULL; - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; if (cp->module != ctx->module) return NULL; return cp; } -/* Very similar to RedisModule_CreateCommand except that it is used to create +/* Very similar to ValkeyModule_CreateCommand except that it is used to create * a subcommand, associated with another, container, command. * * Example: If a module has a configuration command, MODULE.CONFIG, then * GET and SET should be individual subcommands, while MODULE.CONFIG is * a command, but should not be registered with a valid `funcptr`: * - * if (RedisModule_CreateCommand(ctx,"module.config",NULL,"",0,0,0) == REDISMODULE_ERR) - * return REDISMODULE_ERR; + * if (ValkeyModule_CreateCommand(ctx,"module.config",NULL,"",0,0,0) == VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; * - * RedisModuleCommand *parent = RedisModule_GetCommand(ctx,,"module.config"); + * ValkeyModuleCommand *parent = ValkeyModule_GetCommand(ctx,,"module.config"); * - * if (RedisModule_CreateSubcommand(parent,"set",cmd_config_set,"",0,0,0) == REDISMODULE_ERR) - * return REDISMODULE_ERR; + * if (ValkeyModule_CreateSubcommand(parent,"set",cmd_config_set,"",0,0,0) == VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; * - * if (RedisModule_CreateSubcommand(parent,"get",cmd_config_get,"",0,0,0) == REDISMODULE_ERR) - * return REDISMODULE_ERR; + * if (ValkeyModule_CreateSubcommand(parent,"get",cmd_config_get,"",0,0,0) == VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR in case of the following errors: + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR in case of the following errors: * * * Error while parsing `strflags` * * Command is marked as `no-cluster` but cluster mode is enabled * * `parent` is already a subcommand (we do not allow more than one level of command nesting) - * * `parent` is a command with an implementation (RedisModuleCmdFunc) (A parent command should be a pure container of subcommands) + * * `parent` is a command with an implementation (ValkeyModuleCmdFunc) (A parent command should be a pure container of subcommands) * * `parent` already has a subcommand called `name` - * * Creating a subcommand is called outside of RedisModule_OnLoad. + * * Creating a subcommand is called outside of ValkeyModule_OnLoad. */ -int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { +int VM_CreateSubcommand(ValkeyModuleCommand *parent, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!parent->module->onload) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0; - if (flags == -1) return REDISMODULE_ERR; + if (flags == -1) return VALKEYMODULE_ERR; if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; struct serverCommand *parent_cmd = parent->rediscmd; if (parent_cmd->parent) - return REDISMODULE_ERR; /* We don't allow more than one level of subcommands */ + return VALKEYMODULE_ERR; /* We don't allow more than one level of subcommands */ - RedisModuleCommand *parent_cp = parent_cmd->module_cmd; + ValkeyModuleCommand *parent_cp = parent_cmd->module_cmd; if (parent_cp->func) - return REDISMODULE_ERR; /* A parent command should be a pure container of subcommands */ + return VALKEYMODULE_ERR; /* A parent command should be a pure container of subcommands */ /* Check if the command name is valid. */ if (!isCommandNameValid(name)) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Check if the command name is busy within the parent command. */ sds declared_name = sdsnew(name); if (parent_cmd->subcommands_dict && lookupSubcommand(parent_cmd, declared_name) != NULL) { sdsfree(declared_name); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } sds fullname = catSubCommandFullname(parent_cmd->fullname, name); - RedisModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep); + ValkeyModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep); cp->rediscmd->arity = -2; commandAddSubcommand(parent_cmd, cp->rediscmd, name); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Accessors of array elements of structs where the element size is stored * separately in the version struct. */ -static RedisModuleCommandHistoryEntry * -moduleCmdHistoryEntryAt(const RedisModuleCommandInfoVersion *version, - RedisModuleCommandHistoryEntry *entries, int index) { +static ValkeyModuleCommandHistoryEntry * +moduleCmdHistoryEntryAt(const ValkeyModuleCommandInfoVersion *version, + ValkeyModuleCommandHistoryEntry *entries, int index) { off_t offset = index * version->sizeof_historyentry; - return (RedisModuleCommandHistoryEntry *)((char *)(entries) + offset); + return (ValkeyModuleCommandHistoryEntry *)((char *)(entries) + offset); } -static RedisModuleCommandKeySpec * -moduleCmdKeySpecAt(const RedisModuleCommandInfoVersion *version, - RedisModuleCommandKeySpec *keyspecs, int index) { +static ValkeyModuleCommandKeySpec * +moduleCmdKeySpecAt(const ValkeyModuleCommandInfoVersion *version, + ValkeyModuleCommandKeySpec *keyspecs, int index) { off_t offset = index * version->sizeof_keyspec; - return (RedisModuleCommandKeySpec *)((char *)(keyspecs) + offset); + return (ValkeyModuleCommandKeySpec *)((char *)(keyspecs) + offset); } -static RedisModuleCommandArg * -moduleCmdArgAt(const RedisModuleCommandInfoVersion *version, - const RedisModuleCommandArg *args, int index) { +static ValkeyModuleCommandArg * +moduleCmdArgAt(const ValkeyModuleCommandInfoVersion *version, + const ValkeyModuleCommandArg *args, int index) { off_t offset = index * version->sizeof_arg; - return (RedisModuleCommandArg *)((char *)(args) + offset); + return (ValkeyModuleCommandArg *)((char *)(args) + offset); } /* Recursively populate the args structure (setting num_args to the number of @@ -1463,42 +1464,42 @@ int populateArgsStructure(struct serverCommandArg *args) { return count; } -/* RedisModule_AddACLCategory can be used to add new ACL command categories. Category names +/* ValkeyModule_AddACLCategory can be used to add new ACL command categories. Category names * can only contain alphanumeric characters, underscores, or dashes. Categories can only be added - * during the RedisModule_OnLoad function. Once a category has been added, it can not be removed. - * Any module can register a command to any added categories using RedisModule_SetCommandACLCategories. + * during the ValkeyModule_OnLoad function. Once a category has been added, it can not be removed. + * Any module can register a command to any added categories using ValkeyModule_SetCommandACLCategories. * * Returns: - * - REDISMODULE_OK on successfully adding the new ACL category. - * - REDISMODULE_ERR on failure. + * - VALKEYMODULE_OK on successfully adding the new ACL category. + * - VALKEYMODULE_ERR on failure. * * On error the errno is set to: * - EINVAL if the name contains invalid characters. * - EBUSY if the category name already exists. * - ENOMEM if the number of categories reached the max limit of 64 categories. */ -int RM_AddACLCategory(RedisModuleCtx *ctx, const char *name) { +int VM_AddACLCategory(ValkeyModuleCtx *ctx, const char *name) { if (!ctx->module->onload) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (moduleVerifyResourceName(name) == REDISMODULE_ERR) { + if (moduleVerifyResourceName(name) == VALKEYMODULE_ERR) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ACLGetCommandCategoryFlagByName(name)) { errno = EBUSY; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ACLAddCommandCategory(name, 0)) { ctx->module->num_acl_categories_added++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { errno = ENOMEM; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } @@ -1516,7 +1517,7 @@ int matchAclCategoryFlag(char *flag, int64_t *acl_categories_flags) { return 0; /* Unrecognized */ } -/* Helper for RM_SetCommandACLCategories(). Turns a string representing acl category +/* Helper for VM_SetCommandACLCategories(). Turns a string representing acl category * flags into the acl category flags used by Redis ACL which allows users to access * the module commands by acl categories. * @@ -1537,26 +1538,26 @@ int64_t categoryFlagsFromString(char *aclflags) { return acl_categories_flags; } -/* RedisModule_SetCommandACLCategories can be used to set ACL categories to module +/* ValkeyModule_SetCommandACLCategories can be used to set ACL categories to module * commands and subcommands. The set of ACL categories should be passed as * a space separated C string 'aclflags'. * * Example, the acl flags 'write slow' marks the command as part of the write and * slow ACL categories. * - * On success REDISMODULE_OK is returned. On error REDISMODULE_ERR is returned. + * On success VALKEYMODULE_OK is returned. On error VALKEYMODULE_ERR is returned. * - * This function can only be called during the RedisModule_OnLoad function. If called + * This function can only be called during the ValkeyModule_OnLoad function. If called * outside of this function, an error is returned. */ -int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags) { - if (!command || !command->module || !command->module->onload) return REDISMODULE_ERR; +int VM_SetCommandACLCategories(ValkeyModuleCommand *command, const char *aclflags) { + if (!command || !command->module || !command->module->onload) return VALKEYMODULE_ERR; int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0; - if (categories_flags == -1) return REDISMODULE_ERR; + if (categories_flags == -1) return VALKEYMODULE_ERR; struct serverCommand *rcmd = command->rediscmd; rcmd->acl_categories = categories_flags; /* ACL categories flags for module command */ command->module->num_commands_with_acl_categories++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Set additional command information. @@ -1565,26 +1566,26 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * ACL and is used to filter commands with the wrong number of arguments before * the call reaches the module code. * - * This function can be called after creating a command using RM_CreateCommand - * and fetching the command pointer using RM_GetCommand. The information can + * This function can be called after creating a command using VM_CreateCommand + * and fetching the command pointer using VM_GetCommand. The information can * only be set once for each command and has the following structure: * - * typedef struct RedisModuleCommandInfo { - * const RedisModuleCommandInfoVersion *version; + * typedef struct ValkeyModuleCommandInfo { + * const ValkeyModuleCommandInfoVersion *version; * const char *summary; * const char *complexity; * const char *since; - * RedisModuleCommandHistoryEntry *history; + * ValkeyModuleCommandHistoryEntry *history; * const char *tips; * int arity; - * RedisModuleCommandKeySpec *key_specs; - * RedisModuleCommandArg *args; - * } RedisModuleCommandInfo; + * ValkeyModuleCommandKeySpec *key_specs; + * ValkeyModuleCommandArg *args; + * } ValkeyModuleCommandInfo; * * All fields except `version` are optional. Explanation of the fields: * * - `version`: This field enables compatibility with different Redis versions. - * Always set this field to REDISMODULE_COMMAND_INFO_VERSION. + * Always set this field to VALKEYMODULE_COMMAND_INFO_VERSION. * * - `summary`: A short description of the command (optional). * @@ -1593,7 +1594,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * - `since`: The version where the command was introduced (optional). * Note: The version specified should be the module's, not Redis version. * - * - `history`: An array of RedisModuleCommandHistoryEntry (optional), which is + * - `history`: An array of ValkeyModuleCommandHistoryEntry (optional), which is * a struct with the following fields: * * const char *since; @@ -1614,9 +1615,9 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * omitted arity field) is equivalent to -2 if the command has sub commands * and -1 otherwise. * - * - `key_specs`: An array of RedisModuleCommandKeySpec, terminated by an + * - `key_specs`: An array of ValkeyModuleCommandKeySpec, terminated by an * element memset to zero. This is a scheme that tries to describe the - * positions of key arguments better than the old RM_CreateCommand arguments + * positions of key arguments better than the old VM_CreateCommand arguments * `firstkey`, `lastkey`, `keystep` and is needed if those three are not * enough to describe the key positions. There are two steps to retrieve key * positions: *begin search* (BS) in which index should find the first key and @@ -1624,21 +1625,21 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * will which arguments are keys. Additionally, there are key specific flags. * * Key-specs cause the triplet (firstkey, lastkey, keystep) given in - * RM_CreateCommand to be recomputed, but it is still useful to provide - * these three parameters in RM_CreateCommand, to better support old Redis - * versions where RM_SetCommandInfo is not available. + * VM_CreateCommand to be recomputed, but it is still useful to provide + * these three parameters in VM_CreateCommand, to better support old Redis + * versions where VM_SetCommandInfo is not available. * * Note that key-specs don't fully replace the "getkeys-api" (see - * RM_CreateCommand, RM_IsKeysPositionRequest and RM_KeyAtPosWithFlags) so + * VM_CreateCommand, VM_IsKeysPositionRequest and VM_KeyAtPosWithFlags) so * it may be a good idea to supply both key-specs and implement the * getkeys-api. * * A key-spec has the following structure: * - * typedef struct RedisModuleCommandKeySpec { + * typedef struct ValkeyModuleCommandKeySpec { * const char *notes; * uint64_t flags; - * RedisModuleKeySpecBeginSearchType begin_search_type; + * ValkeyModuleKeySpecBeginSearchType begin_search_type; * union { * struct { * int pos; @@ -1648,7 +1649,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * int startfrom; * } keyword; * } bs; - * RedisModuleKeySpecFindKeysType find_keys_type; + * ValkeyModuleKeySpecFindKeysType find_keys_type; * union { * struct { * int lastkey; @@ -1661,9 +1662,9 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * int keystep; * } keynum; * } fk; - * } RedisModuleCommandKeySpec; + * } ValkeyModuleCommandKeySpec; * - * Explanation of the fields of RedisModuleCommandKeySpec: + * Explanation of the fields of ValkeyModuleCommandKeySpec: * * * `notes`: Optional notes or clarifications about this key spec. * @@ -1672,34 +1673,34 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * * `begin_search_type`: This describes how the first key is discovered. * There are two ways to determine the first key: * - * * `REDISMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the + * * `VALKEYMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the * key args start. - * * `REDISMODULE_KSPEC_BS_INDEX`: Key args start at a constant index. - * * `REDISMODULE_KSPEC_BS_KEYWORD`: Key args start just after a + * * `VALKEYMODULE_KSPEC_BS_INDEX`: Key args start at a constant index. + * * `VALKEYMODULE_KSPEC_BS_KEYWORD`: Key args start just after a * specific keyword. * * * `bs`: This is a union in which the `index` or `keyword` branch is used * depending on the value of the `begin_search_type` field. * * * `bs.index.pos`: The index from which we start the search for keys. - * (`REDISMODULE_KSPEC_BS_INDEX` only.) + * (`VALKEYMODULE_KSPEC_BS_INDEX` only.) * * * `bs.keyword.keyword`: The keyword (string) that indicates the - * beginning of key arguments. (`REDISMODULE_KSPEC_BS_KEYWORD` only.) + * beginning of key arguments. (`VALKEYMODULE_KSPEC_BS_KEYWORD` only.) * * * `bs.keyword.startfrom`: An index in argv from which to start * searching. Can be negative, which means start search from the end, * in reverse. Example: -2 means to start in reverse from the - * penultimate argument. (`REDISMODULE_KSPEC_BS_KEYWORD` only.) + * penultimate argument. (`VALKEYMODULE_KSPEC_BS_KEYWORD` only.) * * * `find_keys_type`: After the "begin search", this describes which * arguments are keys. The strategies are: * - * * `REDISMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the + * * `VALKEYMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the * key args are located. - * * `REDISMODULE_KSPEC_FK_RANGE`: Keys end at a specific index (or + * * `VALKEYMODULE_KSPEC_FK_RANGE`: Keys end at a specific index (or * relative to the last argument). - * * `REDISMODULE_KSPEC_FK_KEYNUM`: There's an argument that contains + * * `VALKEYMODULE_KSPEC_FK_KEYNUM`: There's an argument that contains * the number of key args somewhere before the keys themselves. * * `find_keys_type` and `fk` can be omitted if this keyspec describes @@ -1708,7 +1709,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * * `fk`: This is a union in which the `range` or `keynum` branch is used * depending on the value of the `find_keys_type` field. * - * * `fk.range` (for `REDISMODULE_KSPEC_FK_RANGE`): A struct with the + * * `fk.range` (for `VALKEYMODULE_KSPEC_FK_RANGE`): A struct with the * following fields: * * * `lastkey`: Index of the last key relative to the result of the @@ -1723,7 +1724,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * by a factor. 0 and 1 mean no limit. 2 means 1/2 of the * remaining args, 3 means 1/3, and so on. * - * * `fk.keynum` (for `REDISMODULE_KSPEC_FK_KEYNUM`): A struct with the + * * `fk.keynum` (for `VALKEYMODULE_KSPEC_FK_KEYNUM`): A struct with the * following fields: * * * `keynumidx`: Index of the argument containing the number of @@ -1744,16 +1745,16 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * that's not distinctly deletion, overwrite or read-only would be marked as * RW. * - * * `REDISMODULE_CMD_KEY_RO`: Read-Only. Reads the value of the key, but + * * `VALKEYMODULE_CMD_KEY_RO`: Read-Only. Reads the value of the key, but * doesn't necessarily return it. * - * * `REDISMODULE_CMD_KEY_RW`: Read-Write. Modifies the data stored in the + * * `VALKEYMODULE_CMD_KEY_RW`: Read-Write. Modifies the data stored in the * value of the key or its metadata. * - * * `REDISMODULE_CMD_KEY_OW`: Overwrite. Overwrites the data stored in the + * * `VALKEYMODULE_CMD_KEY_OW`: Overwrite. Overwrites the data stored in the * value of the key. * - * * `REDISMODULE_CMD_KEY_RM`: Deletes the key. + * * `VALKEYMODULE_CMD_KEY_RM`: Deletes the key. * * The next four refer to *user data inside the value of the key*, not the * metadata like LRU, type, cardinality. It refers to the logical operation @@ -1763,107 +1764,107 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * combined with one of the write operations INSERT, DELETE or UPDATE. Any * write that's not an INSERT or a DELETE would be UPDATE. * - * * `REDISMODULE_CMD_KEY_ACCESS`: Returns, copies or uses the user data + * * `VALKEYMODULE_CMD_KEY_ACCESS`: Returns, copies or uses the user data * from the value of the key. * - * * `REDISMODULE_CMD_KEY_UPDATE`: Updates data to the value, new value may + * * `VALKEYMODULE_CMD_KEY_UPDATE`: Updates data to the value, new value may * depend on the old value. * - * * `REDISMODULE_CMD_KEY_INSERT`: Adds data to the value with no chance of + * * `VALKEYMODULE_CMD_KEY_INSERT`: Adds data to the value with no chance of * modification or deletion of existing data. * - * * `REDISMODULE_CMD_KEY_DELETE`: Explicitly deletes some content from the + * * `VALKEYMODULE_CMD_KEY_DELETE`: Explicitly deletes some content from the * value of the key. * * Other flags: * - * * `REDISMODULE_CMD_KEY_NOT_KEY`: The key is not actually a key, but + * * `VALKEYMODULE_CMD_KEY_NOT_KEY`: The key is not actually a key, but * should be routed in cluster mode as if it was a key. * - * * `REDISMODULE_CMD_KEY_INCOMPLETE`: The keyspec might not point out all + * * `VALKEYMODULE_CMD_KEY_INCOMPLETE`: The keyspec might not point out all * the keys it should cover. * - * * `REDISMODULE_CMD_KEY_VARIABLE_FLAGS`: Some keys might have different + * * `VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS`: Some keys might have different * flags depending on arguments. * - * - `args`: An array of RedisModuleCommandArg, terminated by an element memset - * to zero. RedisModuleCommandArg is a structure with at the fields described + * - `args`: An array of ValkeyModuleCommandArg, terminated by an element memset + * to zero. ValkeyModuleCommandArg is a structure with at the fields described * below. * - * typedef struct RedisModuleCommandArg { + * typedef struct ValkeyModuleCommandArg { * const char *name; - * RedisModuleCommandArgType type; + * ValkeyModuleCommandArgType type; * int key_spec_index; * const char *token; * const char *summary; * const char *since; * int flags; - * struct RedisModuleCommandArg *subargs; - * } RedisModuleCommandArg; + * struct ValkeyModuleCommandArg *subargs; + * } ValkeyModuleCommandArg; * * Explanation of the fields: * * * `name`: Name of the argument. * * * `type`: The type of the argument. See below for details. The types - * `REDISMODULE_ARG_TYPE_ONEOF` and `REDISMODULE_ARG_TYPE_BLOCK` require + * `VALKEYMODULE_ARG_TYPE_ONEOF` and `VALKEYMODULE_ARG_TYPE_BLOCK` require * an argument to have sub-arguments, i.e. `subargs`. * - * * `key_spec_index`: If the `type` is `REDISMODULE_ARG_TYPE_KEY` you must + * * `key_spec_index`: If the `type` is `VALKEYMODULE_ARG_TYPE_KEY` you must * provide the index of the key-spec associated with this argument. See * `key_specs` above. If the argument is not a key, you may specify -1. * * * `token`: The token preceding the argument (optional). Example: the * argument `seconds` in `SET` has a token `EX`. If the argument consists * of only a token (for example `NX` in `SET`) the type should be - * `REDISMODULE_ARG_TYPE_PURE_TOKEN` and `value` should be NULL. + * `VALKEYMODULE_ARG_TYPE_PURE_TOKEN` and `value` should be NULL. * * * `summary`: A short description of the argument (optional). * * * `since`: The first version which included this argument (optional). * - * * `flags`: A bitwise or of the macros `REDISMODULE_CMD_ARG_*`. See below. + * * `flags`: A bitwise or of the macros `VALKEYMODULE_CMD_ARG_*`. See below. * * * `value`: The display-value of the argument. This string is what should * be displayed when creating the command syntax from the output of * `COMMAND`. If `token` is not NULL, it should also be displayed. * - * Explanation of `RedisModuleCommandArgType`: + * Explanation of `ValkeyModuleCommandArgType`: * - * * `REDISMODULE_ARG_TYPE_STRING`: String argument. - * * `REDISMODULE_ARG_TYPE_INTEGER`: Integer argument. - * * `REDISMODULE_ARG_TYPE_DOUBLE`: Double-precision float argument. - * * `REDISMODULE_ARG_TYPE_KEY`: String argument representing a keyname. - * * `REDISMODULE_ARG_TYPE_PATTERN`: String, but regex pattern. - * * `REDISMODULE_ARG_TYPE_UNIX_TIME`: Integer, but Unix timestamp. - * * `REDISMODULE_ARG_TYPE_PURE_TOKEN`: Argument doesn't have a placeholder. + * * `VALKEYMODULE_ARG_TYPE_STRING`: String argument. + * * `VALKEYMODULE_ARG_TYPE_INTEGER`: Integer argument. + * * `VALKEYMODULE_ARG_TYPE_DOUBLE`: Double-precision float argument. + * * `VALKEYMODULE_ARG_TYPE_KEY`: String argument representing a keyname. + * * `VALKEYMODULE_ARG_TYPE_PATTERN`: String, but regex pattern. + * * `VALKEYMODULE_ARG_TYPE_UNIX_TIME`: Integer, but Unix timestamp. + * * `VALKEYMODULE_ARG_TYPE_PURE_TOKEN`: Argument doesn't have a placeholder. * It's just a token without a value. Example: the `KEEPTTL` option of the * `SET` command. - * * `REDISMODULE_ARG_TYPE_ONEOF`: Used when the user can choose only one of + * * `VALKEYMODULE_ARG_TYPE_ONEOF`: Used when the user can choose only one of * a few sub-arguments. Requires `subargs`. Example: the `NX` and `XX` * options of `SET`. - * * `REDISMODULE_ARG_TYPE_BLOCK`: Used when one wants to group together + * * `VALKEYMODULE_ARG_TYPE_BLOCK`: Used when one wants to group together * several sub-arguments, usually to apply something on all of them, like * making the entire group "optional". Requires `subargs`. Example: the * `LIMIT offset count` parameters in `ZRANGE`. * * Explanation of the command argument flags: * - * * `REDISMODULE_CMD_ARG_OPTIONAL`: The argument is optional (like GET in + * * `VALKEYMODULE_CMD_ARG_OPTIONAL`: The argument is optional (like GET in * the SET command). - * * `REDISMODULE_CMD_ARG_MULTIPLE`: The argument may repeat itself (like + * * `VALKEYMODULE_CMD_ARG_MULTIPLE`: The argument may repeat itself (like * key in DEL). - * * `REDISMODULE_CMD_ARG_MULTIPLE_TOKEN`: The argument may repeat itself, + * * `VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN`: The argument may repeat itself, * and so does its token (like `GET pattern` in SORT). * - * On success REDISMODULE_OK is returned. On error REDISMODULE_ERR is returned + * On success VALKEYMODULE_OK is returned. On error VALKEYMODULE_ERR is returned * and `errno` is set to EINVAL if invalid info was provided or EEXIST if info * has already been set. If the info is invalid, a warning is logged explaining * which part of the info is invalid and why. */ -int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo *info) { +int VM_SetCommandInfo(ValkeyModuleCommand *command, const ValkeyModuleCommandInfo *info) { if (!moduleValidateCommandInfo(info)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } struct serverCommand *cmd = command->rediscmd; @@ -1878,14 +1879,14 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo cmd->key_specs[0].begin_search_type == KSPEC_BS_INDEX && cmd->key_specs[0].find_keys_type == KSPEC_FK_RANGE))) { errno = EEXIST; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (info->summary) cmd->summary = zstrdup(info->summary); if (info->complexity) cmd->complexity = zstrdup(info->complexity); if (info->since) cmd->since = zstrdup(info->since); - const RedisModuleCommandInfoVersion *version = info->version; + const ValkeyModuleCommandInfoVersion *version = info->version; if (info->history) { size_t count = 0; while (moduleCmdHistoryEntryAt(version, info->history, count)->since) @@ -1893,7 +1894,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo serverAssert(count < SIZE_MAX / sizeof(commandHistory)); cmd->history = zmalloc(sizeof(commandHistory) * (count + 1)); for (size_t j = 0; j < count; j++) { - RedisModuleCommandHistoryEntry *entry = + ValkeyModuleCommandHistoryEntry *entry = moduleCmdHistoryEntryAt(version, info->history, j); cmd->history[j].since = zstrdup(entry->since); cmd->history[j].changes = zstrdup(entry->changes); @@ -1928,22 +1929,22 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo zfree(cmd->key_specs); cmd->key_specs = zmalloc(sizeof(keySpec) * count); - /* Copy the contents of the RedisModuleCommandKeySpec array. */ + /* Copy the contents of the ValkeyModuleCommandKeySpec array. */ cmd->key_specs_num = count; for (size_t j = 0; j < count; j++) { - RedisModuleCommandKeySpec *spec = + ValkeyModuleCommandKeySpec *spec = moduleCmdKeySpecAt(version, info->key_specs, j); cmd->key_specs[j].notes = spec->notes ? zstrdup(spec->notes) : NULL; cmd->key_specs[j].flags = moduleConvertKeySpecsFlags(spec->flags, 1); switch (spec->begin_search_type) { - case REDISMODULE_KSPEC_BS_UNKNOWN: + case VALKEYMODULE_KSPEC_BS_UNKNOWN: cmd->key_specs[j].begin_search_type = KSPEC_BS_UNKNOWN; break; - case REDISMODULE_KSPEC_BS_INDEX: + case VALKEYMODULE_KSPEC_BS_INDEX: cmd->key_specs[j].begin_search_type = KSPEC_BS_INDEX; cmd->key_specs[j].bs.index.pos = spec->bs.index.pos; break; - case REDISMODULE_KSPEC_BS_KEYWORD: + case VALKEYMODULE_KSPEC_BS_KEYWORD: cmd->key_specs[j].begin_search_type = KSPEC_BS_KEYWORD; cmd->key_specs[j].bs.keyword.keyword = zstrdup(spec->bs.keyword.keyword); cmd->key_specs[j].bs.keyword.startfrom = spec->bs.keyword.startfrom; @@ -1954,23 +1955,23 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo } switch (spec->find_keys_type) { - case REDISMODULE_KSPEC_FK_OMITTED: + case VALKEYMODULE_KSPEC_FK_OMITTED: /* Omitted field is shorthand to say that it's a single key. */ cmd->key_specs[j].find_keys_type = KSPEC_FK_RANGE; cmd->key_specs[j].fk.range.lastkey = 0; cmd->key_specs[j].fk.range.keystep = 1; cmd->key_specs[j].fk.range.limit = 0; break; - case REDISMODULE_KSPEC_FK_UNKNOWN: + case VALKEYMODULE_KSPEC_FK_UNKNOWN: cmd->key_specs[j].find_keys_type = KSPEC_FK_UNKNOWN; break; - case REDISMODULE_KSPEC_FK_RANGE: + case VALKEYMODULE_KSPEC_FK_RANGE: cmd->key_specs[j].find_keys_type = KSPEC_FK_RANGE; cmd->key_specs[j].fk.range.lastkey = spec->fk.range.lastkey; cmd->key_specs[j].fk.range.keystep = spec->fk.range.keystep; cmd->key_specs[j].fk.range.limit = spec->fk.range.limit; break; - case REDISMODULE_KSPEC_FK_KEYNUM: + case VALKEYMODULE_KSPEC_FK_KEYNUM: cmd->key_specs[j].find_keys_type = KSPEC_FK_KEYNUM; cmd->key_specs[j].fk.keynum.keynumidx = spec->fk.keynum.keynumidx; cmd->key_specs[j].fk.keynum.firstkey = spec->fk.keynum.firstkey; @@ -1996,7 +1997,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo /* Fields added in future versions to be added here, under conditions like * `if (info->version >= 2) { access version 2 fields here }` */ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Returns 1 if v is a power of two, 0 otherwise. */ @@ -2005,8 +2006,8 @@ static inline int isPowerOfTwo(uint64_t v) { } /* Returns 1 if the command info is valid and 0 otherwise. */ -static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { - const RedisModuleCommandInfoVersion *version = info->version; +static int moduleValidateCommandInfo(const ValkeyModuleCommandInfo *info) { + const ValkeyModuleCommandInfoVersion *version = info->version; if (!version) { serverLog(LL_WARNING, "Invalid command info: version missing"); return 0; @@ -2034,7 +2035,7 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { moduleCmdKeySpecAt(version, info->key_specs, j)->begin_search_type; j++) { - RedisModuleCommandKeySpec *spec = + ValkeyModuleCommandKeySpec *spec = moduleCmdKeySpecAt(version, info->key_specs, j); if (j >= INT_MAX) { serverLog(LL_WARNING, "Invalid command info: Too many key specs"); @@ -2044,11 +2045,11 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { /* Flags. Exactly one flag in a group is set if and only if the * masked bits is a power of two. */ uint64_t key_flags = - REDISMODULE_CMD_KEY_RO | REDISMODULE_CMD_KEY_RW | - REDISMODULE_CMD_KEY_OW | REDISMODULE_CMD_KEY_RM; + VALKEYMODULE_CMD_KEY_RO | VALKEYMODULE_CMD_KEY_RW | + VALKEYMODULE_CMD_KEY_OW | VALKEYMODULE_CMD_KEY_RM; uint64_t write_flags = - REDISMODULE_CMD_KEY_INSERT | REDISMODULE_CMD_KEY_DELETE | - REDISMODULE_CMD_KEY_UPDATE; + VALKEYMODULE_CMD_KEY_INSERT | VALKEYMODULE_CMD_KEY_DELETE | + VALKEYMODULE_CMD_KEY_UPDATE; if (!isPowerOfTwo(spec->flags & key_flags)) { serverLog(LL_WARNING, "Invalid command info: key_specs[%zd].flags: " @@ -2065,9 +2066,9 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { } switch (spec->begin_search_type) { - case REDISMODULE_KSPEC_BS_UNKNOWN: break; - case REDISMODULE_KSPEC_BS_INDEX: break; - case REDISMODULE_KSPEC_BS_KEYWORD: + case VALKEYMODULE_KSPEC_BS_UNKNOWN: break; + case VALKEYMODULE_KSPEC_BS_INDEX: break; + case VALKEYMODULE_KSPEC_BS_KEYWORD: if (spec->bs.keyword.keyword == NULL) { serverLog(LL_WARNING, "Invalid command info: key_specs[%zd].bs.keyword.keyword " @@ -2084,10 +2085,10 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { /* Validate find_keys_type. */ switch (spec->find_keys_type) { - case REDISMODULE_KSPEC_FK_OMITTED: break; /* short for RANGE {0,1,0} */ - case REDISMODULE_KSPEC_FK_UNKNOWN: break; - case REDISMODULE_KSPEC_FK_RANGE: break; - case REDISMODULE_KSPEC_FK_KEYNUM: break; + case VALKEYMODULE_KSPEC_FK_OMITTED: break; /* short for RANGE {0,1,0} */ + case VALKEYMODULE_KSPEC_FK_UNKNOWN: break; + case VALKEYMODULE_KSPEC_FK_RANGE: break; + case VALKEYMODULE_KSPEC_FK_KEYNUM: break; default: serverLog(LL_WARNING, "Invalid command info: key_specs[%zd].find_keys_type: " @@ -2101,22 +2102,22 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { return moduleValidateCommandArgs(info->args, version); } -/* When from_api is true, converts from REDISMODULE_CMD_KEY_* flags to CMD_KEY_* flags. - * When from_api is false, converts from CMD_KEY_* flags to REDISMODULE_CMD_KEY_* flags. */ +/* When from_api is true, converts from VALKEYMODULE_CMD_KEY_* flags to CMD_KEY_* flags. + * When from_api is false, converts from CMD_KEY_* flags to VALKEYMODULE_CMD_KEY_* flags. */ static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api) { int64_t out = 0; int64_t map[][2] = { - {REDISMODULE_CMD_KEY_RO, CMD_KEY_RO}, - {REDISMODULE_CMD_KEY_RW, CMD_KEY_RW}, - {REDISMODULE_CMD_KEY_OW, CMD_KEY_OW}, - {REDISMODULE_CMD_KEY_RM, CMD_KEY_RM}, - {REDISMODULE_CMD_KEY_ACCESS, CMD_KEY_ACCESS}, - {REDISMODULE_CMD_KEY_INSERT, CMD_KEY_INSERT}, - {REDISMODULE_CMD_KEY_UPDATE, CMD_KEY_UPDATE}, - {REDISMODULE_CMD_KEY_DELETE, CMD_KEY_DELETE}, - {REDISMODULE_CMD_KEY_NOT_KEY, CMD_KEY_NOT_KEY}, - {REDISMODULE_CMD_KEY_INCOMPLETE, CMD_KEY_INCOMPLETE}, - {REDISMODULE_CMD_KEY_VARIABLE_FLAGS, CMD_KEY_VARIABLE_FLAGS}, + {VALKEYMODULE_CMD_KEY_RO, CMD_KEY_RO}, + {VALKEYMODULE_CMD_KEY_RW, CMD_KEY_RW}, + {VALKEYMODULE_CMD_KEY_OW, CMD_KEY_OW}, + {VALKEYMODULE_CMD_KEY_RM, CMD_KEY_RM}, + {VALKEYMODULE_CMD_KEY_ACCESS, CMD_KEY_ACCESS}, + {VALKEYMODULE_CMD_KEY_INSERT, CMD_KEY_INSERT}, + {VALKEYMODULE_CMD_KEY_UPDATE, CMD_KEY_UPDATE}, + {VALKEYMODULE_CMD_KEY_DELETE, CMD_KEY_DELETE}, + {VALKEYMODULE_CMD_KEY_NOT_KEY, CMD_KEY_NOT_KEY}, + {VALKEYMODULE_CMD_KEY_INCOMPLETE, CMD_KEY_INCOMPLETE}, + {VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS, CMD_KEY_VARIABLE_FLAGS}, {0,0}}; int from_idx = from_api ? 0 : 1, to_idx = !from_idx; @@ -2125,13 +2126,13 @@ static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api) { return out; } -/* Validates an array of RedisModuleCommandArg. Returns 1 if it's valid and 0 if +/* Validates an array of ValkeyModuleCommandArg. Returns 1 if it's valid and 0 if * it's invalid. */ -static int moduleValidateCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version) { +static int moduleValidateCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version) { if (args == NULL) return 1; /* Missing args is OK. */ for (size_t j = 0; moduleCmdArgAt(version, args, j)->name != NULL; j++) { - RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); + ValkeyModuleCommandArg *arg = moduleCmdArgAt(version, args, j); int arg_type_error = 0; moduleConvertArgType(arg->type, &arg_type_error); if (arg_type_error) { @@ -2140,14 +2141,14 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, arg->name, arg->type); return 0; } - if (arg->type == REDISMODULE_ARG_TYPE_PURE_TOKEN && !arg->token) { + if (arg->type == VALKEYMODULE_ARG_TYPE_PURE_TOKEN && !arg->token) { serverLog(LL_WARNING, "Invalid command info: Argument \"%s\": " "token required when type is PURE_TOKEN", args[j].name); return 0; } - if (arg->type == REDISMODULE_ARG_TYPE_KEY) { + if (arg->type == VALKEYMODULE_ARG_TYPE_KEY) { if (arg->key_spec_index < 0) { serverLog(LL_WARNING, "Invalid command info: Argument \"%s\": " @@ -2165,15 +2166,15 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, return 0; } - if (arg->flags & ~(_REDISMODULE_CMD_ARG_NEXT - 1)) { + if (arg->flags & ~(_VALKEYMODULE_CMD_ARG_NEXT - 1)) { serverLog(LL_WARNING, "Invalid command info: Argument \"%s\": Invalid flags", arg->name); return 0; } - if (arg->type == REDISMODULE_ARG_TYPE_ONEOF || - arg->type == REDISMODULE_ARG_TYPE_BLOCK) + if (arg->type == VALKEYMODULE_ARG_TYPE_ONEOF || + arg->type == VALKEYMODULE_ARG_TYPE_BLOCK) { if (arg->subargs == NULL) { serverLog(LL_WARNING, @@ -2196,20 +2197,20 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, return 1; } -/* Converts an array of RedisModuleCommandArg into a freshly allocated array of +/* Converts an array of ValkeyModuleCommandArg into a freshly allocated array of * struct serverCommandArg. */ -static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version) { +static struct serverCommandArg *moduleCopyCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version) { size_t count = 0; while (moduleCmdArgAt(version, args, count)->name) count++; serverAssert(count < SIZE_MAX / sizeof(struct serverCommandArg)); struct serverCommandArg *realargs = zcalloc((count+1) * sizeof(serverCommandArg)); for (size_t j = 0; j < count; j++) { - RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); + ValkeyModuleCommandArg *arg = moduleCmdArgAt(version, args, j); realargs[j].name = zstrdup(arg->name); realargs[j].type = moduleConvertArgType(arg->type, NULL); - if (arg->type == REDISMODULE_ARG_TYPE_KEY) + if (arg->type == VALKEYMODULE_ARG_TYPE_KEY) realargs[j].key_spec_index = arg->key_spec_index; else realargs[j].key_spec_index = -1; @@ -2224,18 +2225,18 @@ static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *arg return realargs; } -static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { +static serverCommandArgType moduleConvertArgType(ValkeyModuleCommandArgType type, int *error) { if (error) *error = 0; switch (type) { - case REDISMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; - case REDISMODULE_ARG_TYPE_INTEGER: return ARG_TYPE_INTEGER; - case REDISMODULE_ARG_TYPE_DOUBLE: return ARG_TYPE_DOUBLE; - case REDISMODULE_ARG_TYPE_KEY: return ARG_TYPE_KEY; - case REDISMODULE_ARG_TYPE_PATTERN: return ARG_TYPE_PATTERN; - case REDISMODULE_ARG_TYPE_UNIX_TIME: return ARG_TYPE_UNIX_TIME; - case REDISMODULE_ARG_TYPE_PURE_TOKEN: return ARG_TYPE_PURE_TOKEN; - case REDISMODULE_ARG_TYPE_ONEOF: return ARG_TYPE_ONEOF; - case REDISMODULE_ARG_TYPE_BLOCK: return ARG_TYPE_BLOCK; + case VALKEYMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; + case VALKEYMODULE_ARG_TYPE_INTEGER: return ARG_TYPE_INTEGER; + case VALKEYMODULE_ARG_TYPE_DOUBLE: return ARG_TYPE_DOUBLE; + case VALKEYMODULE_ARG_TYPE_KEY: return ARG_TYPE_KEY; + case VALKEYMODULE_ARG_TYPE_PATTERN: return ARG_TYPE_PATTERN; + case VALKEYMODULE_ARG_TYPE_UNIX_TIME: return ARG_TYPE_UNIX_TIME; + case VALKEYMODULE_ARG_TYPE_PURE_TOKEN: return ARG_TYPE_PURE_TOKEN; + case VALKEYMODULE_ARG_TYPE_ONEOF: return ARG_TYPE_ONEOF; + case VALKEYMODULE_ARG_TYPE_BLOCK: return ARG_TYPE_BLOCK; default: if (error) *error = 1; return -1; @@ -2244,24 +2245,24 @@ static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, static int moduleConvertArgFlags(int flags) { int realflags = 0; - if (flags & REDISMODULE_CMD_ARG_OPTIONAL) realflags |= CMD_ARG_OPTIONAL; - if (flags & REDISMODULE_CMD_ARG_MULTIPLE) realflags |= CMD_ARG_MULTIPLE; - if (flags & REDISMODULE_CMD_ARG_MULTIPLE_TOKEN) realflags |= CMD_ARG_MULTIPLE_TOKEN; + if (flags & VALKEYMODULE_CMD_ARG_OPTIONAL) realflags |= CMD_ARG_OPTIONAL; + if (flags & VALKEYMODULE_CMD_ARG_MULTIPLE) realflags |= CMD_ARG_MULTIPLE; + if (flags & VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN) realflags |= CMD_ARG_MULTIPLE_TOKEN; return realflags; } -/* Return `struct RedisModule *` as `void *` to avoid exposing it outside of module.c. */ +/* Return `struct ValkeyModule *` as `void *` to avoid exposing it outside of module.c. */ void *moduleGetHandleByName(char *modulename) { return dictFetchValue(modules,modulename); } /* Returns 1 if `cmd` is a command of the module `modulename`. 0 otherwise. */ int moduleIsModuleCommand(void *module_handle, struct serverCommand *cmd) { - if (cmd->proc != RedisModuleCommandDispatcher) + if (cmd->proc != ValkeyModuleCommandDispatcher) return 0; if (module_handle == NULL) return 0; - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; return (cp->module == module_handle); } @@ -2279,12 +2280,12 @@ void moduleListFree(void *config) { zfree(config); } -void RM_SetModuleAttribs(RedisModuleCtx *ctx, const char *name, int ver, int apiver) { - /* Called by RM_Init() to setup the `ctx->module` structure. +void VM_SetModuleAttribs(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) { + /* Called by VM_Init() to setup the `ctx->module` structure. * * This is an internal function, Redis modules developers don't need * to use it. */ - RedisModule *module; + ValkeyModule *module; if (ctx->module != NULL) return; module = zmalloc(sizeof(*module)); @@ -2313,7 +2314,7 @@ void RM_SetModuleAttribs(RedisModuleCtx *ctx, const char *name, int ver, int api /* Return non-zero if the module name is busy. * Otherwise zero is returned. */ -int RM_IsModuleNameBusy(const char *name) { +int VM_IsModuleNameBusy(const char *name) { sds modulename = sdsnew(name); dictEntry *de = dictFind(modules,modulename); sdsfree(modulename); @@ -2321,58 +2322,58 @@ int RM_IsModuleNameBusy(const char *name) { } /* Return the current UNIX time in milliseconds. */ -mstime_t RM_Milliseconds(void) { +mstime_t VM_Milliseconds(void) { return mstime(); } /* Return counter of micro-seconds relative to an arbitrary point in time. */ -uint64_t RM_MonotonicMicroseconds(void) { +uint64_t VM_MonotonicMicroseconds(void) { return getMonotonicUs(); } /* Return the current UNIX time in microseconds */ -ustime_t RM_Microseconds(void) { +ustime_t VM_Microseconds(void) { return ustime(); } /* Return the cached UNIX time in microseconds. * It is updated in the server cron job and before executing a command. * It is useful for complex call stacks, such as a command causing a - * key space notification, causing a module to execute a RedisModule_Call, + * key space notification, causing a module to execute a ValkeyModule_Call, * causing another notification, etc. * It makes sense that all this callbacks would use the same clock. */ -ustime_t RM_CachedMicroseconds(void) { +ustime_t VM_CachedMicroseconds(void) { return server.ustime; } /* Mark a point in time that will be used as the start time to calculate - * the elapsed execution time when RM_BlockedClientMeasureTimeEnd() is called. + * the elapsed execution time when VM_BlockedClientMeasureTimeEnd() is called. * Within the same command, you can call multiple times - * RM_BlockedClientMeasureTimeStart() and RM_BlockedClientMeasureTimeEnd() + * VM_BlockedClientMeasureTimeStart() and VM_BlockedClientMeasureTimeEnd() * to accumulate independent time intervals to the background duration. - * This method always return REDISMODULE_OK. + * This method always return VALKEYMODULE_OK. * * This function is not thread safe, If used in module thread and blocked callback (possibly main thread) * simultaneously, it's recommended to protect them with lock owned by caller instead of GIL. */ -int RM_BlockedClientMeasureTimeStart(RedisModuleBlockedClient *bc) { +int VM_BlockedClientMeasureTimeStart(ValkeyModuleBlockedClient *bc) { elapsedStart(&(bc->background_timer)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Mark a point in time that will be used as the end time * to calculate the elapsed execution time. - * On success REDISMODULE_OK is returned. - * This method only returns REDISMODULE_ERR if no start time was - * previously defined ( meaning RM_BlockedClientMeasureTimeStart was not called ). + * On success VALKEYMODULE_OK is returned. + * This method only returns VALKEYMODULE_ERR if no start time was + * previously defined ( meaning VM_BlockedClientMeasureTimeStart was not called ). * * This function is not thread safe, If used in module thread and blocked callback (possibly main thread) * simultaneously, it's recommended to protect them with lock owned by caller instead of GIL. */ -int RM_BlockedClientMeasureTimeEnd(RedisModuleBlockedClient *bc) { - // If the counter is 0 then we haven't called RM_BlockedClientMeasureTimeStart +int VM_BlockedClientMeasureTimeEnd(ValkeyModuleBlockedClient *bc) { + // If the counter is 0 then we haven't called VM_BlockedClientMeasureTimeStart if (!bc->background_timer) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; bc->background_duration += elapsedUs(bc->background_timer); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This API allows modules to let Redis process background tasks, and some @@ -2380,14 +2381,14 @@ int RM_BlockedClientMeasureTimeEnd(RedisModuleBlockedClient *bc) { * The module can call this API periodically. * The flags is a bit mask of these: * - * - `REDISMODULE_YIELD_FLAG_NONE`: No special flags, can perform some background + * - `VALKEYMODULE_YIELD_FLAG_NONE`: No special flags, can perform some background * operations, but not process client commands. - * - `REDISMODULE_YIELD_FLAG_CLIENTS`: Redis can also process client commands. + * - `VALKEYMODULE_YIELD_FLAG_CLIENTS`: Redis can also process client commands. * * The `busy_reply` argument is optional, and can be used to control the verbose * error string after the `-BUSY` error code. * - * When the `REDISMODULE_YIELD_FLAG_CLIENTS` is used, Redis will only start + * When the `VALKEYMODULE_YIELD_FLAG_CLIENTS` is used, Redis will only start * processing client commands after the time defined by the * `busy-reply-threshold` config, in which case Redis will start rejecting most * commands with `-BUSY` error, but allow the ones marked with the `allow-busy` @@ -2396,9 +2397,9 @@ int RM_BlockedClientMeasureTimeEnd(RedisModuleBlockedClient *bc) { * loading (in the `rdb_load` callback, in which case it'll reject commands with * the -LOADING error) */ -void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { +void VM_Yield(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) { static int yield_nesting = 0; - /* Avoid nested calls to RM_Yield */ + /* Avoid nested calls to VM_Yield */ if (yield_nesting) return; yield_nesting++; @@ -2421,7 +2422,7 @@ void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { if (server.current_client) protectClient(server.current_client); } - if (flags & REDISMODULE_YIELD_FLAG_CLIENTS) + if (flags & VALKEYMODULE_YIELD_FLAG_CLIENTS) server.busy_module_yield_flags |= BUSY_MODULE_YIELD_CLIENTS; /* Let redis process events */ @@ -2468,28 +2469,28 @@ void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { /* Set flags defining capabilities or behavior bit flags. * - * REDISMODULE_OPTIONS_HANDLE_IO_ERRORS: + * VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS: * Generally, modules don't need to bother with this, as the process will just * terminate if a read error happens, however, setting this flag would allow * repl-diskless-load to work if enabled. - * The module should use RedisModule_IsIOError after reads, before using the + * The module should use ValkeyModule_IsIOError after reads, before using the * data that was read, and in case of error, propagate it upwards, and also be * able to release the partially populated value and all it's allocations. * - * REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED: - * See RM_SignalModifiedKey(). + * VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED: + * See VM_SignalModifiedKey(). * - * REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD: + * VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD: * Setting this flag indicates module awareness of diskless async replication (repl-diskless-load=swapdb) * and that redis could be serving reads during replication instead of blocking with LOADING status. * - * REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS: + * VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS: * Declare that the module wants to get nested key-space notifications. * By default, Redis will not fire key-space notifications that happened inside * a key-space notification callback. This flag allows to change this behavior * and fire nested key-space notifications. Notice: if enabled, the module * should protected itself from infinite recursion. */ -void RM_SetModuleOptions(RedisModuleCtx *ctx, int options) { +void VM_SetModuleOptions(ValkeyModuleCtx *ctx, int options) { ctx->module->options = options; } @@ -2497,12 +2498,12 @@ void RM_SetModuleOptions(RedisModuleCtx *ctx, int options) { * and client side caching). * * This is done automatically when a key opened for writing is closed, unless - * the option REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED has been set using - * RM_SetModuleOptions(). + * the option VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED has been set using + * VM_SetModuleOptions(). */ -int RM_SignalModifiedKey(RedisModuleCtx *ctx, RedisModuleString *keyname) { +int VM_SignalModifiedKey(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) { signalModifiedKey(ctx->client,ctx->client->db,keyname); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -2518,19 +2519,19 @@ int RM_SignalModifiedKey(RedisModuleCtx *ctx, RedisModuleString *keyname) { * keys, call replies and Redis string objects once the command returns. In most * cases this eliminates the need of calling the following functions: * - * 1. RedisModule_CloseKey() - * 2. RedisModule_FreeCallReply() - * 3. RedisModule_FreeString() + * 1. ValkeyModule_CloseKey() + * 2. ValkeyModule_FreeCallReply() + * 3. ValkeyModule_FreeString() * * These functions can still be used with automatic memory management enabled, * to optimize loops that make numerous allocations for example. */ -void RM_AutoMemory(RedisModuleCtx *ctx) { - ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; +void VM_AutoMemory(ValkeyModuleCtx *ctx) { + ctx->flags |= VALKEYMODULE_CTX_AUTO_MEMORY; } /* Add a new object to release automatically when the callback returns. */ -void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { - if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; +void autoMemoryAdd(ValkeyModuleCtx *ctx, int type, void *ptr) { + if (!(ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY)) return; if (ctx->amqueue_used == ctx->amqueue_len) { ctx->amqueue_len *= 2; if (ctx->amqueue_len < 16) ctx->amqueue_len = 16; @@ -2546,8 +2547,8 @@ void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { * * The function returns 1 if the object was actually found in the auto memory * pool, otherwise 0 is returned. */ -int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { - if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return 0; +int autoMemoryFreed(ValkeyModuleCtx *ctx, int type, void *ptr) { + if (!(ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY)) return 0; int count = (ctx->amqueue_used+1)/2; for (int j = 0; j < count; j++) { @@ -2558,7 +2559,7 @@ int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { if (ctx->amqueue[i].type == type && ctx->amqueue[i].ptr == ptr) { - ctx->amqueue[i].type = REDISMODULE_AM_FREED; + ctx->amqueue[i].type = VALKEYMODULE_AM_FREED; /* Switch the freed element and the last element, to avoid growing * the queue unnecessarily if we allocate/free in a loop */ @@ -2577,24 +2578,24 @@ int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { } /* Release all the objects in queue. */ -void autoMemoryCollect(RedisModuleCtx *ctx) { - if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; +void autoMemoryCollect(ValkeyModuleCtx *ctx) { + if (!(ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY)) return; /* Clear the AUTO_MEMORY flag from the context, otherwise the functions * we call to free the resources, will try to scan the auto release * queue to mark the entries as freed. */ - ctx->flags &= ~REDISMODULE_CTX_AUTO_MEMORY; + ctx->flags &= ~VALKEYMODULE_CTX_AUTO_MEMORY; int j; for (j = 0; j < ctx->amqueue_used; j++) { void *ptr = ctx->amqueue[j].ptr; switch(ctx->amqueue[j].type) { - case REDISMODULE_AM_STRING: decrRefCount(ptr); break; - case REDISMODULE_AM_REPLY: RM_FreeCallReply(ptr); break; - case REDISMODULE_AM_KEY: RM_CloseKey(ptr); break; - case REDISMODULE_AM_DICT: RM_FreeDict(NULL,ptr); break; - case REDISMODULE_AM_INFO: RM_FreeServerInfo(NULL,ptr); break; + case VALKEYMODULE_AM_STRING: decrRefCount(ptr); break; + case VALKEYMODULE_AM_REPLY: VM_FreeCallReply(ptr); break; + case VALKEYMODULE_AM_KEY: VM_CloseKey(ptr); break; + case VALKEYMODULE_AM_DICT: VM_FreeDict(NULL,ptr); break; + case VALKEYMODULE_AM_INFO: VM_FreeServerInfo(NULL,ptr); break; } } - ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; + ctx->flags |= VALKEYMODULE_CTX_AUTO_MEMORY; zfree(ctx->amqueue); ctx->amqueue = NULL; ctx->amqueue_len = 0; @@ -2606,7 +2607,7 @@ void autoMemoryCollect(RedisModuleCtx *ctx) { * -------------------------------------------------------------------------- */ /* Create a new module string object. The returned string must be freed - * with RedisModule_FreeString(), unless automatic memory is enabled. + * with ValkeyModule_FreeString(), unless automatic memory is enabled. * * The string is created by copying the `len` bytes starting * at `ptr`. No reference is retained to the passed buffer. @@ -2615,21 +2616,21 @@ void autoMemoryCollect(RedisModuleCtx *ctx) { * a string out of the context scope. However in that case, the automatic * memory management will not be available, and the string memory must be * managed manually. */ -RedisModuleString *RM_CreateString(RedisModuleCtx *ctx, const char *ptr, size_t len) { - RedisModuleString *o = createStringObject(ptr,len); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); +ValkeyModuleString *VM_CreateString(ValkeyModuleCtx *ctx, const char *ptr, size_t len) { + ValkeyModuleString *o = createStringObject(ptr,len); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,o); return o; } /* Create a new module string object from a printf format and arguments. - * The returned string must be freed with RedisModule_FreeString(), unless + * The returned string must be freed with ValkeyModule_FreeString(), unless * automatic memory is enabled. * * The string is created using the sds formatter function sdscatvprintf(). * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringPrintf(RedisModuleCtx *ctx, const char *fmt, ...) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringPrintf(ValkeyModuleCtx *ctx, const char *fmt, ...) { sds s = sdsempty(); va_list ap; @@ -2637,90 +2638,90 @@ RedisModuleString *RM_CreateStringPrintf(RedisModuleCtx *ctx, const char *fmt, . s = sdscatvprintf(s, fmt, ap); va_end(ap); - RedisModuleString *o = createObject(OBJ_STRING, s); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); + ValkeyModuleString *o = createObject(OBJ_STRING, s); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,o); return o; } -/* Like RedisModule_CreateString(), but creates a string starting from a `long long` +/* Like ValkeyModule_CreateString(), but creates a string starting from a `long long` * integer instead of taking a buffer and its length. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromLongLong(RedisModuleCtx *ctx, long long ll) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromLongLong(ValkeyModuleCtx *ctx, long long ll) { char buf[LONG_STR_SIZE]; size_t len = ll2string(buf,sizeof(buf),ll); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a `unsigned long long` +/* Like ValkeyModule_CreateString(), but creates a string starting from a `unsigned long long` * integer instead of taking a buffer and its length. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromULongLong(RedisModuleCtx *ctx, unsigned long long ull) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromULongLong(ValkeyModuleCtx *ctx, unsigned long long ull) { char buf[LONG_STR_SIZE]; size_t len = ull2string(buf,sizeof(buf),ull); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a double +/* Like ValkeyModule_CreateString(), but creates a string starting from a double * instead of taking a buffer and its length. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. */ -RedisModuleString *RM_CreateStringFromDouble(RedisModuleCtx *ctx, double d) { +ValkeyModuleString *VM_CreateStringFromDouble(ValkeyModuleCtx *ctx, double d) { char buf[MAX_D2STRING_CHARS]; size_t len = d2string(buf,sizeof(buf),d); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a long +/* Like ValkeyModule_CreateString(), but creates a string starting from a long * double. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromLongDouble(RedisModuleCtx *ctx, long double ld, int humanfriendly) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromLongDouble(ValkeyModuleCtx *ctx, long double ld, int humanfriendly) { char buf[MAX_LONG_DOUBLE_CHARS]; size_t len = ld2string(buf,sizeof(buf),ld, (humanfriendly ? LD_STR_HUMAN : LD_STR_AUTO)); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from another - * RedisModuleString. +/* Like ValkeyModule_CreateString(), but creates a string starting from another + * ValkeyModuleString. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromString(RedisModuleCtx *ctx, const RedisModuleString *str) { - RedisModuleString *o = dupStringObject(str); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromString(ValkeyModuleCtx *ctx, const ValkeyModuleString *str) { + ValkeyModuleString *o = dupStringObject(str); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,o); return o; } /* Creates a string from a stream ID. The returned string must be released with - * RedisModule_FreeString(), unless automatic memory is enabled. + * ValkeyModule_FreeString(), unless automatic memory is enabled. * * The passed context `ctx` may be NULL if necessary. See the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromStreamID(RedisModuleCtx *ctx, const RedisModuleStreamID *id) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromStreamID(ValkeyModuleCtx *ctx, const ValkeyModuleStreamID *id) { streamID streamid = {id->ms, id->seq}; - RedisModuleString *o = createObjectFromStreamID(&streamid); - if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, o); + ValkeyModuleString *o = createObjectFromStreamID(&streamid); + if (ctx != NULL) autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, o); return o; } @@ -2739,16 +2740,16 @@ RedisModuleString *RM_CreateStringFromStreamID(RedisModuleCtx *ctx, const RedisM * * This API is not thread safe, access to these retained strings (if they originated * from a client command arguments) must be done with GIL locked. */ -void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) { +void VM_FreeString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { decrRefCount(str); - if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str); + if (ctx != NULL) autoMemoryFreed(ctx,VALKEYMODULE_AM_STRING,str); } /* Every call to this function, will make the string 'str' requiring - * an additional call to RedisModule_FreeString() in order to really + * an additional call to ValkeyModule_FreeString() in order to really * free the string. Note that the automatic freeing of the string obtained * enabling modules automatic memory management counts for one - * RedisModule_FreeString() call (it is just executed automatically). + * ValkeyModule_FreeString() call (it is just executed automatically). * * Normally you want to call this function when, at the same time * the following conditions are true: @@ -2770,7 +2771,7 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) { * It is possible to call this function with a NULL context. * * When strings are going to be retained for an extended duration, it is good - * practice to also call RedisModule_TrimStringAllocation() in order to + * practice to also call ValkeyModule_TrimStringAllocation() in order to * optimize memory usage. * * Threaded modules that reference retained strings from other threads *must* @@ -2779,8 +2780,8 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) { * * This API is not thread safe, access to these retained strings (if they originated * from a client command arguments) must be done with GIL locked. */ -void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { - if (ctx == NULL || !autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str)) { +void VM_RetainString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { + if (ctx == NULL || !autoMemoryFreed(ctx,VALKEYMODULE_AM_STRING,str)) { /* Increment the string reference counting only if we can't * just remove the object from the list of objects that should * be reclaimed. Why we do that, instead of just incrementing @@ -2789,33 +2790,33 @@ void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { * value? Because this way we ensure that the object refcount * value is 1 (instead of going to 2 to be dropped later to 1) * after the call to this function. This is needed for functions - * like RedisModule_StringAppendBuffer() to work. */ + * like ValkeyModule_StringAppendBuffer() to work. */ incrRefCount(str); } } /** -* This function can be used instead of RedisModule_RetainString(). +* This function can be used instead of ValkeyModule_RetainString(). * The main difference between the two is that this function will always -* succeed, whereas RedisModule_RetainString() may fail because of an +* succeed, whereas ValkeyModule_RetainString() may fail because of an * assertion. * -* The function returns a pointer to RedisModuleString, which is owned -* by the caller. It requires a call to RedisModule_FreeString() to free +* The function returns a pointer to ValkeyModuleString, which is owned +* by the caller. It requires a call to ValkeyModule_FreeString() to free * the string when automatic memory management is disabled for the context. * When automatic memory management is enabled, you can either call -* RedisModule_FreeString() or let the automation free it. +* ValkeyModule_FreeString() or let the automation free it. * -* This function is more efficient than RedisModule_CreateStringFromString() +* This function is more efficient than ValkeyModule_CreateStringFromString() * because whenever possible, it avoids copying the underlying -* RedisModuleString. The disadvantage of using this function is that it -* might not be possible to use RedisModule_StringAppendBuffer() on the -* returned RedisModuleString. +* ValkeyModuleString. The disadvantage of using this function is that it +* might not be possible to use ValkeyModule_StringAppendBuffer() on the +* returned ValkeyModuleString. * * It is possible to call this function with a NULL context. * * When strings are going to be held for an extended duration, it is good - * practice to also call RedisModule_TrimStringAllocation() in order to + * practice to also call ValkeyModule_TrimStringAllocation() in order to * optimize memory usage. * * Threaded modules that reference held strings from other threads *must* @@ -2824,9 +2825,9 @@ void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { * * This API is not thread safe, access to these retained strings (if they originated * from a client command arguments) must be done with GIL locked. */ -RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { +ValkeyModuleString* VM_HoldString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { if (str->refcount == OBJ_STATIC_REFCOUNT) { - return RM_CreateStringFromString(ctx, str); + return VM_CreateStringFromString(ctx, str); } incrRefCount(str); @@ -2838,27 +2839,27 @@ RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { * object in the auto memory free function. * * Why we can not do the same trick of just remove the object - * from the auto memory (like in RM_RetainString)? + * from the auto memory (like in VM_RetainString)? * This code shows the issue: * - * RM_AutoMemory(ctx); - * str1 = RM_CreateString(ctx, "test", 4); - * str2 = RM_HoldString(ctx, str1); - * RM_FreeString(str1); - * RM_FreeString(str2); + * VM_AutoMemory(ctx); + * str1 = VM_CreateString(ctx, "test", 4); + * str2 = VM_HoldString(ctx, str1); + * VM_FreeString(str1); + * VM_FreeString(str2); * - * If after the RM_HoldString we would just remove the string from + * If after the VM_HoldString we would just remove the string from * the auto memory, this example will cause access to a freed memory - * on 'RM_FreeString(str2);' because the String will be free - * on 'RM_FreeString(str1);'. + * on 'VM_FreeString(str2);' because the String will be free + * on 'VM_FreeString(str1);'. * * So it's safer to just increase the ref count * and add the String to auto memory again. * - * The limitation is that it is not possible to use RedisModule_StringAppendBuffer + * The limitation is that it is not possible to use ValkeyModule_StringAppendBuffer * on the String. */ - autoMemoryAdd(ctx,REDISMODULE_AM_STRING,str); + autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,str); } return str; } @@ -2866,7 +2867,7 @@ RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { /* Given a string module object, this function returns the string pointer * and length of the string. The returned pointer and length should only * be used for read only accesses and never modified. */ -const char *RM_StringPtrLen(const RedisModuleString *str, size_t *len) { +const char *VM_StringPtrLen(const ValkeyModuleString *str, size_t *len) { if (str == NULL) { const char *errmsg = "(NULL string reply referenced in module)"; if (len) *len = strlen(errmsg); @@ -2881,64 +2882,64 @@ const char *RM_StringPtrLen(const RedisModuleString *str, size_t *len) { * ------------------------------------------------------------------------- */ /* Convert the string into a `long long` integer, storing it at `*ll`. - * Returns REDISMODULE_OK on success. If the string can't be parsed - * as a valid, strict `long long` (no spaces before/after), REDISMODULE_ERR + * Returns VALKEYMODULE_OK on success. If the string can't be parsed + * as a valid, strict `long long` (no spaces before/after), VALKEYMODULE_ERR * is returned. */ -int RM_StringToLongLong(const RedisModuleString *str, long long *ll) { - return string2ll(str->ptr,sdslen(str->ptr),ll) ? REDISMODULE_OK : - REDISMODULE_ERR; +int VM_StringToLongLong(const ValkeyModuleString *str, long long *ll) { + return string2ll(str->ptr,sdslen(str->ptr),ll) ? VALKEYMODULE_OK : + VALKEYMODULE_ERR; } /* Convert the string into a `unsigned long long` integer, storing it at `*ull`. - * Returns REDISMODULE_OK on success. If the string can't be parsed - * as a valid, strict `unsigned long long` (no spaces before/after), REDISMODULE_ERR + * Returns VALKEYMODULE_OK on success. If the string can't be parsed + * as a valid, strict `unsigned long long` (no spaces before/after), VALKEYMODULE_ERR * is returned. */ -int RM_StringToULongLong(const RedisModuleString *str, unsigned long long *ull) { - return string2ull(str->ptr,ull) ? REDISMODULE_OK : REDISMODULE_ERR; +int VM_StringToULongLong(const ValkeyModuleString *str, unsigned long long *ull) { + return string2ull(str->ptr,ull) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Convert the string into a double, storing it at `*d`. - * Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is + * Returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if the string is * not a valid string representation of a double value. */ -int RM_StringToDouble(const RedisModuleString *str, double *d) { +int VM_StringToDouble(const ValkeyModuleString *str, double *d) { int retval = getDoubleFromObject(str,d); - return (retval == C_OK) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == C_OK) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Convert the string into a long double, storing it at `*ld`. - * Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is + * Returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if the string is * not a valid string representation of a double value. */ -int RM_StringToLongDouble(const RedisModuleString *str, long double *ld) { +int VM_StringToLongDouble(const ValkeyModuleString *str, long double *ld) { int retval = string2ld(str->ptr,sdslen(str->ptr),ld); - return retval ? REDISMODULE_OK : REDISMODULE_ERR; + return retval ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Convert the string into a stream ID, storing it at `*id`. - * Returns REDISMODULE_OK on success and returns REDISMODULE_ERR if the string + * Returns VALKEYMODULE_OK on success and returns VALKEYMODULE_ERR if the string * is not a valid string representation of a stream ID. The special IDs "+" and * "-" are allowed. */ -int RM_StringToStreamID(const RedisModuleString *str, RedisModuleStreamID *id) { +int VM_StringToStreamID(const ValkeyModuleString *str, ValkeyModuleStreamID *id) { streamID streamid; if (streamParseID(str, &streamid) == C_OK) { id->ms = streamid.ms; id->seq = streamid.seq; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* Compare two string objects, returning -1, 0 or 1 respectively if * a < b, a == b, a > b. Strings are compared byte by byte as two * binary blobs without any encoding care / collation attempt. */ -int RM_StringCompare(const RedisModuleString *a, const RedisModuleString *b) { +int VM_StringCompare(const ValkeyModuleString *a, const ValkeyModuleString *b) { return compareStringObjects(a,b); } /* Return the (possibly modified in encoding) input 'str' object if * the string is unshared, otherwise NULL is returned. */ -RedisModuleString *moduleAssertUnsharedString(RedisModuleString *str) { +ValkeyModuleString *moduleAssertUnsharedString(ValkeyModuleString *str) { if (str->refcount != 1) { serverLog(LL_WARNING, "Module attempted to use an in-place string modify operation " @@ -2961,18 +2962,18 @@ RedisModuleString *moduleAssertUnsharedString(RedisModuleString *str) { /* Append the specified buffer to the string 'str'. The string must be a * string created by the user that is referenced only a single time, otherwise - * REDISMODULE_ERR is returned and the operation is not performed. */ -int RM_StringAppendBuffer(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len) { + * VALKEYMODULE_ERR is returned and the operation is not performed. */ +int VM_StringAppendBuffer(ValkeyModuleCtx *ctx, ValkeyModuleString *str, const char *buf, size_t len) { UNUSED(ctx); str = moduleAssertUnsharedString(str); - if (str == NULL) return REDISMODULE_ERR; + if (str == NULL) return VALKEYMODULE_ERR; str->ptr = sdscatlen(str->ptr,buf,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Trim possible excess memory allocated for a RedisModuleString. +/* Trim possible excess memory allocated for a ValkeyModuleString. * - * Sometimes a RedisModuleString may have more memory allocated for + * Sometimes a ValkeyModuleString may have more memory allocated for * it than required, typically for argv arguments that were constructed * from network buffers. This function optimizes such strings by reallocating * their memory, which is useful for strings that are not short lived but @@ -2993,7 +2994,7 @@ int RM_StringAppendBuffer(RedisModuleCtx *ctx, RedisModuleString *str, const cha * in a race condition with the auto-trim, which could result with * data corruption. */ -void RM_TrimStringAllocation(RedisModuleString *str) { +void VM_TrimStringAllocation(ValkeyModuleString *str) { if (!str) return; trimStringObjectIfNeeded(str, 1); } @@ -3003,11 +3004,11 @@ void RM_TrimStringAllocation(RedisModuleString *str) { * * These functions are used for sending replies to the client. * - * Most functions always return REDISMODULE_OK so you can use it with + * Most functions always return VALKEYMODULE_OK so you can use it with * 'return' in order to return from the command implementation with: * * if (... some condition ...) - * return RedisModule_ReplyWithLongLong(ctx,mycount); + * return ValkeyModule_ReplyWithLongLong(ctx,mycount); * * ### Reply with collection functions * @@ -3017,24 +3018,24 @@ void RM_TrimStringAllocation(RedisModuleString *str) { * * When producing collections with a number of elements that is not known * beforehand, the function can be called with a special flag - * REDISMODULE_POSTPONED_LEN (REDISMODULE_POSTPONED_ARRAY_LEN in the past), - * and the actual number of elements can be later set with RM_ReplySet*Length() + * VALKEYMODULE_POSTPONED_LEN (VALKEYMODULE_POSTPONED_ARRAY_LEN in the past), + * and the actual number of elements can be later set with VM_ReplySet*Length() * call (which will set the latest "open" count if there are multiple ones). * -------------------------------------------------------------------------- */ /* Send an error about the number of arguments given to the command, - * citing the command name in the error message. Returns REDISMODULE_OK. + * citing the command name in the error message. Returns VALKEYMODULE_OK. * * Example: * - * if (argc != 3) return RedisModule_WrongArity(ctx); + * if (argc != 3) return ValkeyModule_WrongArity(ctx); */ -int RM_WrongArity(RedisModuleCtx *ctx) { +int VM_WrongArity(ValkeyModuleCtx *ctx) { addReplyErrorArity(ctx->client); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Return the client object the `RM_Reply*` functions should target. +/* Return the client object the `VM_Reply*` functions should target. * Normally this is just `ctx->client`, that is the client that called * the module command, however in the case of thread safe contexts there * is no directly associated client (since it would not be safe to access @@ -3048,8 +3049,8 @@ int RM_WrongArity(RedisModuleCtx *ctx) { * context of a thread safe context that was not initialized with a blocked * client object. Other contexts without associated clients are the ones * initialized to run the timers callbacks. */ -client *moduleGetReplyClient(RedisModuleCtx *ctx) { - if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) { +client *moduleGetReplyClient(ValkeyModuleCtx *ctx) { + if (ctx->flags & VALKEYMODULE_CTX_THREAD_SAFE) { if (ctx->blocked_client) return ctx->blocked_client->reply_client; else @@ -3064,12 +3065,12 @@ client *moduleGetReplyClient(RedisModuleCtx *ctx) { } /* Send an integer reply to the client, with the specified `long long` value. - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithLongLong(RedisModuleCtx *ctx, long long ll) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithLongLong(ValkeyModuleCtx *ctx, long long ll) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyLongLong(c,ll); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with the error 'err'. @@ -3078,19 +3079,19 @@ int RM_ReplyWithLongLong(RedisModuleCtx *ctx, long long ll) { * the initial error code. The function only provides the initial "-", so * the usage is, for example: * - * RedisModule_ReplyWithError(ctx,"ERR Wrong Type"); + * ValkeyModule_ReplyWithError(ctx,"ERR Wrong Type"); * * and not just: * - * RedisModule_ReplyWithError(ctx,"Wrong Type"); + * ValkeyModule_ReplyWithError(ctx,"Wrong Type"); * - * The function always returns REDISMODULE_OK. + * The function always returns VALKEYMODULE_OK. */ -int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) { +int VM_ReplyWithError(ValkeyModuleCtx *ctx, const char *err) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyErrorFormat(c,"-%s",err); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with the error create from a printf format and arguments. @@ -3099,17 +3100,17 @@ int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) { * the initial error code. The function only provides the initial "-", so * the usage is, for example: * - * RedisModule_ReplyWithErrorFormat(ctx,"ERR Wrong Type: %s",type); + * ValkeyModule_ReplyWithErrorFormat(ctx,"ERR Wrong Type: %s",type); * * and not just: * - * RedisModule_ReplyWithErrorFormat(ctx,"Wrong Type: %s",type); + * ValkeyModule_ReplyWithErrorFormat(ctx,"Wrong Type: %s",type); * - * The function always returns REDISMODULE_OK. + * The function always returns VALKEYMODULE_OK. */ -int RM_ReplyWithErrorFormat(RedisModuleCtx *ctx, const char *fmt, ...) { +int VM_ReplyWithErrorFormat(ValkeyModuleCtx *ctx, const char *fmt, ...) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; int len = strlen(fmt) + 2; /* 1 for the \0 and 1 for the hyphen */ char *hyphenfmt = zmalloc(len); @@ -3122,21 +3123,21 @@ int RM_ReplyWithErrorFormat(RedisModuleCtx *ctx, const char *fmt, ...) { zfree(hyphenfmt); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a simple string (`+... \r\n` in RESP protocol). This replies * are suitable only when sending a small non-binary string with small * overhead, like "OK" or similar replies. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithSimpleString(RedisModuleCtx *ctx, const char *msg) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithSimpleString(ValkeyModuleCtx *ctx, const char *msg) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyProto(c,"+",1); addReplyProto(c,msg,strlen(msg)); addReplyProto(c,"\r\n",2); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } #define COLLECTION_REPLY_ARRAY 1 @@ -3144,10 +3145,10 @@ int RM_ReplyWithSimpleString(RedisModuleCtx *ctx, const char *msg) { #define COLLECTION_REPLY_SET 3 #define COLLECTION_REPLY_ATTRIBUTE 4 -int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { +int moduleReplyWithCollection(ValkeyModuleCtx *ctx, long len, int type) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; - if (len == REDISMODULE_POSTPONED_LEN) { + if (c == NULL) return VALKEYMODULE_OK; + if (len == VALKEYMODULE_POSTPONED_LEN) { ctx->postponed_arrays = zrealloc(ctx->postponed_arrays,sizeof(void*)* (ctx->postponed_arrays_count+1)); ctx->postponed_arrays[ctx->postponed_arrays_count] = @@ -3187,7 +3188,7 @@ int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { serverPanic("Invalid module reply type %d", type); } } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with an array type of 'len' elements. @@ -3196,10 +3197,10 @@ int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { * `ReplyWith*` style functions in order to emit the elements of the array. * See Reply APIs section for more details. * - * Use RM_ReplySetArrayLength() to set deferred length. + * Use VM_ReplySetArrayLength() to set deferred length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithArray(ValkeyModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ARRAY); } @@ -3213,10 +3214,10 @@ int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { * If the connected client is using RESP2, the reply will be converted to a flat * array. * - * Use RM_ReplySetMapLength() to set deferred length. + * Use VM_ReplySetMapLength() to set deferred length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithMap(RedisModuleCtx *ctx, long len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithMap(ValkeyModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_MAP); } @@ -3230,10 +3231,10 @@ int RM_ReplyWithMap(RedisModuleCtx *ctx, long len) { * If the connected client is using RESP2, the reply will be converted to an * array type. * - * Use RM_ReplySetSetLength() to set deferred length. + * Use VM_ReplySetSetLength() to set deferred length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithSet(RedisModuleCtx *ctx, long len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithSet(ValkeyModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_SET); } @@ -3245,12 +3246,12 @@ int RM_ReplyWithSet(RedisModuleCtx *ctx, long len) { * `ReplyWith*` style functions in order to emit the elements of the attribute map. * See Reply APIs section for more details. * - * Use RM_ReplySetAttributeLength() to set deferred length. + * Use VM_ReplySetAttributeLength() to set deferred length. * - * Not supported by RESP2 and will return REDISMODULE_ERR, otherwise - * the function always returns REDISMODULE_OK. */ -int RM_ReplyWithAttribute(RedisModuleCtx *ctx, long len) { - if (ctx->client->resp == 2) return REDISMODULE_ERR; + * Not supported by RESP2 and will return VALKEYMODULE_ERR, otherwise + * the function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithAttribute(ValkeyModuleCtx *ctx, long len) { + if (ctx->client->resp == 2) return VALKEYMODULE_ERR; return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ATTRIBUTE); } @@ -3260,34 +3261,34 @@ int RM_ReplyWithAttribute(RedisModuleCtx *ctx, long len) { * * Note: In RESP3 there's no difference between Null reply and * NullArray reply, so to prevent ambiguity it's better to avoid - * using this API and use RedisModule_ReplyWithNull instead. + * using this API and use ValkeyModule_ReplyWithNull instead. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithNullArray(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithNullArray(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyNullArray(c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply to the client with an empty array. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithEmptyArray(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithEmptyArray(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReply(c,shared.emptyarray); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { +void moduleReplySetCollectionLength(ValkeyModuleCtx *ctx, long len, int type) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return; if (ctx->postponed_arrays_count == 0) { serverLog(LL_WARNING, "API misuse detected in module %s: " - "RedisModule_ReplySet*Length() called without previous " - "RedisModule_ReplyWith*(ctx,REDISMODULE_POSTPONED_LEN) " + "ValkeyModule_ReplySet*Length() called without previous " + "ValkeyModule_ReplyWith*(ctx,VALKEYMODULE_POSTPONED_LEN) " "call.", ctx->module->name); return; } @@ -3314,8 +3315,8 @@ void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { } } -/* When RedisModule_ReplyWithArray() is used with the argument - * REDISMODULE_POSTPONED_LEN, because we don't know beforehand the number +/* When ValkeyModule_ReplyWithArray() is used with the argument + * VALKEYMODULE_POSTPONED_LEN, because we don't know beforehand the number * of items we are going to output as elements of the array, this function * will take care to set the array length. * @@ -3326,115 +3327,115 @@ void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { * For example in order to output an array like [1,[10,20,30]] we * could write: * - * RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); - * RedisModule_ReplyWithLongLong(ctx,1); - * RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); - * RedisModule_ReplyWithLongLong(ctx,10); - * RedisModule_ReplyWithLongLong(ctx,20); - * RedisModule_ReplyWithLongLong(ctx,30); - * RedisModule_ReplySetArrayLength(ctx,3); // Set len of 10,20,30 array. - * RedisModule_ReplySetArrayLength(ctx,2); // Set len of top array + * ValkeyModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); + * ValkeyModule_ReplyWithLongLong(ctx,1); + * ValkeyModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); + * ValkeyModule_ReplyWithLongLong(ctx,10); + * ValkeyModule_ReplyWithLongLong(ctx,20); + * ValkeyModule_ReplyWithLongLong(ctx,30); + * ValkeyModule_ReplySetArrayLength(ctx,3); // Set len of 10,20,30 array. + * ValkeyModule_ReplySetArrayLength(ctx,2); // Set len of top array * * Note that in the above example there is no reason to postpone the array * length, since we produce a fixed number of elements, but in the practice * the code may use an iterator or other ways of creating the output so * that is not easy to calculate in advance the number of elements. */ -void RM_ReplySetArrayLength(RedisModuleCtx *ctx, long len) { +void VM_ReplySetArrayLength(ValkeyModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ARRAY); } -/* Very similar to RedisModule_ReplySetArrayLength except `len` should +/* Very similar to ValkeyModule_ReplySetArrayLength except `len` should * exactly half of the number of `ReplyWith*` functions called in the * context of the map. * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. */ -void RM_ReplySetMapLength(RedisModuleCtx *ctx, long len) { +void VM_ReplySetMapLength(ValkeyModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_MAP); } -/* Very similar to RedisModule_ReplySetArrayLength +/* Very similar to ValkeyModule_ReplySetArrayLength * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. */ -void RM_ReplySetSetLength(RedisModuleCtx *ctx, long len) { +void VM_ReplySetSetLength(ValkeyModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_SET); } -/* Very similar to RedisModule_ReplySetMapLength +/* Very similar to ValkeyModule_ReplySetMapLength * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. * - * Must not be called if RM_ReplyWithAttribute returned an error. */ -void RM_ReplySetAttributeLength(RedisModuleCtx *ctx, long len) { + * Must not be called if VM_ReplyWithAttribute returned an error. */ +void VM_ReplySetAttributeLength(ValkeyModuleCtx *ctx, long len) { if (ctx->client->resp == 2) return; moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ATTRIBUTE); } /* Reply with a bulk string, taking in input a C buffer pointer and length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithStringBuffer(RedisModuleCtx *ctx, const char *buf, size_t len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithStringBuffer(ValkeyModuleCtx *ctx, const char *buf, size_t len) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBulkCBuffer(c,(char*)buf,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a bulk string, taking in input a C buffer pointer that is * assumed to be null-terminated. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithCString(RedisModuleCtx *ctx, const char *buf) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithCString(ValkeyModuleCtx *ctx, const char *buf) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBulkCString(c,(char*)buf); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Reply with a bulk string, taking in input a RedisModuleString object. +/* Reply with a bulk string, taking in input a ValkeyModuleString object. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithString(RedisModuleCtx *ctx, RedisModuleString *str) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBulk(c,str); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with an empty string. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithEmptyString(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithEmptyString(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReply(c,shared.emptybulk); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a binary safe string, which should not be escaped or filtered * taking in input a C buffer pointer, length and a 3 character type/extension. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithVerbatimStringType(RedisModuleCtx *ctx, const char *buf, size_t len, const char *ext) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithVerbatimStringType(ValkeyModuleCtx *ctx, const char *buf, size_t len, const char *ext) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyVerbatim(c, buf, len, ext); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a binary safe string, which should not be escaped or filtered * taking in input a C buffer pointer and length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithVerbatimString(RedisModuleCtx *ctx, const char *buf, size_t len) { - return RM_ReplyWithVerbatimStringType(ctx, buf, len, "txt"); + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithVerbatimString(ValkeyModuleCtx *ctx, const char *buf, size_t len) { + return VM_ReplyWithVerbatimStringType(ctx, buf, len, "txt"); } /* Reply to the client with a NULL. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithNull(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithNull(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyNull(c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a RESP3 Boolean type. @@ -3443,34 +3444,34 @@ int RM_ReplyWithNull(RedisModuleCtx *ctx) { * In RESP3, this is boolean type * In RESP2, it's a string response of "1" and "0" for true and false respectively. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithBool(RedisModuleCtx *ctx, int b) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithBool(ValkeyModuleCtx *ctx, int b) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBool(c,b); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Reply exactly what a Redis command returned us with RedisModule_Call(). - * This function is useful when we use RedisModule_Call() in order to +/* Reply exactly what a Redis command returned us with ValkeyModule_Call(). + * This function is useful when we use ValkeyModule_Call() in order to * execute some command, as we want to reply to the client exactly the * same reply we obtained by the command. * * Return: - * - REDISMODULE_OK on success. - * - REDISMODULE_ERR if the given reply is in RESP3 format but the client expects RESP2. + * - VALKEYMODULE_OK on success. + * - VALKEYMODULE_ERR if the given reply is in RESP3 format but the client expects RESP2. * In case of an error, it's the module writer responsibility to translate the reply * to RESP2 (or handle it differently by returning an error). Notice that for * module writer convenience, it is possible to pass `0` as a parameter to the fmt - * argument of `RM_Call` so that the RedisModuleCallReply will return in the same + * argument of `VM_Call` so that the ValkeyModuleCallReply will return in the same * protocol (RESP2 or RESP3) as set in the current client's context. */ -int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { +int VM_ReplyWithCallReply(ValkeyModuleCtx *ctx, ValkeyModuleCallReply *reply) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; if (c->resp == 2 && callReplyIsResp3(reply)) { /* The reply is in RESP3 format and the client is RESP2, * so it isn't possible to send this reply to the client. */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } size_t proto_len; const char *proto = callReplyGetProto(reply, &proto_len); @@ -3484,7 +3485,7 @@ int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { list *errors = callReplyDeferredErrorList(reply); if (errors) deferredAfterErrorReply(c, errors); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a RESP3 Double type. @@ -3493,17 +3494,17 @@ int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { * Send a string reply obtained converting the double 'd' into a bulk string. * This function is basically equivalent to converting a double into * a string into a C buffer, and then calling the function - * RedisModule_ReplyWithStringBuffer() with the buffer and length. + * ValkeyModule_ReplyWithStringBuffer() with the buffer and length. * * In RESP3 the string is tagged as a double, while in RESP2 it's just a plain string * that the user will have to parse. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithDouble(ValkeyModuleCtx *ctx, double d) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyDouble(c,d); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a RESP3 BigNumber type. @@ -3513,27 +3514,27 @@ int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) { * however, it's up to the caller to ensure that it's a valid BigNumber. * In RESP2, this is just a plain bulk string response. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithBigNumber(RedisModuleCtx *ctx, const char *bignum, size_t len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithBigNumber(ValkeyModuleCtx *ctx, const char *bignum, size_t len) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBigNum(c, bignum, len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Send a string reply obtained converting the long double 'ld' into a bulk * string. This function is basically equivalent to converting a long double * into a string into a C buffer, and then calling the function - * RedisModule_ReplyWithStringBuffer() with the buffer and length. + * ValkeyModule_ReplyWithStringBuffer() with the buffer and length. * The double string uses human readable formatting (see * `addReplyHumanLongDouble` in networking.c). * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithLongDouble(ValkeyModuleCtx *ctx, long double ld) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyHumanLongDouble(c, ld); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -3545,17 +3546,17 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { * * The replicated commands are always wrapped into the MULTI/EXEC that * contains all the commands replicated in a given module command - * execution. However the commands replicated with RedisModule_Call() - * are the first items, the ones replicated with RedisModule_Replicate() + * execution. However the commands replicated with ValkeyModule_Call() + * are the first items, the ones replicated with ValkeyModule_Replicate() * will all follow before the EXEC. * * Modules should try to use one interface or the other. * - * This command follows exactly the same interface of RedisModule_Call(), + * This command follows exactly the same interface of ValkeyModule_Call(), * so a set of format specifiers must be passed, followed by arguments * matching the provided format specifiers. * - * Please refer to RedisModule_Call() for more information. + * Please refer to ValkeyModule_Call() for more information. * * Using the special "A" and "R" modifiers, the caller can exclude either * the AOF or the replicas from the propagation of the specified command. @@ -3575,29 +3576,29 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { * * #### Return value * - * The command returns REDISMODULE_ERR if the format specifiers are invalid + * The command returns VALKEYMODULE_ERR if the format specifiers are invalid * or the command name does not belong to a known command. */ -int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { +int VM_Replicate(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { struct serverCommand *cmd; robj **argv = NULL; int argc = 0, flags = 0, j; va_list ap; cmd = lookupCommandByCString((char*)cmdname); - if (!cmd) return REDISMODULE_ERR; + if (!cmd) return VALKEYMODULE_ERR; /* Create the client and dispatch the command. */ va_start(ap, fmt); argv = moduleCreateArgvFromUserFormat(cmdname,fmt,&argc,&flags,ap); va_end(ap); - if (argv == NULL) return REDISMODULE_ERR; + if (argv == NULL) return VALKEYMODULE_ERR; /* Select the propagation target. Usually is AOF + replicas, however * the caller can exclude one or the other using the "A" or "R" * modifiers. */ int target = 0; - if (!(flags & REDISMODULE_ARGV_NO_AOF)) target |= PROPAGATE_AOF; - if (!(flags & REDISMODULE_ARGV_NO_REPLICAS)) target |= PROPAGATE_REPL; + if (!(flags & VALKEYMODULE_ARGV_NO_AOF)) target |= PROPAGATE_AOF; + if (!(flags & VALKEYMODULE_ARGV_NO_REPLICAS)) target |= PROPAGATE_REPL; alsoPropagate(ctx->client->db->id,argv,argc,target); @@ -3605,7 +3606,7 @@ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) for (j = 0; j < argc; j++) decrRefCount(argv[j]); zfree(argv); server.dirty++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This function will replicate the command exactly as it was invoked @@ -3618,13 +3619,13 @@ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) * the command can just be re-executed to deterministically re-create the * new state starting from the old one. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplicateVerbatim(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplicateVerbatim(ValkeyModuleCtx *ctx) { alsoPropagate(ctx->client->db->id, ctx->client->argv,ctx->client->argc, PROPAGATE_AOF|PROPAGATE_REPL); server.dirty++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -3646,20 +3647,20 @@ int RM_ReplicateVerbatim(RedisModuleCtx *ctx) { * After obtaining the ID, it is possible to check if the command execution * is actually happening in the context of AOF loading, using this macro: * - * if (RedisModule_IsAOFClient(RedisModule_GetClientId(ctx)) { + * if (ValkeyModule_IsAOFClient(ValkeyModule_GetClientId(ctx)) { * // Handle it differently. * } */ -unsigned long long RM_GetClientId(RedisModuleCtx *ctx) { +unsigned long long VM_GetClientId(ValkeyModuleCtx *ctx) { if (ctx->client == NULL) return 0; return ctx->client->id; } /* Return the ACL user name used by the client with the specified client ID. - * Client ID can be obtained with RM_GetClientId() API. If the client does not + * Client ID can be obtained with VM_GetClientId() API. If the client does not * exist, NULL is returned and errno is set to ENOENT. If the client isn't * using an ACL user, NULL is returned and errno is set to ENOTSUP */ -RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { +ValkeyModuleString *VM_GetClientUserNameById(ValkeyModuleCtx *ctx, uint64_t id) { client *client = lookupClientByID(id); if (client == NULL) { errno = ENOENT; @@ -3673,52 +3674,52 @@ RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { sds name = sdsnew(client->user->name); robj *str = createObject(OBJ_STRING, name); - autoMemoryAdd(ctx, REDISMODULE_AM_STRING, str); + autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, str); return str; } -/* This is a helper for RM_GetClientInfoById() and other functions: given +/* This is a helper for VM_GetClientInfoById() and other functions: given * a client, it populates the client info structure with the appropriate * fields depending on the version provided. If the version is not valid - * then REDISMODULE_ERR is returned. Otherwise the function returns - * REDISMODULE_OK and the structure pointed by 'ci' gets populated. */ + * then VALKEYMODULE_ERR is returned. Otherwise the function returns + * VALKEYMODULE_OK and the structure pointed by 'ci' gets populated. */ int modulePopulateClientInfoStructure(void *ci, client *client, int structver) { - if (structver != 1) return REDISMODULE_ERR; + if (structver != 1) return VALKEYMODULE_ERR; - RedisModuleClientInfoV1 *ci1 = ci; + ValkeyModuleClientInfoV1 *ci1 = ci; memset(ci1,0,sizeof(*ci1)); ci1->version = structver; if (client->flags & CLIENT_MULTI) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_MULTI; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_MULTI; if (client->flags & CLIENT_PUBSUB) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_PUBSUB; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB; if (client->flags & CLIENT_UNIX_SOCKET) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET; if (client->flags & CLIENT_TRACKING) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_TRACKING; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_TRACKING; if (client->flags & CLIENT_BLOCKED) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_BLOCKED; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED; if (client->conn->type == connectionTypeTls()) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_SSL; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_SSL; int port; connAddrPeerName(client->conn,ci1->addr,sizeof(ci1->addr),&port); ci1->port = port; ci1->db = client->db->id; ci1->id = client->id; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is a helper for moduleFireServerEvent() and other functions: * It populates the replication info structure with the appropriate * fields depending on the version provided. If the version is not valid - * then REDISMODULE_ERR is returned. Otherwise the function returns - * REDISMODULE_OK and the structure pointed by 'ri' gets populated. */ + * then VALKEYMODULE_ERR is returned. Otherwise the function returns + * VALKEYMODULE_OK and the structure pointed by 'ri' gets populated. */ int modulePopulateReplicationInfoStructure(void *ri, int structver) { - if (structver != 1) return REDISMODULE_ERR; + if (structver != 1) return VALKEYMODULE_ERR; - RedisModuleReplicationInfoV1 *ri1 = ri; + ValkeyModuleReplicationInfoV1 *ri1 = ri; memset(ri1,0,sizeof(*ri1)); ri1->version = structver; ri1->master = server.masterhost==NULL; @@ -3728,20 +3729,20 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { ri1->replid2 = server.replid2; ri1->repl1_offset = server.master_repl_offset; ri1->repl2_offset = server.second_replid_offset; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return information about the client with the specified ID (that was - * previously obtained via the RedisModule_GetClientId() API). If the - * client exists, REDISMODULE_OK is returned, otherwise REDISMODULE_ERR + * previously obtained via the ValkeyModule_GetClientId() API). If the + * client exists, VALKEYMODULE_OK is returned, otherwise VALKEYMODULE_ERR * is returned. * * When the client exist and the `ci` pointer is not NULL, but points to - * a structure of type RedisModuleClientInfoV1, previously initialized with - * the correct REDISMODULE_CLIENTINFO_INITIALIZER_V1, the structure is populated + * a structure of type ValkeyModuleClientInfoV1, previously initialized with + * the correct VALKEYMODULE_CLIENTINFO_INITIALIZER_V1, the structure is populated * with the following fields: * - * uint64_t flags; // REDISMODULE_CLIENTINFO_FLAG_* + * uint64_t flags; // VALKEYMODULE_CLIENTINFO_FLAG_* * uint64_t id; // Client ID * char addr[46]; // IPv4 or IPv6 address. * uint16_t port; // TCP port. @@ -3754,12 +3755,12 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { * * With flags having the following meaning: * - * REDISMODULE_CLIENTINFO_FLAG_SSL Client using SSL connection. - * REDISMODULE_CLIENTINFO_FLAG_PUBSUB Client in Pub/Sub mode. - * REDISMODULE_CLIENTINFO_FLAG_BLOCKED Client blocked in command. - * REDISMODULE_CLIENTINFO_FLAG_TRACKING Client with keys tracking on. - * REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET Client using unix domain socket. - * REDISMODULE_CLIENTINFO_FLAG_MULTI Client in MULTI state. + * VALKEYMODULE_CLIENTINFO_FLAG_SSL Client using SSL connection. + * VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB Client in Pub/Sub mode. + * VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED Client blocked in command. + * VALKEYMODULE_CLIENTINFO_FLAG_TRACKING Client with keys tracking on. + * VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET Client using unix domain socket. + * VALKEYMODULE_CLIENTINFO_FLAG_MULTI Client in MULTI state. * * However passing NULL is a way to just check if the client exists in case * we are not interested in any additional information. @@ -3767,16 +3768,16 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { * This is the correct usage when we want the client info structure * returned: * - * RedisModuleClientInfo ci = REDISMODULE_CLIENTINFO_INITIALIZER; - * int retval = RedisModule_GetClientInfoById(&ci,client_id); - * if (retval == REDISMODULE_OK) { + * ValkeyModuleClientInfo ci = VALKEYMODULE_CLIENTINFO_INITIALIZER; + * int retval = ValkeyModule_GetClientInfoById(&ci,client_id); + * if (retval == VALKEYMODULE_OK) { * printf("Address: %s\n", ci.addr); * } */ -int RM_GetClientInfoById(void *ci, uint64_t id) { +int VM_GetClientInfoById(void *ci, uint64_t id) { client *client = lookupClientByID(id); - if (client == NULL) return REDISMODULE_ERR; - if (ci == NULL) return REDISMODULE_OK; + if (client == NULL) return VALKEYMODULE_ERR; + if (ci == NULL) return VALKEYMODULE_OK; /* Fill the info structure if passed. */ uint64_t structver = ((uint64_t*)ci)[0]; @@ -3787,50 +3788,50 @@ int RM_GetClientInfoById(void *ci, uint64_t id) { * * If the client ID does not exist or if the client has no name associated with * it, NULL is returned. */ -RedisModuleString *RM_GetClientNameById(RedisModuleCtx *ctx, uint64_t id) { +ValkeyModuleString *VM_GetClientNameById(ValkeyModuleCtx *ctx, uint64_t id) { client *client = lookupClientByID(id); if (client == NULL || client->name == NULL) return NULL; robj *name = client->name; incrRefCount(name); - autoMemoryAdd(ctx, REDISMODULE_AM_STRING, name); + autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, name); return name; } /* Sets the name of the client with the given ID. This is equivalent to the client calling * `CLIENT SETNAME name`. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and errno is set as follows: * * - ENOENT if the client does not exist * - EINVAL if the name contains invalid characters */ -int RM_SetClientNameById(uint64_t id, RedisModuleString *name) { +int VM_SetClientNameById(uint64_t id, ValkeyModuleString *name) { client *client = lookupClientByID(id); if (client == NULL) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (clientSetName(client, name, NULL) == C_ERR) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Publish a message to subscribers (see PUBLISH command). */ -int RM_PublishMessage(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) { +int VM_PublishMessage(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) { UNUSED(ctx); return pubsubPublishMessageAndPropagateToCluster(channel, message, 0); } /* Publish a message to shard-subscribers (see SPUBLISH command). */ -int RM_PublishMessageShard(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) { +int VM_PublishMessageShard(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) { UNUSED(ctx); return pubsubPublishMessageAndPropagateToCluster(channel, message, 1); } /* Return the currently selected DB. */ -int RM_GetSelectedDb(RedisModuleCtx *ctx) { +int VM_GetSelectedDb(ValkeyModuleCtx *ctx) { return ctx->client->db->id; } @@ -3846,151 +3847,151 @@ int RM_GetSelectedDb(RedisModuleCtx *ctx) { * * Available flags and their meaning: * - * * REDISMODULE_CTX_FLAGS_LUA: The command is running in a Lua script + * * VALKEYMODULE_CTX_FLAGS_LUA: The command is running in a Lua script * - * * REDISMODULE_CTX_FLAGS_MULTI: The command is running inside a transaction + * * VALKEYMODULE_CTX_FLAGS_MULTI: The command is running inside a transaction * - * * REDISMODULE_CTX_FLAGS_REPLICATED: The command was sent over the replication + * * VALKEYMODULE_CTX_FLAGS_REPLICATED: The command was sent over the replication * link by the MASTER * - * * REDISMODULE_CTX_FLAGS_MASTER: The Redis instance is a master + * * VALKEYMODULE_CTX_FLAGS_PRIMARY: The Redis instance is a primary * - * * REDISMODULE_CTX_FLAGS_SLAVE: The Redis instance is a slave + * * VALKEYMODULE_CTX_FLAGS_REPLICA: The Redis instance is a replica * - * * REDISMODULE_CTX_FLAGS_READONLY: The Redis instance is read-only + * * VALKEYMODULE_CTX_FLAGS_READONLY: The Redis instance is read-only * - * * REDISMODULE_CTX_FLAGS_CLUSTER: The Redis instance is in cluster mode + * * VALKEYMODULE_CTX_FLAGS_CLUSTER: The Redis instance is in cluster mode * - * * REDISMODULE_CTX_FLAGS_AOF: The Redis instance has AOF enabled + * * VALKEYMODULE_CTX_FLAGS_AOF: The Redis instance has AOF enabled * - * * REDISMODULE_CTX_FLAGS_RDB: The instance has RDB enabled + * * VALKEYMODULE_CTX_FLAGS_RDB: The instance has RDB enabled * - * * REDISMODULE_CTX_FLAGS_MAXMEMORY: The instance has Maxmemory set + * * VALKEYMODULE_CTX_FLAGS_MAXMEMORY: The instance has Maxmemory set * - * * REDISMODULE_CTX_FLAGS_EVICT: Maxmemory is set and has an eviction + * * VALKEYMODULE_CTX_FLAGS_EVICT: Maxmemory is set and has an eviction * policy that may delete keys * - * * REDISMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the + * * VALKEYMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the * maxmemory setting. * - * * REDISMODULE_CTX_FLAGS_OOM_WARNING: Less than 25% of memory remains before + * * VALKEYMODULE_CTX_FLAGS_OOM_WARNING: Less than 25% of memory remains before * reaching the maxmemory level. * - * * REDISMODULE_CTX_FLAGS_LOADING: Server is loading RDB/AOF + * * VALKEYMODULE_CTX_FLAGS_LOADING: Server is loading RDB/AOF * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE: No active link with the master. + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE: No active link with the master. * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING: The replica is trying to + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING: The replica is trying to * connect with the master. * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING: Master -> Replica RDB + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING: Master -> Replica RDB * transfer is in progress. * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE: The replica has an active link + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE: The replica has an active link * with its master. This is the * contrary of STALE state. * - * * REDISMODULE_CTX_FLAGS_ACTIVE_CHILD: There is currently some background + * * VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD: There is currently some background * process active (RDB, AUX or module). * - * * REDISMODULE_CTX_FLAGS_MULTI_DIRTY: The next EXEC will fail due to dirty + * * VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY: The next EXEC will fail due to dirty * CAS (touched keys). * - * * REDISMODULE_CTX_FLAGS_IS_CHILD: Redis is currently running inside + * * VALKEYMODULE_CTX_FLAGS_IS_CHILD: Redis is currently running inside * background child process. * - * * REDISMODULE_CTX_FLAGS_RESP3: Indicate the that client attached to this + * * VALKEYMODULE_CTX_FLAGS_RESP3: Indicate the that client attached to this * context is using RESP3. * - * * REDISMODULE_CTX_FLAGS_SERVER_STARTUP: The Redis instance is starting + * * VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP: The Redis instance is starting */ -int RM_GetContextFlags(RedisModuleCtx *ctx) { +int VM_GetContextFlags(ValkeyModuleCtx *ctx) { int flags = 0; /* Client specific flags */ if (ctx) { if (ctx->client) { if (ctx->client->flags & CLIENT_DENY_BLOCKING) - flags |= REDISMODULE_CTX_FLAGS_DENY_BLOCKING; + flags |= VALKEYMODULE_CTX_FLAGS_DENY_BLOCKING; /* Module command received from MASTER, is replicated. */ if (ctx->client->flags & CLIENT_MASTER) - flags |= REDISMODULE_CTX_FLAGS_REPLICATED; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICATED; if (ctx->client->resp == 3) { - flags |= REDISMODULE_CTX_FLAGS_RESP3; + flags |= VALKEYMODULE_CTX_FLAGS_RESP3; } } /* For DIRTY flags, we need the blocked client if used */ client *c = ctx->blocked_client ? ctx->blocked_client->client : ctx->client; if (c && (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))) { - flags |= REDISMODULE_CTX_FLAGS_MULTI_DIRTY; + flags |= VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY; } } if (scriptIsRunning()) - flags |= REDISMODULE_CTX_FLAGS_LUA; + flags |= VALKEYMODULE_CTX_FLAGS_LUA; if (server.in_exec) - flags |= REDISMODULE_CTX_FLAGS_MULTI; + flags |= VALKEYMODULE_CTX_FLAGS_MULTI; if (server.cluster_enabled) - flags |= REDISMODULE_CTX_FLAGS_CLUSTER; + flags |= VALKEYMODULE_CTX_FLAGS_CLUSTER; if (server.async_loading) - flags |= REDISMODULE_CTX_FLAGS_ASYNC_LOADING; + flags |= VALKEYMODULE_CTX_FLAGS_ASYNC_LOADING; else if (server.loading) - flags |= REDISMODULE_CTX_FLAGS_LOADING; + flags |= VALKEYMODULE_CTX_FLAGS_LOADING; /* Maxmemory and eviction policy */ if (server.maxmemory > 0 && (!server.masterhost || !server.repl_slave_ignore_maxmemory)) { - flags |= REDISMODULE_CTX_FLAGS_MAXMEMORY; + flags |= VALKEYMODULE_CTX_FLAGS_MAXMEMORY; if (server.maxmemory_policy != MAXMEMORY_NO_EVICTION) - flags |= REDISMODULE_CTX_FLAGS_EVICT; + flags |= VALKEYMODULE_CTX_FLAGS_EVICT; } /* Persistence flags */ if (server.aof_state != AOF_OFF) - flags |= REDISMODULE_CTX_FLAGS_AOF; + flags |= VALKEYMODULE_CTX_FLAGS_AOF; if (server.saveparamslen > 0) - flags |= REDISMODULE_CTX_FLAGS_RDB; + flags |= VALKEYMODULE_CTX_FLAGS_RDB; /* Replication flags */ if (server.masterhost == NULL) { - flags |= REDISMODULE_CTX_FLAGS_MASTER; + flags |= VALKEYMODULE_CTX_FLAGS_PRIMARY; } else { - flags |= REDISMODULE_CTX_FLAGS_SLAVE; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA; if (server.repl_slave_ro) - flags |= REDISMODULE_CTX_FLAGS_READONLY; + flags |= VALKEYMODULE_CTX_FLAGS_READONLY; /* Replica state flags. */ if (server.repl_state == REPL_STATE_CONNECT || server.repl_state == REPL_STATE_CONNECTING) { - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING; } else if (server.repl_state == REPL_STATE_TRANSFER) { - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING; } else if (server.repl_state == REPL_STATE_CONNECTED) { - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE; } if (server.repl_state != REPL_STATE_CONNECTED) - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE; } /* OOM flag. */ float level; int retval = getMaxmemoryState(NULL,NULL,NULL,&level); - if (retval == C_ERR) flags |= REDISMODULE_CTX_FLAGS_OOM; - if (level > 0.75) flags |= REDISMODULE_CTX_FLAGS_OOM_WARNING; + if (retval == C_ERR) flags |= VALKEYMODULE_CTX_FLAGS_OOM; + if (level > 0.75) flags |= VALKEYMODULE_CTX_FLAGS_OOM_WARNING; /* Presence of children processes. */ - if (hasActiveChildProcess()) flags |= REDISMODULE_CTX_FLAGS_ACTIVE_CHILD; - if (server.in_fork_child) flags |= REDISMODULE_CTX_FLAGS_IS_CHILD; + if (hasActiveChildProcess()) flags |= VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD; + if (server.in_fork_child) flags |= VALKEYMODULE_CTX_FLAGS_IS_CHILD; /* Non-empty server.loadmodule_queue means that Redis is starting. */ if (listLength(server.loadmodule_queue) > 0) - flags |= REDISMODULE_CTX_FLAGS_SERVER_STARTUP; + flags |= VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP; return flags; } @@ -4002,8 +4003,8 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { * replication offset, match the one of the master. When this happens, it is * safe to failover the master without data loss. * - * However modules may generate traffic by calling RedisModule_Call() with - * the "!" flag, or by calling RedisModule_Replicate(), in a context outside + * However modules may generate traffic by calling ValkeyModule_Call() with + * the "!" flag, or by calling ValkeyModule_Replicate(), in a context outside * commands execution, for instance in timeout callbacks, threads safe * contexts, and so forth. When modules will generate too much traffic, it * will be hard for the master and replicas offset to match, because there @@ -4015,7 +4016,7 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { * garbage collection tasks, or that do writes and replicate such writes * periodically in timer callbacks or other periodic callbacks. */ -int RM_AvoidReplicaTraffic(void) { +int VM_AvoidReplicaTraffic(void) { return !!(isPausedActionsWithUpdate(PAUSE_ACTION_REPLICA)); } @@ -4027,26 +4028,26 @@ int RM_AvoidReplicaTraffic(void) { * returns. * * If the module command wishes to change something in a different DB and - * returns back to the original one, it should call RedisModule_GetSelectedDb() + * returns back to the original one, it should call ValkeyModule_GetSelectedDb() * before in order to restore the old DB number before returning. */ -int RM_SelectDb(RedisModuleCtx *ctx, int newid) { +int VM_SelectDb(ValkeyModuleCtx *ctx, int newid) { int retval = selectDb(ctx->client,newid); - return (retval == C_OK) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == C_OK) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Check if a key exists, without affecting its last access time. * - * This is equivalent to calling RM_OpenKey with the mode REDISMODULE_READ | - * REDISMODULE_OPEN_KEY_NOTOUCH, then checking if NULL was returned and, if not, - * calling RM_CloseKey on the opened key. + * This is equivalent to calling VM_OpenKey with the mode VALKEYMODULE_READ | + * VALKEYMODULE_OPEN_KEY_NOTOUCH, then checking if NULL was returned and, if not, + * calling VM_CloseKey on the opened key. */ -int RM_KeyExists(RedisModuleCtx *ctx, robj *keyname) { +int VM_KeyExists(ValkeyModuleCtx *ctx, robj *keyname) { robj *value = lookupKeyReadWithFlags(ctx->client->db, keyname, LOOKUP_NOTOUCH); return (value != NULL); } -/* Initialize a RedisModuleKey struct */ -static void moduleInitKey(RedisModuleKey *kp, RedisModuleCtx *ctx, robj *keyname, robj *value, int mode){ +/* Initialize a ValkeyModuleKey struct */ +static void moduleInitKey(ValkeyModuleKey *kp, ValkeyModuleCtx *ctx, robj *keyname, robj *value, int mode){ kp->ctx = ctx; kp->db = ctx->client->db; kp->key = keyname; @@ -4058,7 +4059,7 @@ static void moduleInitKey(RedisModuleKey *kp, RedisModuleCtx *ctx, robj *keyname } /* Initialize the type-specific part of the key. Only when key has a value. */ -static void moduleInitKeyTypeSpecific(RedisModuleKey *key) { +static void moduleInitKeyTypeSpecific(ValkeyModuleKey *key) { switch (key->value->type) { case OBJ_ZSET: zsetKeyReset(key); break; case OBJ_STREAM: key->u.stream.signalready = 0; break; @@ -4070,33 +4071,33 @@ static void moduleInitKeyTypeSpecific(RedisModuleKey *key) { * operations on the key. * * The return value is the handle representing the key, that must be - * closed with RM_CloseKey(). + * closed with VM_CloseKey(). * - * If the key does not exist and REDISMODULE_WRITE mode is requested, the handle + * If the key does not exist and VALKEYMODULE_WRITE mode is requested, the handle * is still returned, since it is possible to perform operations on * a yet not existing key (that will be created, for example, after - * a list push operation). If the mode is just REDISMODULE_READ instead, and the + * a list push operation). If the mode is just VALKEYMODULE_READ instead, and the * key does not exist, NULL is returned. However it is still safe to - * call RedisModule_CloseKey() and RedisModule_KeyType() on a NULL + * call ValkeyModule_CloseKey() and ValkeyModule_KeyType() on a NULL * value. * * Extra flags that can be pass to the API under the mode argument: - * * REDISMODULE_OPEN_KEY_NOTOUCH - Avoid touching the LRU/LFU of the key when opened. - * * REDISMODULE_OPEN_KEY_NONOTIFY - Don't trigger keyspace event on key misses. - * * REDISMODULE_OPEN_KEY_NOSTATS - Don't update keyspace hits/misses counters. - * * REDISMODULE_OPEN_KEY_NOEXPIRE - Avoid deleting lazy expired keys. - * * REDISMODULE_OPEN_KEY_NOEFFECTS - Avoid any effects from fetching the key. */ -RedisModuleKey *RM_OpenKey(RedisModuleCtx *ctx, robj *keyname, int mode) { - RedisModuleKey *kp; + * * VALKEYMODULE_OPEN_KEY_NOTOUCH - Avoid touching the LRU/LFU of the key when opened. + * * VALKEYMODULE_OPEN_KEY_NONOTIFY - Don't trigger keyspace event on key misses. + * * VALKEYMODULE_OPEN_KEY_NOSTATS - Don't update keyspace hits/misses counters. + * * VALKEYMODULE_OPEN_KEY_NOEXPIRE - Avoid deleting lazy expired keys. + * * VALKEYMODULE_OPEN_KEY_NOEFFECTS - Avoid any effects from fetching the key. */ +ValkeyModuleKey *VM_OpenKey(ValkeyModuleCtx *ctx, robj *keyname, int mode) { + ValkeyModuleKey *kp; robj *value; int flags = 0; - flags |= (mode & REDISMODULE_OPEN_KEY_NOTOUCH? LOOKUP_NOTOUCH: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NONOTIFY? LOOKUP_NONOTIFY: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NOSTATS? LOOKUP_NOSTATS: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NOEXPIRE? LOOKUP_NOEXPIRE: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NOEFFECTS? LOOKUP_NOEFFECTS: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOTOUCH? LOOKUP_NOTOUCH: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NONOTIFY? LOOKUP_NONOTIFY: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOSTATS? LOOKUP_NOSTATS: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOEXPIRE? LOOKUP_NOEXPIRE: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOEFFECTS? LOOKUP_NOEFFECTS: 0); - if (mode & REDISMODULE_WRITE) { + if (mode & VALKEYMODULE_WRITE) { value = lookupKeyWriteWithFlags(ctx->client->db,keyname, flags); } else { value = lookupKeyReadWithFlags(ctx->client->db,keyname, flags); @@ -4108,7 +4109,7 @@ RedisModuleKey *RM_OpenKey(RedisModuleCtx *ctx, robj *keyname, int mode) { /* Setup the key handle. */ kp = zmalloc(sizeof(*kp)); moduleInitKey(kp, ctx, keyname, value, mode); - autoMemoryAdd(ctx,REDISMODULE_AM_KEY,kp); + autoMemoryAdd(ctx,VALKEYMODULE_AM_KEY,kp); return kp; } @@ -4118,31 +4119,31 @@ RedisModuleKey *RM_OpenKey(RedisModuleCtx *ctx, robj *keyname, int mode) { * by the redis server version in use. * Example: * - * int supportedMode = RM_GetOpenKeyModesAll(); - * if (supportedMode & REDISMODULE_OPEN_KEY_NOTOUCH) { - * // REDISMODULE_OPEN_KEY_NOTOUCH is supported + * int supportedMode = VM_GetOpenKeyModesAll(); + * if (supportedMode & VALKEYMODULE_OPEN_KEY_NOTOUCH) { + * // VALKEYMODULE_OPEN_KEY_NOTOUCH is supported * } else{ - * // REDISMODULE_OPEN_KEY_NOTOUCH is not supported + * // VALKEYMODULE_OPEN_KEY_NOTOUCH is not supported * } */ -int RM_GetOpenKeyModesAll(void) { - return _REDISMODULE_OPEN_KEY_ALL; +int VM_GetOpenKeyModesAll(void) { + return _VALKEYMODULE_OPEN_KEY_ALL; } -/* Destroy a RedisModuleKey struct (freeing is the responsibility of the caller). */ -static void moduleCloseKey(RedisModuleKey *key) { +/* Destroy a ValkeyModuleKey struct (freeing is the responsibility of the caller). */ +static void moduleCloseKey(ValkeyModuleKey *key) { int signal = SHOULD_SIGNAL_MODIFIED_KEYS(key->ctx); - if ((key->mode & REDISMODULE_WRITE) && signal) + if ((key->mode & VALKEYMODULE_WRITE) && signal) signalModifiedKey(key->ctx->client,key->db,key->key); if (key->value) { if (key->iter) moduleFreeKeyIterator(key); switch (key->value->type) { case OBJ_ZSET: - RM_ZsetRangeStop(key); + VM_ZsetRangeStop(key); break; case OBJ_STREAM: if (key->u.stream.signalready) - /* One or more RM_StreamAdd() have been done. */ + /* One or more VM_StreamAdd() have been done. */ signalKeyAsReady(key->db, key->key, OBJ_STREAM); break; } @@ -4152,28 +4153,28 @@ static void moduleCloseKey(RedisModuleKey *key) { } /* Close a key handle. */ -void RM_CloseKey(RedisModuleKey *key) { +void VM_CloseKey(ValkeyModuleKey *key) { if (key == NULL) return; moduleCloseKey(key); - autoMemoryFreed(key->ctx,REDISMODULE_AM_KEY,key); + autoMemoryFreed(key->ctx,VALKEYMODULE_AM_KEY,key); zfree(key); } /* Return the type of the key. If the key pointer is NULL then - * REDISMODULE_KEYTYPE_EMPTY is returned. */ -int RM_KeyType(RedisModuleKey *key) { - if (key == NULL || key->value == NULL) return REDISMODULE_KEYTYPE_EMPTY; + * VALKEYMODULE_KEYTYPE_EMPTY is returned. */ +int VM_KeyType(ValkeyModuleKey *key) { + if (key == NULL || key->value == NULL) return VALKEYMODULE_KEYTYPE_EMPTY; /* We map between defines so that we are free to change the internal * defines as desired. */ switch(key->value->type) { - case OBJ_STRING: return REDISMODULE_KEYTYPE_STRING; - case OBJ_LIST: return REDISMODULE_KEYTYPE_LIST; - case OBJ_SET: return REDISMODULE_KEYTYPE_SET; - case OBJ_ZSET: return REDISMODULE_KEYTYPE_ZSET; - case OBJ_HASH: return REDISMODULE_KEYTYPE_HASH; - case OBJ_MODULE: return REDISMODULE_KEYTYPE_MODULE; - case OBJ_STREAM: return REDISMODULE_KEYTYPE_STREAM; - default: return REDISMODULE_KEYTYPE_EMPTY; + case OBJ_STRING: return VALKEYMODULE_KEYTYPE_STRING; + case OBJ_LIST: return VALKEYMODULE_KEYTYPE_LIST; + case OBJ_SET: return VALKEYMODULE_KEYTYPE_SET; + case OBJ_ZSET: return VALKEYMODULE_KEYTYPE_ZSET; + case OBJ_HASH: return VALKEYMODULE_KEYTYPE_HASH; + case OBJ_MODULE: return VALKEYMODULE_KEYTYPE_MODULE; + case OBJ_STREAM: return VALKEYMODULE_KEYTYPE_STREAM; + default: return VALKEYMODULE_KEYTYPE_EMPTY; } } @@ -4182,7 +4183,7 @@ int RM_KeyType(RedisModuleKey *key) { * is the number of elements (just counting keys for hashes). * * If the key pointer is NULL or the key is empty, zero is returned. */ -size_t RM_ValueLength(RedisModuleKey *key) { +size_t VM_ValueLength(ValkeyModuleKey *key) { if (key == NULL || key->value == NULL) return 0; switch(key->value->type) { case OBJ_STRING: return stringObjectLen(key->value); @@ -4197,150 +4198,150 @@ size_t RM_ValueLength(RedisModuleKey *key) { /* If the key is open for writing, remove it, and setup the key to * accept new writes as an empty key (that will be created on demand). - * On success REDISMODULE_OK is returned. If the key is not open for - * writing REDISMODULE_ERR is returned. */ -int RM_DeleteKey(RedisModuleKey *key) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing VALKEYMODULE_ERR is returned. */ +int VM_DeleteKey(ValkeyModuleKey *key) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; if (key->value) { dbDelete(key->db,key->key); key->value = NULL; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* If the key is open for writing, unlink it (that is delete it in a * non-blocking way, not reclaiming memory immediately) and setup the key to * accept new writes as an empty key (that will be created on demand). - * On success REDISMODULE_OK is returned. If the key is not open for - * writing REDISMODULE_ERR is returned. */ -int RM_UnlinkKey(RedisModuleKey *key) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing VALKEYMODULE_ERR is returned. */ +int VM_UnlinkKey(ValkeyModuleKey *key) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; if (key->value) { dbAsyncDelete(key->db,key->key); key->value = NULL; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return the key expire value, as milliseconds of remaining TTL. * If no TTL is associated with the key or if the key is empty, - * REDISMODULE_NO_EXPIRE is returned. */ -mstime_t RM_GetExpire(RedisModuleKey *key) { + * VALKEYMODULE_NO_EXPIRE is returned. */ +mstime_t VM_GetExpire(ValkeyModuleKey *key) { mstime_t expire = getExpire(key->db,key->key); if (expire == -1 || key->value == NULL) - return REDISMODULE_NO_EXPIRE; + return VALKEYMODULE_NO_EXPIRE; expire -= commandTimeSnapshot(); return expire >= 0 ? expire : 0; } /* Set a new expire for the key. If the special expire - * REDISMODULE_NO_EXPIRE is set, the expire is cancelled if there was + * VALKEYMODULE_NO_EXPIRE is set, the expire is cancelled if there was * one (the same as the PERSIST command). * * Note that the expire must be provided as a positive integer representing * the number of milliseconds of TTL the key should have. * - * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if + * The function returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if * the key was not open for writing or is an empty key. */ -int RM_SetExpire(RedisModuleKey *key, mstime_t expire) { - if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != REDISMODULE_NO_EXPIRE)) - return REDISMODULE_ERR; - if (expire != REDISMODULE_NO_EXPIRE) { +int VM_SetExpire(ValkeyModuleKey *key, mstime_t expire) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != VALKEYMODULE_NO_EXPIRE)) + return VALKEYMODULE_ERR; + if (expire != VALKEYMODULE_NO_EXPIRE) { expire += commandTimeSnapshot(); setExpire(key->ctx->client,key->db,key->key,expire); } else { removeExpire(key->db,key->key); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return the key expire value, as absolute Unix timestamp. * If no TTL is associated with the key or if the key is empty, - * REDISMODULE_NO_EXPIRE is returned. */ -mstime_t RM_GetAbsExpire(RedisModuleKey *key) { + * VALKEYMODULE_NO_EXPIRE is returned. */ +mstime_t VM_GetAbsExpire(ValkeyModuleKey *key) { mstime_t expire = getExpire(key->db,key->key); if (expire == -1 || key->value == NULL) - return REDISMODULE_NO_EXPIRE; + return VALKEYMODULE_NO_EXPIRE; return expire; } /* Set a new expire for the key. If the special expire - * REDISMODULE_NO_EXPIRE is set, the expire is cancelled if there was + * VALKEYMODULE_NO_EXPIRE is set, the expire is cancelled if there was * one (the same as the PERSIST command). * * Note that the expire must be provided as a positive integer representing * the absolute Unix timestamp the key should have. * - * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if + * The function returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if * the key was not open for writing or is an empty key. */ -int RM_SetAbsExpire(RedisModuleKey *key, mstime_t expire) { - if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != REDISMODULE_NO_EXPIRE)) - return REDISMODULE_ERR; - if (expire != REDISMODULE_NO_EXPIRE) { +int VM_SetAbsExpire(ValkeyModuleKey *key, mstime_t expire) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != VALKEYMODULE_NO_EXPIRE)) + return VALKEYMODULE_ERR; + if (expire != VALKEYMODULE_NO_EXPIRE) { setExpire(key->ctx->client,key->db,key->key,expire); } else { removeExpire(key->db,key->key); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Performs similar operation to FLUSHALL, and optionally start a new AOF file (if enabled) * If restart_aof is true, you must make sure the command that triggered this call is not * propagated to the AOF file. * When async is set to true, db contents will be freed by a background thread. */ -void RM_ResetDataset(int restart_aof, int async) { +void VM_ResetDataset(int restart_aof, int async) { if (restart_aof && server.aof_state != AOF_OFF) stopAppendOnly(); flushAllDataAndResetRDB((async? EMPTYDB_ASYNC: EMPTYDB_NO_FLAGS) | EMPTYDB_NOFUNCTIONS); if (server.aof_enabled && restart_aof) restartAOFAfterSYNC(); } /* Returns the number of keys in the current db. */ -unsigned long long RM_DbSize(RedisModuleCtx *ctx) { +unsigned long long VM_DbSize(ValkeyModuleCtx *ctx) { return dbSize(ctx->client->db); } /* Returns a name of a random key, or NULL if current db is empty. */ -RedisModuleString *RM_RandomKey(RedisModuleCtx *ctx) { +ValkeyModuleString *VM_RandomKey(ValkeyModuleCtx *ctx) { robj *key = dbRandomKey(ctx->client->db); - autoMemoryAdd(ctx,REDISMODULE_AM_STRING,key); + autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,key); return key; } /* Returns the name of the key currently being processed. */ -const RedisModuleString *RM_GetKeyNameFromOptCtx(RedisModuleKeyOptCtx *ctx) { +const ValkeyModuleString *VM_GetKeyNameFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->from_key; } /* Returns the name of the target key currently being processed. */ -const RedisModuleString *RM_GetToKeyNameFromOptCtx(RedisModuleKeyOptCtx *ctx) { +const ValkeyModuleString *VM_GetToKeyNameFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->to_key; } /* Returns the dbid currently being processed. */ -int RM_GetDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { +int VM_GetDbIdFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->from_dbid; } /* Returns the target dbid currently being processed. */ -int RM_GetToDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { +int VM_GetToDbIdFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->to_dbid; } /* -------------------------------------------------------------------------- * ## Key API for String type * - * See also RM_ValueLength(), which returns the length of a string. + * See also VM_ValueLength(), which returns the length of a string. * -------------------------------------------------------------------------- */ /* If the key is open for writing, set the specified string 'str' as the * value of the key, deleting the old value if any. - * On success REDISMODULE_OK is returned. If the key is not open for - * writing or there is an active iterator, REDISMODULE_ERR is returned. */ -int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { - if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; - RM_DeleteKey(key); + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing or there is an active iterator, VALKEYMODULE_ERR is returned. */ +int VM_StringSet(ValkeyModuleKey *key, ValkeyModuleString *str) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->iter) return VALKEYMODULE_ERR; + VM_DeleteKey(key); setKey(key->ctx->client,key->db,key->key,str,SETKEY_NO_SIGNAL); key->value = str; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Prepare the key associated string value for DMA access, and returns @@ -4349,8 +4350,8 @@ int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { * * The 'mode' is composed by bitwise OR-ing the following flags: * - * REDISMODULE_READ -- Read access - * REDISMODULE_WRITE -- Write access + * VALKEYMODULE_READ -- Read access + * VALKEYMODULE_WRITE -- Write access * * If the DMA is not requested for writing, the pointer returned should * only be accessed in a read-only fashion. @@ -4363,16 +4364,16 @@ int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { * the pointer is obtained, for all the time we want to use DMA access * to read or modify the string. * - * 2. Each time RM_StringTruncate() is called, to continue with the DMA - * access, RM_StringDMA() should be called again to re-obtain + * 2. Each time VM_StringTruncate() is called, to continue with the DMA + * access, VM_StringDMA() should be called again to re-obtain * a new pointer and length. * * 3. If the returned pointer is not NULL, but the length is zero, no * byte can be touched (the string is empty, or the key itself is empty) - * so a RM_StringTruncate() call should be used if there is to enlarge + * so a VM_StringTruncate() call should be used if there is to enlarge * the string, and later call StringDMA() again to get the pointer. */ -char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { +char *VM_StringDMA(ValkeyModuleKey *key, size_t *len, int mode) { /* We need to return *some* pointer for empty keys, we just return * a string literal pointer, that is the advantage to be mapped into * a read only memory page, so the module will segfault if a write @@ -4387,7 +4388,7 @@ char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { /* For write access, and even for read access if the object is encoded, * we unshare the string (that has the side effect of decoding it). */ - if ((mode & REDISMODULE_WRITE) || key->value->encoding != OBJ_ENCODING_RAW) + if ((mode & VALKEYMODULE_WRITE) || key->value->encoding != OBJ_ENCODING_RAW) key->value = dbUnshareStringValue(key->db, key->key, key->value); *len = sdslen(key->value->ptr); @@ -4397,23 +4398,23 @@ char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { /* If the key is open for writing and is of string type, resize it, padding * with zero bytes if the new length is greater than the old one. * - * After this call, RM_StringDMA() must be called again to continue + * After this call, VM_StringDMA() must be called again to continue * DMA access with the new pointer. * - * The function returns REDISMODULE_OK on success, and REDISMODULE_ERR on + * The function returns VALKEYMODULE_OK on success, and VALKEYMODULE_ERR on * error, that is, the key is not open for writing, is not a string * or resizing for more than 512 MB is requested. * * If the key is empty, a string key is created with the new string value * unless the new length value requested is zero. */ -int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_STRING) return REDISMODULE_ERR; - if (newlen > 512*1024*1024) return REDISMODULE_ERR; +int VM_StringTruncate(ValkeyModuleKey *key, size_t newlen) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_STRING) return VALKEYMODULE_ERR; + if (newlen > 512*1024*1024) return VALKEYMODULE_ERR; - /* Empty key and new len set to 0. Just return REDISMODULE_OK without + /* Empty key and new len set to 0. Just return VALKEYMODULE_OK without * doing anything. */ - if (key->value == NULL && newlen == 0) return REDISMODULE_OK; + if (key->value == NULL && newlen == 0) return VALKEYMODULE_OK; if (key->value == NULL) { /* Empty key: create it with the new size. */ @@ -4434,7 +4435,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { key->value->ptr = sdsRemoveFreeSpace(key->value->ptr, 0); } } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -4448,28 +4449,28 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { * * This enables iteration to be done efficiently using a simple for loop: * - * long n = RM_ValueLength(key); + * long n = VM_ValueLength(key); * for (long i = 0; i < n; i++) { - * RedisModuleString *elem = RedisModule_ListGet(key, i); + * ValkeyModuleString *elem = ValkeyModule_ListGet(key, i); * // Do stuff... * } * - * Note that after modifying a list using RM_ListPop, RM_ListSet or - * RM_ListInsert, the internal iterator is invalidated so the next operation + * Note that after modifying a list using VM_ListPop, VM_ListSet or + * VM_ListInsert, the internal iterator is invalidated so the next operation * will require a linear seek. * - * Modifying a list in any another way, for example using RM_Call(), while a key + * Modifying a list in any another way, for example using VM_Call(), while a key * is open will confuse the internal iterator and may cause trouble if the key * is used after such modifications. The key must be reopened in this case. * - * See also RM_ValueLength(), which returns the length of a list. + * See also VM_ValueLength(), which returns the length of a list. * -------------------------------------------------------------------------- */ /* Seeks the key's internal list iterator to the given index. On success, 1 is * returned and key->iter, key->u.list.entry and key->u.list.index are set. On * failure, 0 is returned and errno is set as required by the list API * functions. */ -int moduleListIteratorSeek(RedisModuleKey *key, long index, int mode) { +int moduleListIteratorSeek(ValkeyModuleKey *key, long index, int mode) { if (!key) { errno = EINVAL; return 0; @@ -4514,9 +4515,9 @@ int moduleListIteratorSeek(RedisModuleKey *key, long index, int mode) { } /* Push an element into a list, on head or tail depending on 'where' argument - * (REDISMODULE_LIST_HEAD or REDISMODULE_LIST_TAIL). If the key refers to an - * empty key opened for writing, the key is created. On success, REDISMODULE_OK - * is returned. On failure, REDISMODULE_ERR is returned and `errno` is set as + * (VALKEYMODULE_LIST_HEAD or VALKEYMODULE_LIST_TAIL). If the key refers to an + * empty key opened for writing, the key is created. On success, VALKEYMODULE_OK + * is returned. On failure, VALKEYMODULE_ERR is returned and `errno` is set as * follows: * * - EINVAL if key or ele is NULL. @@ -4524,33 +4525,33 @@ int moduleListIteratorSeek(RedisModuleKey *key, long index, int mode) { * - EBADF if the key is not opened for writing. * * Note: Before Redis 7.0, `errno` was not set by this function. */ -int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) { +int VM_ListPush(ValkeyModuleKey *key, int where, ValkeyModuleString *ele) { if (!key || !ele) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->value != NULL && key->value->type != OBJ_LIST) { errno = ENOTSUP; - return REDISMODULE_ERR; - } if (!(key->mode & REDISMODULE_WRITE)) { + return VALKEYMODULE_ERR; + } if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR; + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_LIST) return VALKEYMODULE_ERR; if (key->iter) moduleFreeKeyIterator(key); - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST); + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_LIST); listTypeTryConversionAppend(key->value, &ele, 0, 0, moduleFreeListIterator, key); listTypePush(key->value, ele, - (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); - return REDISMODULE_OK; + (where == VALKEYMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); + return VALKEYMODULE_OK; } /* Pop an element from the list, and returns it as a module string object - * that the user should be free with RM_FreeString() or by enabling + * that the user should be free with VM_FreeString() or by enabling * automatic memory. The `where` argument specifies if the element should be - * popped from the beginning or the end of the list (REDISMODULE_LIST_HEAD or - * REDISMODULE_LIST_TAIL). On failure, the command returns NULL and sets + * popped from the beginning or the end of the list (VALKEYMODULE_LIST_HEAD or + * VALKEYMODULE_LIST_TAIL). On failure, the command returns NULL and sets * `errno` as follows: * * - EINVAL if key is NULL. @@ -4558,30 +4559,30 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) { * - EBADF if the key is not opened for writing. * * Note: Before Redis 7.0, `errno` was not set by this function. */ -RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { +ValkeyModuleString *VM_ListPop(ValkeyModuleKey *key, int where) { if (!key) { errno = EINVAL; return NULL; } else if (key->value == NULL || key->value->type != OBJ_LIST) { errno = ENOTSUP; return NULL; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return NULL; } if (key->iter) moduleFreeKeyIterator(key); robj *ele = listTypePop(key->value, - (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); + (where == VALKEYMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); robj *decoded = getDecodedObject(ele); decrRefCount(ele); if (!moduleDelKeyIfEmpty(key)) listTypeTryConversion(key->value, LIST_CONV_SHRINKING, moduleFreeListIterator, key); - autoMemoryAdd(key->ctx,REDISMODULE_AM_STRING,decoded); + autoMemoryAdd(key->ctx,VALKEYMODULE_AM_STRING,decoded); return decoded; } /* Returns the element at index `index` in the list stored at `key`, like the - * LINDEX command. The element should be free'd using RM_FreeString() or using + * LINDEX command. The element should be free'd using VM_FreeString() or using * automatic memory management. * * The index is zero-based, so 0 means the first element, 1 the second element @@ -4597,12 +4598,12 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { * - EBADF if the key is not opened for reading. * - EDOM if the index is not a valid index in the list. */ -RedisModuleString *RM_ListGet(RedisModuleKey *key, long index) { - if (moduleListIteratorSeek(key, index, REDISMODULE_READ)) { +ValkeyModuleString *VM_ListGet(ValkeyModuleKey *key, long index) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_READ)) { robj *elem = listTypeGet(&key->u.list.entry); robj *decoded = getDecodedObject(elem); decrRefCount(elem); - autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, decoded); + autoMemoryAdd(key->ctx, VALKEYMODULE_AM_STRING, decoded); return decoded; } else { return NULL; @@ -4616,7 +4617,7 @@ RedisModuleString *RM_ListGet(RedisModuleKey *key, long index) { * tail of the list. Here, -1 means the last element, -2 means the penultimate * and so forth. * - * On success, REDISMODULE_OK is returned. On failure, REDISMODULE_ERR is + * On success, VALKEYMODULE_OK is returned. On failure, VALKEYMODULE_ERR is * returned and `errno` is set as follows: * * - EINVAL if key or value is NULL. @@ -4624,24 +4625,24 @@ RedisModuleString *RM_ListGet(RedisModuleKey *key, long index) { * - EBADF if the key is not opened for writing. * - EDOM if the index is not a valid index in the list. */ -int RM_ListSet(RedisModuleKey *key, long index, RedisModuleString *value) { +int VM_ListSet(ValkeyModuleKey *key, long index, ValkeyModuleString *value) { if (!value) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (!key->value || key->value->type != OBJ_LIST) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } listTypeTryConversionAppend(key->value, &value, 0, 0, moduleFreeListIterator, key); - if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_WRITE)) { listTypeReplace(&key->u.list.entry, value); /* A note in quicklist.c forbids use of iterator after insert, so * probably also after replace. */ moduleFreeKeyIterator(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } @@ -4652,7 +4653,7 @@ int RM_ListSet(RedisModuleKey *key, long index, RedisModuleString *value) { * tail of the list. Here, -1 means the last element, -2 means the penultimate * and so forth. The index is the element's index after inserting it. * - * On success, REDISMODULE_OK is returned. On failure, REDISMODULE_ERR is + * On success, VALKEYMODULE_OK is returned. On failure, VALKEYMODULE_ERR is * returned and `errno` is set as follows: * * - EINVAL if key or value is NULL. @@ -4660,41 +4661,41 @@ int RM_ListSet(RedisModuleKey *key, long index, RedisModuleString *value) { * - EBADF if the key is not opened for writing. * - EDOM if the index is not a valid index in the list. */ -int RM_ListInsert(RedisModuleKey *key, long index, RedisModuleString *value) { +int VM_ListInsert(ValkeyModuleKey *key, long index, ValkeyModuleString *value) { if (!value) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key != NULL && key->value == NULL && (index == 0 || index == -1)) { /* Insert in empty key => push. */ - return RM_ListPush(key, REDISMODULE_LIST_TAIL, value); + return VM_ListPush(key, VALKEYMODULE_LIST_TAIL, value); } else if (key != NULL && key->value != NULL && key->value->type == OBJ_LIST && (index == (long)listTypeLength(key->value) || index == -1)) { /* Insert after the last element => push tail. */ - return RM_ListPush(key, REDISMODULE_LIST_TAIL, value); + return VM_ListPush(key, VALKEYMODULE_LIST_TAIL, value); } else if (key != NULL && key->value != NULL && key->value->type == OBJ_LIST && (index == 0 || index == -(long)listTypeLength(key->value) - 1)) { /* Insert before the first element => push head. */ - return RM_ListPush(key, REDISMODULE_LIST_HEAD, value); + return VM_ListPush(key, VALKEYMODULE_LIST_HEAD, value); } listTypeTryConversionAppend(key->value, &value, 0, 0, moduleFreeListIterator, key); - if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_WRITE)) { int where = index < 0 ? LIST_TAIL : LIST_HEAD; listTypeInsert(&key->u.list.entry, value, where); /* A note in quicklist.c forbids use of iterator after insert. */ moduleFreeKeyIterator(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* Removes an element at the given index. The index is 0-based. A negative index * can also be used, counting from the end of the list. * - * On success, REDISMODULE_OK is returned. On failure, REDISMODULE_ERR is + * On success, VALKEYMODULE_OK is returned. On failure, VALKEYMODULE_ERR is * returned and `errno` is set as follows: * * - EINVAL if key or value is NULL. @@ -4702,12 +4703,12 @@ int RM_ListInsert(RedisModuleKey *key, long index, RedisModuleString *value) { * - EBADF if the key is not opened for writing. * - EDOM if the index is not a valid index in the list. */ -int RM_ListDelete(RedisModuleKey *key, long index) { - if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { +int VM_ListDelete(ValkeyModuleKey *key, long index) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_WRITE)) { listTypeDelete(key->iter, &key->u.list.entry); - if (moduleDelKeyIfEmpty(key)) return REDISMODULE_OK; + if (moduleDelKeyIfEmpty(key)) return VALKEYMODULE_OK; listTypeTryConversion(key->value, LIST_CONV_SHRINKING, moduleFreeListIterator, key); - if (!key->iter) return REDISMODULE_OK; /* Return ASAP if iterator has been freed */ + if (!key->iter) return VALKEYMODULE_OK; /* Return ASAP if iterator has been freed */ if (listTypeNext(key->iter, &key->u.list.entry)) { /* After delete entry at position 'index', we need to update * 'key->u.list.index' according to the following cases: @@ -4725,35 +4726,35 @@ int RM_ListDelete(RedisModuleKey *key, long index) { /* Reset list iterator if the next entry doesn't exist. */ moduleFreeKeyIterator(key); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* -------------------------------------------------------------------------- * ## Key API for Sorted Set type * - * See also RM_ValueLength(), which returns the length of a sorted set. + * See also VM_ValueLength(), which returns the length of a sorted set. * -------------------------------------------------------------------------- */ /* Conversion from/to public flags of the Modules API and our private flags, * so that we have everything decoupled. */ int moduleZsetAddFlagsToCoreFlags(int flags) { int retflags = 0; - if (flags & REDISMODULE_ZADD_XX) retflags |= ZADD_IN_XX; - if (flags & REDISMODULE_ZADD_NX) retflags |= ZADD_IN_NX; - if (flags & REDISMODULE_ZADD_GT) retflags |= ZADD_IN_GT; - if (flags & REDISMODULE_ZADD_LT) retflags |= ZADD_IN_LT; + if (flags & VALKEYMODULE_ZADD_XX) retflags |= ZADD_IN_XX; + if (flags & VALKEYMODULE_ZADD_NX) retflags |= ZADD_IN_NX; + if (flags & VALKEYMODULE_ZADD_GT) retflags |= ZADD_IN_GT; + if (flags & VALKEYMODULE_ZADD_LT) retflags |= ZADD_IN_LT; return retflags; } /* See previous function comment. */ int moduleZsetAddFlagsFromCoreFlags(int flags) { int retflags = 0; - if (flags & ZADD_OUT_ADDED) retflags |= REDISMODULE_ZADD_ADDED; - if (flags & ZADD_OUT_UPDATED) retflags |= REDISMODULE_ZADD_UPDATED; - if (flags & ZADD_OUT_NOP) retflags |= REDISMODULE_ZADD_NOP; + if (flags & ZADD_OUT_ADDED) retflags |= VALKEYMODULE_ZADD_ADDED; + if (flags & ZADD_OUT_UPDATED) retflags |= VALKEYMODULE_ZADD_UPDATED; + if (flags & ZADD_OUT_NOP) retflags |= VALKEYMODULE_ZADD_NOP; return retflags; } @@ -4769,72 +4770,72 @@ int moduleZsetAddFlagsFromCoreFlags(int flags) { * * The input flags are: * - * REDISMODULE_ZADD_XX: Element must already exist. Do nothing otherwise. - * REDISMODULE_ZADD_NX: Element must not exist. Do nothing otherwise. - * REDISMODULE_ZADD_GT: If element exists, new score must be greater than the current score. + * VALKEYMODULE_ZADD_XX: Element must already exist. Do nothing otherwise. + * VALKEYMODULE_ZADD_NX: Element must not exist. Do nothing otherwise. + * VALKEYMODULE_ZADD_GT: If element exists, new score must be greater than the current score. * Do nothing otherwise. Can optionally be combined with XX. - * REDISMODULE_ZADD_LT: If element exists, new score must be less than the current score. + * VALKEYMODULE_ZADD_LT: If element exists, new score must be less than the current score. * Do nothing otherwise. Can optionally be combined with XX. * * The output flags are: * - * REDISMODULE_ZADD_ADDED: The new element was added to the sorted set. - * REDISMODULE_ZADD_UPDATED: The score of the element was updated. - * REDISMODULE_ZADD_NOP: No operation was performed because XX or NX flags. + * VALKEYMODULE_ZADD_ADDED: The new element was added to the sorted set. + * VALKEYMODULE_ZADD_UPDATED: The score of the element was updated. + * VALKEYMODULE_ZADD_NOP: No operation was performed because XX or NX flags. * - * On success the function returns REDISMODULE_OK. On the following errors - * REDISMODULE_ERR is returned: + * On success the function returns VALKEYMODULE_OK. On the following errors + * VALKEYMODULE_ERR is returned: * * * The key was not opened for writing. * * The key is of the wrong type. * * 'score' double value is not a number (NaN). */ -int RM_ZsetAdd(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr) { +int VM_ZsetAdd(ValkeyModuleKey *key, double score, ValkeyModuleString *ele, int *flagsptr) { int in_flags = 0, out_flags = 0; - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_ZSET); + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_ZSET); if (flagsptr) in_flags = moduleZsetAddFlagsToCoreFlags(*flagsptr); if (zsetAdd(key->value,score,ele->ptr,in_flags,&out_flags,NULL) == 0) { if (flagsptr) *flagsptr = 0; moduleDelKeyIfEmpty(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (flagsptr) *flagsptr = moduleZsetAddFlagsFromCoreFlags(out_flags); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* This function works exactly like RM_ZsetAdd(), but instead of setting +/* This function works exactly like VM_ZsetAdd(), but instead of setting * a new score, the score of the existing element is incremented, or if the * element does not already exist, it is added assuming the old score was * zero. * * The input and output flags, and the return value, have the same exact * meaning, with the only difference that this function will return - * REDISMODULE_ERR even when 'score' is a valid double number, but adding it + * VALKEYMODULE_ERR even when 'score' is a valid double number, but adding it * to the existing score results into a NaN (not a number) condition. * * This function has an additional field 'newscore', if not NULL is filled * with the new score of the element after the increment, if no error * is returned. */ -int RM_ZsetIncrby(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr, double *newscore) { +int VM_ZsetIncrby(ValkeyModuleKey *key, double score, ValkeyModuleString *ele, int *flagsptr, double *newscore) { int in_flags = 0, out_flags = 0; - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_ZSET); + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_ZSET); if (flagsptr) in_flags = moduleZsetAddFlagsToCoreFlags(*flagsptr); in_flags |= ZADD_IN_INCR; if (zsetAdd(key->value,score,ele->ptr,in_flags,&out_flags,newscore) == 0) { if (flagsptr) *flagsptr = 0; moduleDelKeyIfEmpty(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (flagsptr) *flagsptr = moduleZsetAddFlagsFromCoreFlags(out_flags); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Remove the specified element from the sorted set. - * The function returns REDISMODULE_OK on success, and REDISMODULE_ERR + * The function returns VALKEYMODULE_OK on success, and VALKEYMODULE_ERR * on one of the following conditions: * * * The key was not opened for writing. @@ -4851,48 +4852,48 @@ int RM_ZsetIncrby(RedisModuleKey *key, double score, RedisModuleString *ele, int * to know if the element was really removed. * * Empty keys will be handled correctly by doing nothing. */ -int RM_ZsetRem(RedisModuleKey *key, RedisModuleString *ele, int *deleted) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; +int VM_ZsetRem(ValkeyModuleKey *key, ValkeyModuleString *ele, int *deleted) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; if (key->value != NULL && zsetDel(key->value,ele->ptr)) { if (deleted) *deleted = 1; moduleDelKeyIfEmpty(key); } else { if (deleted) *deleted = 0; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* On success retrieve the double score associated at the sorted set element - * 'ele' and returns REDISMODULE_OK. Otherwise REDISMODULE_ERR is returned + * 'ele' and returns VALKEYMODULE_OK. Otherwise VALKEYMODULE_ERR is returned * to signal one of the following conditions: * * * There is no such element 'ele' in the sorted set. * * The key is not a sorted set. * * The key is an open empty key. */ -int RM_ZsetScore(RedisModuleKey *key, RedisModuleString *ele, double *score) { - if (key->value == NULL) return REDISMODULE_ERR; - if (key->value->type != OBJ_ZSET) return REDISMODULE_ERR; - if (zsetScore(key->value,ele->ptr,score) == C_ERR) return REDISMODULE_ERR; - return REDISMODULE_OK; +int VM_ZsetScore(ValkeyModuleKey *key, ValkeyModuleString *ele, double *score) { + if (key->value == NULL) return VALKEYMODULE_ERR; + if (key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; + if (zsetScore(key->value,ele->ptr,score) == C_ERR) return VALKEYMODULE_ERR; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- * ## Key API for Sorted Set iterator * -------------------------------------------------------------------------- */ -void zsetKeyReset(RedisModuleKey *key) { - key->u.zset.type = REDISMODULE_ZSET_RANGE_NONE; +void zsetKeyReset(ValkeyModuleKey *key) { + key->u.zset.type = VALKEYMODULE_ZSET_RANGE_NONE; key->u.zset.current = NULL; key->u.zset.er = 1; } /* Stop a sorted set iteration. */ -void RM_ZsetRangeStop(RedisModuleKey *key) { +void VM_ZsetRangeStop(ValkeyModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return; /* Free resources if needed. */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) zslFreeLexRange(&key->u.zset.lrs); /* Setup sensible values so that misused iteration API calls when an * iterator is not active will result into something more sensible @@ -4901,22 +4902,22 @@ void RM_ZsetRangeStop(RedisModuleKey *key) { } /* Return the "End of range" flag value to signal the end of the iteration. */ -int RM_ZsetRangeEndReached(RedisModuleKey *key) { +int VM_ZsetRangeEndReached(ValkeyModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 1; return key->u.zset.er; } -/* Helper function for RM_ZsetFirstInScoreRange() and RM_ZsetLastInScoreRange(). +/* Helper function for VM_ZsetFirstInScoreRange() and VM_ZsetLastInScoreRange(). * Setup the sorted set iteration according to the specified score range * (see the functions calling it for more info). If 'first' is true the * first element in the range is used as a starting point for the iterator - * otherwise the last. Return REDISMODULE_OK on success otherwise - * REDISMODULE_ERR. */ -int zsetInitScoreRange(RedisModuleKey *key, double min, double max, int minex, int maxex, int first) { - if (!key->value || key->value->type != OBJ_ZSET) return REDISMODULE_ERR; + * otherwise the last. Return VALKEYMODULE_OK on success otherwise + * VALKEYMODULE_ERR. */ +int zsetInitScoreRange(ValkeyModuleKey *key, double min, double max, int minex, int maxex, int first) { + if (!key->value || key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; - RM_ZsetRangeStop(key); - key->u.zset.type = REDISMODULE_ZSET_RANGE_SCORE; + VM_ZsetRangeStop(key); + key->u.zset.type = VALKEYMODULE_ZSET_RANGE_SCORE; key->u.zset.er = 0; /* Setup the range structure used by the sorted set core implementation @@ -4939,57 +4940,57 @@ int zsetInitScoreRange(RedisModuleKey *key, double min, double max, int minex, i serverPanic("Unsupported zset encoding"); } if (key->u.zset.current == NULL) key->u.zset.er = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Setup a sorted set iterator seeking the first element in the specified - * range. Returns REDISMODULE_OK if the iterator was correctly initialized - * otherwise REDISMODULE_ERR is returned in the following conditions: + * range. Returns VALKEYMODULE_OK if the iterator was correctly initialized + * otherwise VALKEYMODULE_ERR is returned in the following conditions: * * 1. The value stored at key is not a sorted set or the key is empty. * * The range is specified according to the two double values 'min' and 'max'. * Both can be infinite using the following two macros: * - * * REDISMODULE_POSITIVE_INFINITE for positive infinite value - * * REDISMODULE_NEGATIVE_INFINITE for negative infinite value + * * VALKEYMODULE_POSITIVE_INFINITE for positive infinite value + * * VALKEYMODULE_NEGATIVE_INFINITE for negative infinite value * * 'minex' and 'maxex' parameters, if true, respectively setup a range * where the min and max value are exclusive (not included) instead of * inclusive. */ -int RM_ZsetFirstInScoreRange(RedisModuleKey *key, double min, double max, int minex, int maxex) { +int VM_ZsetFirstInScoreRange(ValkeyModuleKey *key, double min, double max, int minex, int maxex) { return zsetInitScoreRange(key,min,max,minex,maxex,1); } -/* Exactly like RedisModule_ZsetFirstInScoreRange() but the last element of +/* Exactly like ValkeyModule_ZsetFirstInScoreRange() but the last element of * the range is selected for the start of the iteration instead. */ -int RM_ZsetLastInScoreRange(RedisModuleKey *key, double min, double max, int minex, int maxex) { +int VM_ZsetLastInScoreRange(ValkeyModuleKey *key, double min, double max, int minex, int maxex) { return zsetInitScoreRange(key,min,max,minex,maxex,0); } -/* Helper function for RM_ZsetFirstInLexRange() and RM_ZsetLastInLexRange(). +/* Helper function for VM_ZsetFirstInLexRange() and VM_ZsetLastInLexRange(). * Setup the sorted set iteration according to the specified lexicographical * range (see the functions calling it for more info). If 'first' is true the * first element in the range is used as a starting point for the iterator - * otherwise the last. Return REDISMODULE_OK on success otherwise - * REDISMODULE_ERR. + * otherwise the last. Return VALKEYMODULE_OK on success otherwise + * VALKEYMODULE_ERR. * * Note that this function takes 'min' and 'max' in the same form of the * Redis ZRANGEBYLEX command. */ -int zsetInitLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max, int first) { - if (!key->value || key->value->type != OBJ_ZSET) return REDISMODULE_ERR; +int zsetInitLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max, int first) { + if (!key->value || key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; - RM_ZsetRangeStop(key); + VM_ZsetRangeStop(key); key->u.zset.er = 0; /* Setup the range structure used by the sorted set core implementation * in order to seek at the specified element. */ zlexrangespec *zlrs = &key->u.zset.lrs; - if (zslParseLexRange(min, max, zlrs) == C_ERR) return REDISMODULE_ERR; + if (zslParseLexRange(min, max, zlrs) == C_ERR) return VALKEYMODULE_ERR; /* Set the range type to lex only after successfully parsing the range, * otherwise we don't want the zlexrangespec to be freed. */ - key->u.zset.type = REDISMODULE_ZSET_RANGE_LEX; + key->u.zset.type = VALKEYMODULE_ZSET_RANGE_LEX; if (key->value->encoding == OBJ_ENCODING_LISTPACK) { key->u.zset.current = first ? zzlFirstInLexRange(key->value->ptr,zlrs) : @@ -5004,36 +5005,36 @@ int zsetInitLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleStr } if (key->u.zset.current == NULL) key->u.zset.er = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Setup a sorted set iterator seeking the first element in the specified - * lexicographical range. Returns REDISMODULE_OK if the iterator was correctly - * initialized otherwise REDISMODULE_ERR is returned in the + * lexicographical range. Returns VALKEYMODULE_OK if the iterator was correctly + * initialized otherwise VALKEYMODULE_ERR is returned in the * following conditions: * * 1. The value stored at key is not a sorted set or the key is empty. * 2. The lexicographical range 'min' and 'max' format is invalid. * - * 'min' and 'max' should be provided as two RedisModuleString objects + * 'min' and 'max' should be provided as two ValkeyModuleString objects * in the same format as the parameters passed to the ZRANGEBYLEX command. * The function does not take ownership of the objects, so they can be released * ASAP after the iterator is setup. */ -int RM_ZsetFirstInLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) { +int VM_ZsetFirstInLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) { return zsetInitLexRange(key,min,max,1); } -/* Exactly like RedisModule_ZsetFirstInLexRange() but the last element of +/* Exactly like ValkeyModule_ZsetFirstInLexRange() but the last element of * the range is selected for the start of the iteration instead. */ -int RM_ZsetLastInLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) { +int VM_ZsetLastInLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) { return zsetInitLexRange(key,min,max,0); } /* Return the current sorted set element of an active sorted set iterator * or NULL if the range specified in the iterator does not include any * element. */ -RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score) { - RedisModuleString *str; +ValkeyModuleString *VM_ZsetRangeCurrentElement(ValkeyModuleKey *key, double *score) { + ValkeyModuleString *str; if (!key->value || key->value->type != OBJ_ZSET) return NULL; if (key->u.zset.current == NULL) return NULL; @@ -5053,14 +5054,14 @@ RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score } else { serverPanic("Unsupported zset encoding"); } - autoMemoryAdd(key->ctx,REDISMODULE_AM_STRING,str); + autoMemoryAdd(key->ctx,VALKEYMODULE_AM_STRING,str); return str; } /* Go to the next element of the sorted set iterator. Returns 1 if there was * a next element, 0 if we are already at the latest element or the range * does not include any item at all. */ -int RM_ZsetRangeNext(RedisModuleKey *key) { +int VM_ZsetRangeNext(ValkeyModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 0; if (!key->u.zset.type || !key->u.zset.current) return 0; /* No active iterator. */ @@ -5075,7 +5076,7 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE) { + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE) { /* Fetch the next element score for the * range check. */ unsigned char *saved_next = next; @@ -5086,7 +5087,7 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { return 0; } next = saved_next; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zzlLexValueLteMax(next,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5102,12 +5103,12 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE && + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE && !zslValueLteMax(next->score,&key->u.zset.rs)) { key->u.zset.er = 1; return 0; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zslLexValueLteMax(next->ele,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5124,7 +5125,7 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { /* Go to the previous element of the sorted set iterator. Returns 1 if there was * a previous element, 0 if we are already at the first element or the range * does not include any item at all. */ -int RM_ZsetRangePrev(RedisModuleKey *key) { +int VM_ZsetRangePrev(ValkeyModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 0; if (!key->u.zset.type || !key->u.zset.current) return 0; /* No active iterator. */ @@ -5139,7 +5140,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE) { + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE) { /* Fetch the previous element score for the * range check. */ unsigned char *saved_prev = prev; @@ -5150,7 +5151,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { return 0; } prev = saved_prev; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zzlLexValueGteMin(prev,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5166,12 +5167,12 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE && + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE && !zslValueGteMin(prev->score,&key->u.zset.rs)) { key->u.zset.er = 1; return 0; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zslLexValueGteMin(prev->ele,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5188,7 +5189,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { /* -------------------------------------------------------------------------- * ## Key API for Hash type * - * See also RM_ValueLength(), which returns the number of fields in a hash. + * See also VM_ValueLength(), which returns the number of fields in a hash. * -------------------------------------------------------------------------- */ /* Set the field of the specified hash field to the specified value. @@ -5196,33 +5197,33 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * hash value, in order to set the specified field. * * The function is variadic and the user must specify pairs of field - * names and values, both as RedisModuleString pointers (unless the + * names and values, both as ValkeyModuleString pointers (unless the * CFIELD option is set, see later). At the end of the field/value-ptr pairs, * NULL must be specified as last argument to signal the end of the arguments * in the variadic function. * * Example to set the hash argv[1] to the value argv[2]: * - * RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1],argv[2],NULL); + * ValkeyModule_HashSet(key,VALKEYMODULE_HASH_NONE,argv[1],argv[2],NULL); * * The function can also be used in order to delete fields (if they exist) - * by setting them to the specified value of REDISMODULE_HASH_DELETE: + * by setting them to the specified value of VALKEYMODULE_HASH_DELETE: * - * RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1], - * REDISMODULE_HASH_DELETE,NULL); + * ValkeyModule_HashSet(key,VALKEYMODULE_HASH_NONE,argv[1], + * VALKEYMODULE_HASH_DELETE,NULL); * * The behavior of the command changes with the specified flags, that can be - * set to REDISMODULE_HASH_NONE if no special behavior is needed. + * set to VALKEYMODULE_HASH_NONE if no special behavior is needed. * - * REDISMODULE_HASH_NX: The operation is performed only if the field was not + * VALKEYMODULE_HASH_NX: The operation is performed only if the field was not * already existing in the hash. - * REDISMODULE_HASH_XX: The operation is performed only if the field was + * VALKEYMODULE_HASH_XX: The operation is performed only if the field was * already existing, so that a new value could be * associated to an existing filed, but no new fields * are created. - * REDISMODULE_HASH_CFIELDS: The field names passed are null terminated C - * strings instead of RedisModuleString objects. - * REDISMODULE_HASH_COUNT_ALL: Include the number of inserted fields in the + * VALKEYMODULE_HASH_CFIELDS: The field names passed are null terminated C + * strings instead of ValkeyModuleString objects. + * VALKEYMODULE_HASH_COUNT_ALL: Include the number of inserted fields in the * returned number, in addition to the number of * updated and deleted fields. (Added in Redis * 6.2.) @@ -5230,18 +5231,18 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * Unless NX is specified, the command overwrites the old field value with * the new one. * - * When using REDISMODULE_HASH_CFIELDS, field names are reported using + * When using VALKEYMODULE_HASH_CFIELDS, field names are reported using * normal C strings, so for example to delete the field "foo" the following * code can be used: * - * RedisModule_HashSet(key,REDISMODULE_HASH_CFIELDS,"foo", - * REDISMODULE_HASH_DELETE,NULL); + * ValkeyModule_HashSet(key,VALKEYMODULE_HASH_CFIELDS,"foo", + * VALKEYMODULE_HASH_DELETE,NULL); * * Return value: * * The number of fields existing in the hash prior to the call, which have been * updated (its old value has been replaced by a new value) or deleted. If the - * flag REDISMODULE_HASH_COUNT_ALL is set, inserted fields not previously + * flag VALKEYMODULE_HASH_COUNT_ALL is set, inserted fields not previously * existing in the hash are also counted. * * If the return value is zero, `errno` is set (since Redis 6.2) as follows: @@ -5258,53 +5259,53 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * between Redis 6.2 and older versions. Modules that use it should determine * the Redis version and handle it accordingly. */ -int RM_HashSet(RedisModuleKey *key, int flags, ...) { +int VM_HashSet(ValkeyModuleKey *key, int flags, ...) { va_list ap; - if (!key || (flags & ~(REDISMODULE_HASH_NX | - REDISMODULE_HASH_XX | - REDISMODULE_HASH_CFIELDS | - REDISMODULE_HASH_COUNT_ALL))) { + if (!key || (flags & ~(VALKEYMODULE_HASH_NX | + VALKEYMODULE_HASH_XX | + VALKEYMODULE_HASH_CFIELDS | + VALKEYMODULE_HASH_COUNT_ALL))) { errno = EINVAL; return 0; } else if (key->value && key->value->type != OBJ_HASH) { errno = ENOTSUP; return 0; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return 0; } - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_HASH); + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_HASH); int count = 0; va_start(ap, flags); while(1) { - RedisModuleString *field, *value; + ValkeyModuleString *field, *value; /* Get the field and value objects. */ - if (flags & REDISMODULE_HASH_CFIELDS) { + if (flags & VALKEYMODULE_HASH_CFIELDS) { char *cfield = va_arg(ap,char*); if (cfield == NULL) break; field = createRawStringObject(cfield,strlen(cfield)); } else { - field = va_arg(ap,RedisModuleString*); + field = va_arg(ap,ValkeyModuleString*); if (field == NULL) break; } - value = va_arg(ap,RedisModuleString*); + value = va_arg(ap,ValkeyModuleString*); /* Handle XX and NX */ - if (flags & (REDISMODULE_HASH_XX|REDISMODULE_HASH_NX)) { + if (flags & (VALKEYMODULE_HASH_XX|VALKEYMODULE_HASH_NX)) { int exists = hashTypeExists(key->value, field->ptr); - if (((flags & REDISMODULE_HASH_XX) && !exists) || - ((flags & REDISMODULE_HASH_NX) && exists)) + if (((flags & VALKEYMODULE_HASH_XX) && !exists) || + ((flags & VALKEYMODULE_HASH_NX) && exists)) { - if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field); + if (flags & VALKEYMODULE_HASH_CFIELDS) decrRefCount(field); continue; } } - /* Handle deletion if value is REDISMODULE_HASH_DELETE. */ - if (value == REDISMODULE_HASH_DELETE) { + /* Handle deletion if value is VALKEYMODULE_HASH_DELETE. */ + if (value == VALKEYMODULE_HASH_DELETE) { count += hashTypeDelete(key->value, field->ptr); - if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field); + if (flags & VALKEYMODULE_HASH_CFIELDS) decrRefCount(field); continue; } @@ -5312,17 +5313,17 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) { /* If CFIELDS is active, we can pass the ownership of the * SDS object to the low level function that sets the field * to avoid a useless copy. */ - if (flags & REDISMODULE_HASH_CFIELDS) + if (flags & VALKEYMODULE_HASH_CFIELDS) low_flags |= HASH_SET_TAKE_FIELD; robj *argv[2] = {field,value}; hashTypeTryConversion(key->value,argv,0,1); int updated = hashTypeSet(key->value, field->ptr, value->ptr, low_flags); - count += (flags & REDISMODULE_HASH_COUNT_ALL) ? 1 : updated; + count += (flags & VALKEYMODULE_HASH_COUNT_ALL) ? 1 : updated; /* If CFIELDS is active, SDS string ownership is now of hashTypeSet(), * however we still have to release the 'field' object shell. */ - if (flags & REDISMODULE_HASH_CFIELDS) { + if (flags & VALKEYMODULE_HASH_CFIELDS) { field->ptr = NULL; /* Prevent the SDS string from being freed. */ decrRefCount(field); } @@ -5334,73 +5335,73 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) { } /* Get fields from a hash value. This function is called using a variable - * number of arguments, alternating a field name (as a RedisModuleString - * pointer) with a pointer to a RedisModuleString pointer, that is set to the + * number of arguments, alternating a field name (as a ValkeyModuleString + * pointer) with a pointer to a ValkeyModuleString pointer, that is set to the * value of the field if the field exists, or NULL if the field does not exist. * At the end of the field/value-ptr pairs, NULL must be specified as last * argument to signal the end of the arguments in the variadic function. * * This is an example usage: * - * RedisModuleString *first, *second; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_NONE,argv[1],&first, + * ValkeyModuleString *first, *second; + * ValkeyModule_HashGet(mykey,VALKEYMODULE_HASH_NONE,argv[1],&first, * argv[2],&second,NULL); * - * As with RedisModule_HashSet() the behavior of the command can be specified - * passing flags different than REDISMODULE_HASH_NONE: + * As with ValkeyModule_HashSet() the behavior of the command can be specified + * passing flags different than VALKEYMODULE_HASH_NONE: * - * REDISMODULE_HASH_CFIELDS: field names as null terminated C strings. + * VALKEYMODULE_HASH_CFIELDS: field names as null terminated C strings. * - * REDISMODULE_HASH_EXISTS: instead of setting the value of the field - * expecting a RedisModuleString pointer to pointer, the function just + * VALKEYMODULE_HASH_EXISTS: instead of setting the value of the field + * expecting a ValkeyModuleString pointer to pointer, the function just * reports if the field exists or not and expects an integer pointer * as the second element of each pair. * - * Example of REDISMODULE_HASH_CFIELDS: + * Example of VALKEYMODULE_HASH_CFIELDS: * - * RedisModuleString *username, *hashedpass; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_CFIELDS,"username",&username,"hp",&hashedpass, NULL); + * ValkeyModuleString *username, *hashedpass; + * ValkeyModule_HashGet(mykey,VALKEYMODULE_HASH_CFIELDS,"username",&username,"hp",&hashedpass, NULL); * - * Example of REDISMODULE_HASH_EXISTS: + * Example of VALKEYMODULE_HASH_EXISTS: * * int exists; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_EXISTS,argv[1],&exists,NULL); + * ValkeyModule_HashGet(mykey,VALKEYMODULE_HASH_EXISTS,argv[1],&exists,NULL); * - * The function returns REDISMODULE_OK on success and REDISMODULE_ERR if + * The function returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR if * the key is not a hash value. * * Memory management: * - * The returned RedisModuleString objects should be released with - * RedisModule_FreeString(), or by enabling automatic memory management. + * The returned ValkeyModuleString objects should be released with + * ValkeyModule_FreeString(), or by enabling automatic memory management. */ -int RM_HashGet(RedisModuleKey *key, int flags, ...) { +int VM_HashGet(ValkeyModuleKey *key, int flags, ...) { va_list ap; - if (key->value && key->value->type != OBJ_HASH) return REDISMODULE_ERR; + if (key->value && key->value->type != OBJ_HASH) return VALKEYMODULE_ERR; va_start(ap, flags); while(1) { - RedisModuleString *field, **valueptr; + ValkeyModuleString *field, **valueptr; int *existsptr; /* Get the field object and the value pointer to pointer. */ - if (flags & REDISMODULE_HASH_CFIELDS) { + if (flags & VALKEYMODULE_HASH_CFIELDS) { char *cfield = va_arg(ap,char*); if (cfield == NULL) break; field = createRawStringObject(cfield,strlen(cfield)); } else { - field = va_arg(ap,RedisModuleString*); + field = va_arg(ap,ValkeyModuleString*); if (field == NULL) break; } /* Query the hash for existence or value object. */ - if (flags & REDISMODULE_HASH_EXISTS) { + if (flags & VALKEYMODULE_HASH_EXISTS) { existsptr = va_arg(ap,int*); if (key->value) *existsptr = hashTypeExists(key->value,field->ptr); else *existsptr = 0; } else { - valueptr = va_arg(ap,RedisModuleString**); + valueptr = va_arg(ap,ValkeyModuleString**); if (key->value) { *valueptr = hashTypeGetValueObject(key->value,field->ptr); if (*valueptr) { @@ -5409,17 +5410,17 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { *valueptr = decoded; } if (*valueptr) - autoMemoryAdd(key->ctx,REDISMODULE_AM_STRING,*valueptr); + autoMemoryAdd(key->ctx,VALKEYMODULE_AM_STRING,*valueptr); } else { *valueptr = NULL; } } /* Cleanup */ - if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field); + if (flags & VALKEYMODULE_HASH_CFIELDS) decrRefCount(field); } va_end(ap); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -5427,23 +5428,23 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { * * For an introduction to streams, see https://redis.io/topics/streams-intro. * - * The type RedisModuleStreamID, which is used in stream functions, is a struct + * The type ValkeyModuleStreamID, which is used in stream functions, is a struct * with two 64-bit fields and is defined as * - * typedef struct RedisModuleStreamID { + * typedef struct ValkeyModuleStreamID { * uint64_t ms; * uint64_t seq; - * } RedisModuleStreamID; + * } ValkeyModuleStreamID; * - * See also RM_ValueLength(), which returns the length of a stream, and the - * conversion functions RM_StringToStreamID() and RM_CreateStringFromStreamID(). + * See also VM_ValueLength(), which returns the length of a stream, and the + * conversion functions VM_StringToStreamID() and VM_CreateStringFromStreamID(). * -------------------------------------------------------------------------- */ /* Adds an entry to a stream. Like XADD without trimming. * * - `key`: The key where the stream is (or will be) stored * - `flags`: A bit field of - * - `REDISMODULE_STREAM_ADD_AUTOID`: Assign a stream ID automatically, like + * - `VALKEYMODULE_STREAM_ADD_AUTOID`: Assign a stream ID automatically, like * `*` in the XADD command. * - `id`: If the `AUTOID` flag is set, this is where the assigned ID is * returned. Can be NULL if `AUTOID` is set, if you don't care to receive the @@ -5452,8 +5453,8 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { * fields and values. * - `numfields`: The number of field-value pairs in `argv`. * - * Returns REDISMODULE_OK if an entry has been added. On failure, - * REDISMODULE_ERR is returned and `errno` is set as follows: + * Returns VALKEYMODULE_OK if an entry has been added. On failure, + * VALKEYMODULE_ERR is returned and `errno` is set as follows: * * - EINVAL if called with invalid arguments * - ENOTSUP if the key refers to a value of a type other than stream @@ -5463,29 +5464,29 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { * - EFBIG if the stream has reached the last possible ID * - ERANGE if the elements are too large to be stored. */ -int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisModuleString **argv, long numfields) { +int VM_StreamAdd(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id, ValkeyModuleString **argv, long numfields) { /* Validate args */ if (!key || (numfields != 0 && !argv) || /* invalid key or argv */ - (flags & ~(REDISMODULE_STREAM_ADD_AUTOID)) || /* invalid flags */ - (!(flags & REDISMODULE_STREAM_ADD_AUTOID) && !id)) { /* id required */ + (flags & ~(VALKEYMODULE_STREAM_ADD_AUTOID)) || /* invalid flags */ + (!(flags & VALKEYMODULE_STREAM_ADD_AUTOID) && !id)) { /* id required */ errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->value && key->value->type != OBJ_STREAM) { errno = ENOTSUP; /* wrong type */ - return REDISMODULE_ERR; - } else if (!(key->mode & REDISMODULE_WRITE)) { + return VALKEYMODULE_ERR; + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; /* key not open for writing */ - return REDISMODULE_ERR; - } else if (!(flags & REDISMODULE_STREAM_ADD_AUTOID) && + return VALKEYMODULE_ERR; + } else if (!(flags & VALKEYMODULE_STREAM_ADD_AUTOID) && id->ms == 0 && id->seq == 0) { errno = EDOM; /* ID out of range */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Create key if necessary */ int created = 0; if (key->value == NULL) { - moduleCreateEmptyKey(key, REDISMODULE_KEYTYPE_STREAM); + moduleCreateEmptyKey(key, VALKEYMODULE_KEYTYPE_STREAM); created = 1; } @@ -5493,13 +5494,13 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM if (s->last_id.ms == UINT64_MAX && s->last_id.seq == UINT64_MAX) { /* The stream has reached the last possible ID */ errno = EFBIG; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamID added_id; streamID use_id; streamID *use_id_ptr = NULL; - if (!(flags & REDISMODULE_STREAM_ADD_AUTOID)) { + if (!(flags & VALKEYMODULE_STREAM_ADD_AUTOID)) { use_id.ms = id->ms; use_id.seq = id->seq; use_id_ptr = &use_id; @@ -5510,7 +5511,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * the elements are too large to be stored. either way, errno is already * set by streamAppendItem. */ if (created) moduleDelKeyIfEmpty(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Postponed signalKeyAsReady(). Done implicitly by moduleCreateEmptyKey() * so not needed if the stream has just been created. */ @@ -5521,7 +5522,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM id->seq = added_id.seq; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Deletes an entry from a stream. @@ -5529,7 +5530,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * - `key`: A key opened for writing, with no stream iterator started. * - `id`: The stream ID of the entry to delete. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with invalid arguments @@ -5539,44 +5540,44 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * associated with the key * - ENOENT if no entry with the given stream ID exists * - * See also RM_StreamIteratorDelete() for deleting the current entry while + * See also VM_StreamIteratorDelete() for deleting the current entry while * iterating using a stream iterator. */ -int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { +int VM_StreamDelete(ValkeyModuleKey *key, ValkeyModuleStreamID *id) { if (!key || !id) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; /* wrong type */ - return REDISMODULE_ERR; - } else if (!(key->mode & REDISMODULE_WRITE) || + return VALKEYMODULE_ERR; + } else if (!(key->mode & VALKEYMODULE_WRITE) || key->iter != NULL) { errno = EBADF; /* key not opened for writing or iterator started */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } stream *s = key->value->ptr; streamID streamid = {id->ms, id->seq}; if (streamDeleteItem(s, &streamid)) { - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { errno = ENOENT; /* no entry with this id */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* Sets up a stream iterator. * - * - `key`: The stream key opened for reading using RedisModule_OpenKey(). + * - `key`: The stream key opened for reading using ValkeyModule_OpenKey(). * - `flags`: - * - `REDISMODULE_STREAM_ITERATOR_EXCLUSIVE`: Don't include `start` and `end` + * - `VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE`: Don't include `start` and `end` * in the iterated range. - * - `REDISMODULE_STREAM_ITERATOR_REVERSE`: Iterate in reverse order, starting + * - `VALKEYMODULE_STREAM_ITERATOR_REVERSE`: Iterate in reverse order, starting * from the `end` of the range. * - `start`: The lower bound of the range. Use NULL for the beginning of the * stream. * - `end`: The upper bound of the range. Use NULL for the end of the stream. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with invalid arguments @@ -5586,76 +5587,76 @@ int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { * already associated with the key * - EDOM if `start` or `end` is outside the valid range * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR if the key doesn't + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR if the key doesn't * refer to a stream or if invalid arguments were given. * - * The stream IDs are retrieved using RedisModule_StreamIteratorNextID() and + * The stream IDs are retrieved using ValkeyModule_StreamIteratorNextID() and * for each stream ID, the fields and values are retrieved using - * RedisModule_StreamIteratorNextField(). The iterator is freed by calling - * RedisModule_StreamIteratorStop(). + * ValkeyModule_StreamIteratorNextField(). The iterator is freed by calling + * ValkeyModule_StreamIteratorStop(). * * Example (error handling omitted): * - * RedisModule_StreamIteratorStart(key, 0, startid_ptr, endid_ptr); - * RedisModuleStreamID id; + * ValkeyModule_StreamIteratorStart(key, 0, startid_ptr, endid_ptr); + * ValkeyModuleStreamID id; * long numfields; - * while (RedisModule_StreamIteratorNextID(key, &id, &numfields) == - * REDISMODULE_OK) { - * RedisModuleString *field, *value; - * while (RedisModule_StreamIteratorNextField(key, &field, &value) == - * REDISMODULE_OK) { + * while (ValkeyModule_StreamIteratorNextID(key, &id, &numfields) == + * VALKEYMODULE_OK) { + * ValkeyModuleString *field, *value; + * while (ValkeyModule_StreamIteratorNextField(key, &field, &value) == + * VALKEYMODULE_OK) { * // * // ... Do stuff ... * // - * RedisModule_FreeString(ctx, field); - * RedisModule_FreeString(ctx, value); + * ValkeyModule_FreeString(ctx, field); + * ValkeyModule_FreeString(ctx, value); * } * } - * RedisModule_StreamIteratorStop(key); + * ValkeyModule_StreamIteratorStop(key); */ -int RM_StreamIteratorStart(RedisModuleKey *key, int flags, RedisModuleStreamID *start, RedisModuleStreamID *end) { +int VM_StreamIteratorStart(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *start, ValkeyModuleStreamID *end) { /* check args */ if (!key || - (flags & ~(REDISMODULE_STREAM_ITERATOR_EXCLUSIVE | - REDISMODULE_STREAM_ITERATOR_REVERSE))) { + (flags & ~(VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE | + VALKEYMODULE_STREAM_ITERATOR_REVERSE))) { errno = EINVAL; /* key missing or invalid flags */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; /* not a stream */ + return VALKEYMODULE_ERR; /* not a stream */ } else if (key->iter) { errno = EBADF; /* iterator already started */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* define range for streamIteratorStart() */ streamID lower, upper; if (start) lower = (streamID){start->ms, start->seq}; if (end) upper = (streamID){end->ms, end->seq}; - if (flags & REDISMODULE_STREAM_ITERATOR_EXCLUSIVE) { + if (flags & VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE) { if ((start && streamIncrID(&lower) != C_OK) || (end && streamDecrID(&upper) != C_OK)) { errno = EDOM; /* end is 0-0 or start is MAX-MAX? */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* create iterator */ stream *s = key->value->ptr; - int rev = flags & REDISMODULE_STREAM_ITERATOR_REVERSE; + int rev = flags & VALKEYMODULE_STREAM_ITERATOR_REVERSE; streamIterator *si = zmalloc(sizeof(*si)); streamIteratorStart(si, s, start ? &lower : NULL, end ? &upper : NULL, rev); key->iter = si; - key->u.stream.currentid.ms = 0; /* for RM_StreamIteratorDelete() */ + key->u.stream.currentid.ms = 0; /* for VM_StreamIteratorDelete() */ key->u.stream.currentid.seq = 0; - key->u.stream.numfieldsleft = 0; /* for RM_StreamIteratorNextField() */ - return REDISMODULE_OK; + key->u.stream.numfieldsleft = 0; /* for VM_StreamIteratorNextField() */ + return VALKEYMODULE_OK; } -/* Stops a stream iterator created using RedisModule_StreamIteratorStart() and +/* Stops a stream iterator created using ValkeyModule_StreamIteratorStart() and * reclaims its memory. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with a NULL key @@ -5664,34 +5665,34 @@ int RM_StreamIteratorStart(RedisModuleKey *key, int flags, RedisModuleStreamID * * - EBADF if the key was not opened for writing or if no stream iterator is * associated with the key */ -int RM_StreamIteratorStop(RedisModuleKey *key) { +int VM_StreamIteratorStop(ValkeyModuleKey *key) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIteratorStop(key->iter); zfree(key->iter); key->iter = NULL; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Finds the next stream entry and returns its stream ID and the number of * fields. * * - `key`: Key for which a stream iterator has been started using - * RedisModule_StreamIteratorStart(). + * ValkeyModule_StreamIteratorStart(). * - `id`: The stream ID returned. NULL if you don't care. * - `numfields`: The number of fields in the found stream entry. NULL if you * don't care. * - * Returns REDISMODULE_OK and sets `*id` and `*numfields` if an entry was found. - * On failure, REDISMODULE_ERR is returned and `errno` is set as follows: + * Returns VALKEYMODULE_OK and sets `*id` and `*numfields` if an entry was found. + * On failure, VALKEYMODULE_ERR is returned and `errno` is set as follows: * * - EINVAL if called with a NULL key * - ENOTSUP if the key refers to a value of a type other than stream or if the @@ -5699,23 +5700,23 @@ int RM_StreamIteratorStop(RedisModuleKey *key) { * - EBADF if no stream iterator is associated with the key * - ENOENT if there are no more entries in the range of the iterator * - * In practice, if RM_StreamIteratorNextID() is called after a successful call - * to RM_StreamIteratorStart() and with the same key, it is safe to assume that - * an REDISMODULE_ERR return value means that there are no more entries. + * In practice, if VM_StreamIteratorNextID() is called after a successful call + * to VM_StreamIteratorStart() and with the same key, it is safe to assume that + * an VALKEYMODULE_ERR return value means that there are no more entries. * - * Use RedisModule_StreamIteratorNextField() to retrieve the fields and values. - * See the example at RedisModule_StreamIteratorStart(). + * Use ValkeyModule_StreamIteratorNextField() to retrieve the fields and values. + * See the example at ValkeyModule_StreamIteratorStart(). */ -int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) { +int VM_StreamIteratorNextID(ValkeyModuleKey *key, ValkeyModuleStreamID *id, long *numfields) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIterator *si = key->iter; int64_t *num_ptr = &key->u.stream.numfieldsleft; @@ -5726,29 +5727,29 @@ int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long * id->seq = streamid_ptr->seq; } if (numfields) *numfields = *num_ptr; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { /* No entry found. */ - key->u.stream.currentid.ms = 0; /* for RM_StreamIteratorDelete() */ + key->u.stream.currentid.ms = 0; /* for VM_StreamIteratorDelete() */ key->u.stream.currentid.seq = 0; - key->u.stream.numfieldsleft = 0; /* for RM_StreamIteratorNextField() */ + key->u.stream.numfieldsleft = 0; /* for VM_StreamIteratorNextField() */ errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* Retrieves the next field of the current stream ID and its corresponding value * in a stream iteration. This function should be called repeatedly after calling - * RedisModule_StreamIteratorNextID() to fetch each field-value pair. + * ValkeyModule_StreamIteratorNextID() to fetch each field-value pair. * * - `key`: Key where a stream iterator has been started. * - `field_ptr`: This is where the field is returned. * - `value_ptr`: This is where the value is returned. * - * Returns REDISMODULE_OK and points `*field_ptr` and `*value_ptr` to freshly - * allocated RedisModuleString objects. The string objects are freed + * Returns VALKEYMODULE_OK and points `*field_ptr` and `*value_ptr` to freshly + * allocated ValkeyModuleString objects. The string objects are freed * automatically when the callback finishes if automatic memory is enabled. On - * failure, REDISMODULE_ERR is returned and `errno` is set as follows: + * failure, VALKEYMODULE_ERR is returned and `errno` is set as follows: * * - EINVAL if called with a NULL key * - ENOTSUP if the key refers to a value of a type other than stream or if the @@ -5756,25 +5757,25 @@ int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long * * - EBADF if no stream iterator is associated with the key * - ENOENT if there are no more fields in the current stream entry * - * In practice, if RM_StreamIteratorNextField() is called after a successful - * call to RM_StreamIteratorNextID() and with the same key, it is safe to assume - * that an REDISMODULE_ERR return value means that there are no more fields. + * In practice, if VM_StreamIteratorNextField() is called after a successful + * call to VM_StreamIteratorNextID() and with the same key, it is safe to assume + * that an VALKEYMODULE_ERR return value means that there are no more fields. * - * See the example at RedisModule_StreamIteratorStart(). + * See the example at ValkeyModule_StreamIteratorStart(). */ -int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) { +int VM_StreamIteratorNextField(ValkeyModuleKey *key, ValkeyModuleString **field_ptr, ValkeyModuleString **value_ptr) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->u.stream.numfieldsleft <= 0) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIterator *si = key->iter; unsigned char *field, *value; @@ -5782,22 +5783,22 @@ int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_pt streamIteratorGetField(si, &field, &value, &field_len, &value_len); if (field_ptr) { *field_ptr = createRawStringObject((char *)field, field_len); - autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *field_ptr); + autoMemoryAdd(key->ctx, VALKEYMODULE_AM_STRING, *field_ptr); } if (value_ptr) { *value_ptr = createRawStringObject((char *)value, value_len); - autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *value_ptr); + autoMemoryAdd(key->ctx, VALKEYMODULE_AM_STRING, *value_ptr); } key->u.stream.numfieldsleft--; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Deletes the current stream entry while iterating. * - * This function can be called after RM_StreamIteratorNextID() or after any - * calls to RM_StreamIteratorNextField(). + * This function can be called after VM_StreamIteratorNextID() or after any + * calls to VM_StreamIteratorNextField(). * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if key is NULL @@ -5805,34 +5806,34 @@ int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_pt * - EBADF if the key is not opened for writing, if no iterator has been started * - ENOENT if the iterator has no current stream entry */ -int RM_StreamIteratorDelete(RedisModuleKey *key) { +int VM_StreamIteratorDelete(ValkeyModuleKey *key) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; - } else if (!(key->mode & REDISMODULE_WRITE) || !key->iter) { + return VALKEYMODULE_ERR; + } else if (!(key->mode & VALKEYMODULE_WRITE) || !key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->u.stream.currentid.ms == 0 && key->u.stream.currentid.seq == 0) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIterator *si = key->iter; streamIteratorRemoveEntry(si, &key->u.stream.currentid); key->u.stream.currentid.ms = 0; /* Make sure repeated Delete() fails */ key->u.stream.currentid.seq = 0; key->u.stream.numfieldsleft = 0; /* Make sure NextField() fails */ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Trim a stream by length, similar to XTRIM with MAXLEN. * * - `key`: Key opened for writing. * - `flags`: A bitfield of - * - `REDISMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, + * - `VALKEYMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, * like XTRIM with `~`. * - `length`: The number of stream entries to keep after trimming. * @@ -5843,18 +5844,18 @@ int RM_StreamIteratorDelete(RedisModuleKey *key) { * - ENOTSUP if the key is empty or of a type other than stream * - EBADF if the key is not opened for writing */ -long long RM_StreamTrimByLength(RedisModuleKey *key, int flags, long long length) { - if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || length < 0) { +long long VM_StreamTrimByLength(ValkeyModuleKey *key, int flags, long long length) { + if (!key || (flags & ~(VALKEYMODULE_STREAM_TRIM_APPROX)) || length < 0) { errno = EINVAL; return -1; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; return -1; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return -1; } - int approx = flags & REDISMODULE_STREAM_TRIM_APPROX ? 1 : 0; + int approx = flags & VALKEYMODULE_STREAM_TRIM_APPROX ? 1 : 0; return streamTrimByLength((stream *)key->value->ptr, length, approx); } @@ -5862,7 +5863,7 @@ long long RM_StreamTrimByLength(RedisModuleKey *key, int flags, long long length * * - `key`: Key opened for writing. * - `flags`: A bitfield of - * - `REDISMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, + * - `VALKEYMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, * like XTRIM with `~`. * - `id`: The smallest stream ID to keep after trimming. * @@ -5873,18 +5874,18 @@ long long RM_StreamTrimByLength(RedisModuleKey *key, int flags, long long length * - ENOTSUP if the key is empty or of a type other than stream * - EBADF if the key is not opened for writing */ -long long RM_StreamTrimByID(RedisModuleKey *key, int flags, RedisModuleStreamID *id) { - if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || !id) { +long long VM_StreamTrimByID(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id) { + if (!key || (flags & ~(VALKEYMODULE_STREAM_TRIM_APPROX)) || !id) { errno = EINVAL; return -1; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; return -1; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return -1; } - int approx = flags & REDISMODULE_STREAM_TRIM_APPROX ? 1 : 0; + int approx = flags & VALKEYMODULE_STREAM_TRIM_APPROX ? 1 : 0; streamID minid = (streamID){id->ms, id->seq}; return streamTrimByID((stream *)key->value->ptr, minid, approx); } @@ -5892,28 +5893,28 @@ long long RM_StreamTrimByID(RedisModuleKey *key, int flags, RedisModuleStreamID /* -------------------------------------------------------------------------- * ## Calling Redis commands from modules * - * RM_Call() sends a command to Redis. The remaining functions handle the reply. + * VM_Call() sends a command to Redis. The remaining functions handle the reply. * -------------------------------------------------------------------------- */ -void moduleParseCallReply_Int(RedisModuleCallReply *reply); -void moduleParseCallReply_BulkString(RedisModuleCallReply *reply); -void moduleParseCallReply_SimpleString(RedisModuleCallReply *reply); -void moduleParseCallReply_Array(RedisModuleCallReply *reply); +void moduleParseCallReply_Int(ValkeyModuleCallReply *reply); +void moduleParseCallReply_BulkString(ValkeyModuleCallReply *reply); +void moduleParseCallReply_SimpleString(ValkeyModuleCallReply *reply); +void moduleParseCallReply_Array(ValkeyModuleCallReply *reply); /* Free a Call reply and all the nested replies it contains if it's an * array. */ -void RM_FreeCallReply(RedisModuleCallReply *reply) { +void VM_FreeCallReply(ValkeyModuleCallReply *reply) { /* This is a wrapper for the recursive free reply function. This is needed * in order to have the first level function to return on nested replies, * but only if called by the module API. */ - RedisModuleCtx *ctx = NULL; - if(callReplyType(reply) == REDISMODULE_REPLY_PROMISE) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); + ValkeyModuleCtx *ctx = NULL; + if(callReplyType(reply) == VALKEYMODULE_REPLY_PROMISE) { + ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); ctx = promise->ctx; freeRedisModuleAsyncRMCallPromise(promise); } else { @@ -5922,131 +5923,131 @@ void RM_FreeCallReply(RedisModuleCallReply *reply) { freeCallReply(reply); if (ctx) { - autoMemoryFreed(ctx,REDISMODULE_AM_REPLY,reply); + autoMemoryFreed(ctx,VALKEYMODULE_AM_REPLY,reply); } } /* Return the reply type as one of the following: * - * - REDISMODULE_REPLY_UNKNOWN - * - REDISMODULE_REPLY_STRING - * - REDISMODULE_REPLY_ERROR - * - REDISMODULE_REPLY_INTEGER - * - REDISMODULE_REPLY_ARRAY - * - REDISMODULE_REPLY_NULL - * - REDISMODULE_REPLY_MAP - * - REDISMODULE_REPLY_SET - * - REDISMODULE_REPLY_BOOL - * - REDISMODULE_REPLY_DOUBLE - * - REDISMODULE_REPLY_BIG_NUMBER - * - REDISMODULE_REPLY_VERBATIM_STRING - * - REDISMODULE_REPLY_ATTRIBUTE - * - REDISMODULE_REPLY_PROMISE */ -int RM_CallReplyType(RedisModuleCallReply *reply) { + * - VALKEYMODULE_REPLY_UNKNOWN + * - VALKEYMODULE_REPLY_STRING + * - VALKEYMODULE_REPLY_ERROR + * - VALKEYMODULE_REPLY_INTEGER + * - VALKEYMODULE_REPLY_ARRAY + * - VALKEYMODULE_REPLY_NULL + * - VALKEYMODULE_REPLY_MAP + * - VALKEYMODULE_REPLY_SET + * - VALKEYMODULE_REPLY_BOOL + * - VALKEYMODULE_REPLY_DOUBLE + * - VALKEYMODULE_REPLY_BIG_NUMBER + * - VALKEYMODULE_REPLY_VERBATIM_STRING + * - VALKEYMODULE_REPLY_ATTRIBUTE + * - VALKEYMODULE_REPLY_PROMISE */ +int VM_CallReplyType(ValkeyModuleCallReply *reply) { return callReplyType(reply); } /* Return the reply type length, where applicable. */ -size_t RM_CallReplyLength(RedisModuleCallReply *reply) { +size_t VM_CallReplyLength(ValkeyModuleCallReply *reply) { return callReplyGetLen(reply); } /* Return the 'idx'-th nested call reply element of an array reply, or NULL * if the reply type is wrong or the index is out of range. */ -RedisModuleCallReply *RM_CallReplyArrayElement(RedisModuleCallReply *reply, size_t idx) { +ValkeyModuleCallReply *VM_CallReplyArrayElement(ValkeyModuleCallReply *reply, size_t idx) { return callReplyGetArrayElement(reply, idx); } /* Return the `long long` of an integer reply. */ -long long RM_CallReplyInteger(RedisModuleCallReply *reply) { +long long VM_CallReplyInteger(ValkeyModuleCallReply *reply) { return callReplyGetLongLong(reply); } /* Return the double value of a double reply. */ -double RM_CallReplyDouble(RedisModuleCallReply *reply) { +double VM_CallReplyDouble(ValkeyModuleCallReply *reply) { return callReplyGetDouble(reply); } /* Return the big number value of a big number reply. */ -const char *RM_CallReplyBigNumber(RedisModuleCallReply *reply, size_t *len) { +const char *VM_CallReplyBigNumber(ValkeyModuleCallReply *reply, size_t *len) { return callReplyGetBigNumber(reply, len); } /* Return the value of a verbatim string reply, * An optional output argument can be given to get verbatim reply format. */ -const char *RM_CallReplyVerbatim(RedisModuleCallReply *reply, size_t *len, const char **format) { +const char *VM_CallReplyVerbatim(ValkeyModuleCallReply *reply, size_t *len, const char **format) { return callReplyGetVerbatim(reply, len, format); } /* Return the Boolean value of a Boolean reply. */ -int RM_CallReplyBool(RedisModuleCallReply *reply) { +int VM_CallReplyBool(ValkeyModuleCallReply *reply) { return callReplyGetBool(reply); } /* Return the 'idx'-th nested call reply element of a set reply, or NULL * if the reply type is wrong or the index is out of range. */ -RedisModuleCallReply *RM_CallReplySetElement(RedisModuleCallReply *reply, size_t idx) { +ValkeyModuleCallReply *VM_CallReplySetElement(ValkeyModuleCallReply *reply, size_t idx) { return callReplyGetSetElement(reply, idx); } /* Retrieve the 'idx'-th key and value of a map reply. * * Returns: - * - REDISMODULE_OK on success. - * - REDISMODULE_ERR if idx out of range or if the reply type is wrong. + * - VALKEYMODULE_OK on success. + * - VALKEYMODULE_ERR if idx out of range or if the reply type is wrong. * * The `key` and `value` arguments are used to return by reference, and may be * NULL if not required. */ -int RM_CallReplyMapElement(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) { +int VM_CallReplyMapElement(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) { if (callReplyGetMapElement(reply, idx, key, val) == C_OK){ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Return the attribute of the given reply, or NULL if no attribute exists. */ -RedisModuleCallReply *RM_CallReplyAttribute(RedisModuleCallReply *reply) { +ValkeyModuleCallReply *VM_CallReplyAttribute(ValkeyModuleCallReply *reply) { return callReplyGetAttribute(reply); } /* Retrieve the 'idx'-th key and value of an attribute reply. * * Returns: - * - REDISMODULE_OK on success. - * - REDISMODULE_ERR if idx out of range or if the reply type is wrong. + * - VALKEYMODULE_OK on success. + * - VALKEYMODULE_ERR if idx out of range or if the reply type is wrong. * * The `key` and `value` arguments are used to return by reference, and may be * NULL if not required. */ -int RM_CallReplyAttributeElement(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) { +int VM_CallReplyAttributeElement(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) { if (callReplyGetAttributeElement(reply, idx, key, val) == C_OK){ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } -/* Set unblock handler (callback and private data) on the given promise RedisModuleCallReply. - * The given reply must be of promise type (REDISMODULE_REPLY_PROMISE). */ -void RM_CallReplyPromiseSetUnblockHandler(RedisModuleCallReply *reply, RedisModuleOnUnblocked on_unblock, void *private_data) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); +/* Set unblock handler (callback and private data) on the given promise ValkeyModuleCallReply. + * The given reply must be of promise type (VALKEYMODULE_REPLY_PROMISE). */ +void VM_CallReplyPromiseSetUnblockHandler(ValkeyModuleCallReply *reply, ValkeyModuleOnUnblocked on_unblock, void *private_data) { + ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); promise->on_unblocked = on_unblock; promise->private_data = private_data; } -/* Abort the execution of a given promise RedisModuleCallReply. - * return REDMODULE_OK in case the abort was done successfully and REDISMODULE_ERR +/* Abort the execution of a given promise ValkeyModuleCallReply. + * return REDMODULE_OK in case the abort was done successfully and VALKEYMODULE_ERR * if its not possible to abort the execution (execution already finished). * In case the execution was aborted (REDMODULE_OK was returned), the private_data out parameter - * will be set with the value of the private data that was given on 'RM_CallReplyPromiseSetUnblockHandler' + * will be set with the value of the private data that was given on 'VM_CallReplyPromiseSetUnblockHandler' * so the caller will be able to release the private data. * * If the execution was aborted successfully, it is promised that the unblock handler will not be called. * That said, it is possible that the abort operation will successes but the operation will still continue. * This can happened if, for example, a module implements some blocking command and does not respect the * disconnect callback. For pure Redis commands this can not happened.*/ -int RM_CallReplyPromiseAbort(RedisModuleCallReply *reply, void **private_data) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); - if (!promise->c) return REDISMODULE_ERR; /* Promise can not be aborted, either already aborted or already finished. */ - if (!(promise->c->flags & CLIENT_BLOCKED)) return REDISMODULE_ERR; /* Client is not blocked anymore, can not abort it. */ +int VM_CallReplyPromiseAbort(ValkeyModuleCallReply *reply, void **private_data) { + ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); + if (!promise->c) return VALKEYMODULE_ERR; /* Promise can not be aborted, either already aborted or already finished. */ + if (!(promise->c->flags & CLIENT_BLOCKED)) return VALKEYMODULE_ERR; /* Client is not blocked anymore, can not abort it. */ /* Client is still blocked, remove it from any blocking state and release it. */ if (private_data) *private_data = promise->private_data; @@ -6054,11 +6055,11 @@ int RM_CallReplyPromiseAbort(RedisModuleCallReply *reply, void **private_data) { promise->on_unblocked = NULL; unblockClient(promise->c, 0); moduleReleaseTempClient(promise->c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return the pointer and length of a string or error reply. */ -const char *RM_CallReplyStringPtr(RedisModuleCallReply *reply, size_t *len) { +const char *VM_CallReplyStringPtr(ValkeyModuleCallReply *reply, size_t *len) { size_t private_len; if (!len) len = &private_len; return callReplyGetString(reply, len); @@ -6066,45 +6067,45 @@ const char *RM_CallReplyStringPtr(RedisModuleCallReply *reply, size_t *len) { /* Return a new string object from a call reply of type string, error or * integer. Otherwise (wrong reply type) return NULL. */ -RedisModuleString *RM_CreateStringFromCallReply(RedisModuleCallReply *reply) { - RedisModuleCtx* ctx = callReplyGetPrivateData(reply); +ValkeyModuleString *VM_CreateStringFromCallReply(ValkeyModuleCallReply *reply) { + ValkeyModuleCtx* ctx = callReplyGetPrivateData(reply); size_t len; const char *str; switch(callReplyType(reply)) { - case REDISMODULE_REPLY_STRING: - case REDISMODULE_REPLY_ERROR: + case VALKEYMODULE_REPLY_STRING: + case VALKEYMODULE_REPLY_ERROR: str = callReplyGetString(reply, &len); - return RM_CreateString(ctx, str, len); - case REDISMODULE_REPLY_INTEGER: { + return VM_CreateString(ctx, str, len); + case VALKEYMODULE_REPLY_INTEGER: { char buf[64]; int len = ll2string(buf,sizeof(buf),callReplyGetLongLong(reply)); - return RM_CreateString(ctx ,buf,len); + return VM_CreateString(ctx ,buf,len); } default: return NULL; } } -/* Modifies the user that RM_Call will use (e.g. for ACL checks) */ -void RM_SetContextUser(RedisModuleCtx *ctx, const RedisModuleUser *user) { +/* Modifies the user that VM_Call will use (e.g. for ACL checks) */ +void VM_SetContextUser(ValkeyModuleCtx *ctx, const ValkeyModuleUser *user) { ctx->user = user; } /* Returns an array of robj pointers, by parsing the format specifier "fmt" as described for - * the RM_Call(), RM_Replicate() and other module APIs. Populates *argcp with the number of + * the VM_Call(), VM_Replicate() and other module APIs. Populates *argcp with the number of * items (which equals to the length of the allocated argv). * * The integer pointed by 'flags' is populated with flags according * to special modifiers in "fmt". * - * "!" -> REDISMODULE_ARGV_REPLICATE - * "A" -> REDISMODULE_ARGV_NO_AOF - * "R" -> REDISMODULE_ARGV_NO_REPLICAS - * "3" -> REDISMODULE_ARGV_RESP_3 - * "0" -> REDISMODULE_ARGV_RESP_AUTO - * "C" -> REDISMODULE_ARGV_RUN_AS_USER - * "M" -> REDISMODULE_ARGV_RESPECT_DENY_OOM - * "K" -> REDISMODULE_ARGV_ALLOW_BLOCK + * "!" -> VALKEYMODULE_ARGV_REPLICATE + * "A" -> VALKEYMODULE_ARGV_NO_AOF + * "R" -> VALKEYMODULE_ARGV_NO_REPLICAS + * "3" -> VALKEYMODULE_ARGV_RESP_3 + * "0" -> VALKEYMODULE_ARGV_RESP_AUTO + * "C" -> VALKEYMODULE_ARGV_RUN_AS_USER + * "M" -> VALKEYMODULE_ARGV_RESPECT_DENY_OOM + * "K" -> VALKEYMODULE_ARGV_ALLOW_BLOCK * * On error (format specifier error) NULL is returned and nothing is * allocated. On success the argument vector is returned. */ @@ -6158,29 +6159,29 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int argv[argc++] = v[i]; } } else if (*p == '!') { - if (flags) (*flags) |= REDISMODULE_ARGV_REPLICATE; + if (flags) (*flags) |= VALKEYMODULE_ARGV_REPLICATE; } else if (*p == 'A') { - if (flags) (*flags) |= REDISMODULE_ARGV_NO_AOF; + if (flags) (*flags) |= VALKEYMODULE_ARGV_NO_AOF; } else if (*p == 'R') { - if (flags) (*flags) |= REDISMODULE_ARGV_NO_REPLICAS; + if (flags) (*flags) |= VALKEYMODULE_ARGV_NO_REPLICAS; } else if (*p == '3') { - if (flags) (*flags) |= REDISMODULE_ARGV_RESP_3; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RESP_3; } else if (*p == '0') { - if (flags) (*flags) |= REDISMODULE_ARGV_RESP_AUTO; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RESP_AUTO; } else if (*p == 'C') { - if (flags) (*flags) |= REDISMODULE_ARGV_RUN_AS_USER; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RUN_AS_USER; } else if (*p == 'S') { - if (flags) (*flags) |= REDISMODULE_ARGV_SCRIPT_MODE; + if (flags) (*flags) |= VALKEYMODULE_ARGV_SCRIPT_MODE; } else if (*p == 'W') { - if (flags) (*flags) |= REDISMODULE_ARGV_NO_WRITES; + if (flags) (*flags) |= VALKEYMODULE_ARGV_NO_WRITES; } else if (*p == 'M') { - if (flags) (*flags) |= REDISMODULE_ARGV_RESPECT_DENY_OOM; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RESPECT_DENY_OOM; } else if (*p == 'E') { - if (flags) (*flags) |= REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS; + if (flags) (*flags) |= VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS; } else if (*p == 'D') { - if (flags) (*flags) |= (REDISMODULE_ARGV_DRY_RUN | REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS); + if (flags) (*flags) |= (VALKEYMODULE_ARGV_DRY_RUN | VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS); } else if (*p == 'K') { - if (flags) (*flags) |= REDISMODULE_ARGV_ALLOW_BLOCK; + if (flags) (*flags) |= VALKEYMODULE_ARGV_ALLOW_BLOCK; } else { goto fmterr; } @@ -6208,22 +6209,22 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * argument that is the buffer's length. * * `c` -- The argument is a pointer to a plain C string (null-terminated). * * `l` -- The argument is a `long long` integer. - * * `s` -- The argument is a RedisModuleString. - * * `v` -- The argument(s) is a vector of RedisModuleString. + * * `s` -- The argument is a ValkeyModuleString. + * * `v` -- The argument(s) is a vector of ValkeyModuleString. * * `!` -- Sends the Redis command and its arguments to replicas and AOF. * * `A` -- Suppress AOF propagation, send only to replicas (requires `!`). * * `R` -- Suppress replicas propagation, send only to AOF (requires `!`). * * `3` -- Return a RESP3 reply. This will change the command reply. * e.g., HGETALL returns a map instead of a flat array. * * `0` -- Return the reply in auto mode, i.e. the reply format will be the - * same as the client attached to the given RedisModuleCtx. This will + * same as the client attached to the given ValkeyModuleCtx. This will * probably used when you want to pass the reply directly to the client. * * `C` -- Run a command as the user attached to the context. * User is either attached automatically via the client that directly - * issued the command and created the context or via RM_SetContextUser. + * issued the command and created the context or via VM_SetContextUser. * If the context is not directly created by an issued command (such as a - * background context and no user was set on it via RM_SetContextUser, - * RM_Call will fail. + * background context and no user was set on it via VM_SetContextUser, + * VM_Call will fail. * Checks if the command can be executed according to ACL rules and causes * the command to run as the determined user, so that any future user * dependent activity, such as ACL checks within scripts will proceed as @@ -6237,7 +6238,7 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * or when the server is unable to persist to the disk. * * `W` -- Do not allow to run any write command (flagged with the `write` flag). * * `M` -- Do not allow `deny-oom` flagged commands when over the memory limit. - * * `E` -- Return error as RedisModuleCallReply. If there is an error before + * * `E` -- Return error as ValkeyModuleCallReply. If there is an error before * invoking the command, the error is returned using errno mechanism. * This flag allows to get the error also as an error CallReply with * relevant error message. @@ -6246,36 +6247,36 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * return with a CallReply object denoting the error, as if it was called with * the 'E' code. * * 'K' -- Allow running blocking commands. If enabled and the command gets blocked, a - * special REDISMODULE_REPLY_PROMISE will be returned. This reply type + * special VALKEYMODULE_REPLY_PROMISE will be returned. This reply type * indicates that the command was blocked and the reply will be given asynchronously. * The module can use this reply object to set a handler which will be called when - * the command gets unblocked using RedisModule_CallReplyPromiseSetUnblockHandler. + * the command gets unblocked using ValkeyModule_CallReplyPromiseSetUnblockHandler. * The handler must be set immediately after the command invocation (without releasing * the Redis lock in between). If the handler is not set, the blocking command will * still continue its execution but the reply will be ignored (fire and forget), * notice that this is dangerous in case of role change, as explained below. - * The module can use RedisModule_CallReplyPromiseAbort to abort the command invocation - * if it was not yet finished (see RedisModule_CallReplyPromiseAbort documentation for more + * The module can use ValkeyModule_CallReplyPromiseAbort to abort the command invocation + * if it was not yet finished (see ValkeyModule_CallReplyPromiseAbort documentation for more * details). It is also the module's responsibility to abort the execution on role change, either by using * server event (to get notified when the instance becomes a replica) or relying on the disconnect * callback of the original client. Failing to do so can result in a write operation on a replica. * Unlike other call replies, promise call reply **must** be freed while the Redis GIL is locked. * Notice that on unblocking, the only promise is that the unblock handler will be called, - * If the blocking RM_Call caused the module to also block some real client (using RM_BlockClient), + * If the blocking VM_Call caused the module to also block some real client (using VM_BlockClient), * it is the module responsibility to unblock this client on the unblock handler. * On the unblock handler it is only allowed to perform the following: - * * Calling additional Redis commands using RM_Call - * * Open keys using RM_OpenKey + * * Calling additional Redis commands using VM_Call + * * Open keys using VM_OpenKey * * Replicate data to the replica or AOF * * Specifically, it is not allowed to call any Redis module API which are client related such as: - * * RM_Reply* API's - * * RM_BlockClient - * * RM_GetCurrentUserName + * * VM_Reply* API's + * * VM_BlockClient + * * VM_GetCurrentUserName * * * **...**: The actual arguments to the Redis command. * - * On success a RedisModuleCallReply object is returned, otherwise + * On success a ValkeyModuleCallReply object is returned, otherwise * NULL is returned and errno is set to the following values: * * * EBADF: wrong format specifier. @@ -6292,53 +6293,53 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * * Example code fragment: * - * reply = RedisModule_Call(ctx,"INCRBY","sc",argv[1],"10"); - * if (RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_INTEGER) { - * long long myval = RedisModule_CallReplyInteger(reply); + * reply = ValkeyModule_Call(ctx,"INCRBY","sc",argv[1],"10"); + * if (ValkeyModule_CallReplyType(reply) == VALKEYMODULE_REPLY_INTEGER) { + * long long myval = ValkeyModule_CallReplyInteger(reply); * // Do something with myval. * } * * This API is documented here: https://redis.io/topics/modules-intro */ -RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { +ValkeyModuleCallReply *VM_Call(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { client *c = NULL; robj **argv = NULL; int argc = 0, flags = 0; va_list ap; - RedisModuleCallReply *reply = NULL; + ValkeyModuleCallReply *reply = NULL; int replicate = 0; /* Replicate this command? */ - int error_as_call_replies = 0; /* return errors as RedisModuleCallReply object */ + int error_as_call_replies = 0; /* return errors as ValkeyModuleCallReply object */ uint64_t cmd_flags; /* Handle arguments. */ va_start(ap, fmt); argv = moduleCreateArgvFromUserFormat(cmdname,fmt,&argc,&flags,ap); - replicate = flags & REDISMODULE_ARGV_REPLICATE; - error_as_call_replies = flags & REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS; + replicate = flags & VALKEYMODULE_ARGV_REPLICATE; + error_as_call_replies = flags & VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS; va_end(ap); c = moduleAllocTempClient(); - if (!(flags & REDISMODULE_ARGV_ALLOW_BLOCK)) { + if (!(flags & VALKEYMODULE_ARGV_ALLOW_BLOCK)) { /* We do not want to allow block, the module do not expect it */ c->flags |= CLIENT_DENY_BLOCKING; } c->db = ctx->client->db; c->argv = argv; - /* We have to assign argv_len, which is equal to argc in that case (RM_Call) + /* We have to assign argv_len, which is equal to argc in that case (VM_Call) * because we may be calling a command that uses rewriteClientCommandArgument */ c->argc = c->argv_len = argc; c->resp = 2; - if (flags & REDISMODULE_ARGV_RESP_3) { + if (flags & VALKEYMODULE_ARGV_RESP_3) { c->resp = 3; - } else if (flags & REDISMODULE_ARGV_RESP_AUTO) { + } else if (flags & VALKEYMODULE_ARGV_RESP_AUTO) { /* Auto mode means to take the same protocol as the ctx client. */ c->resp = ctx->client->resp; } if (ctx->module) ctx->module->in_call++; user *user = NULL; - if (flags & REDISMODULE_ARGV_RUN_AS_USER) { + if (flags & VALKEYMODULE_ARGV_RUN_AS_USER) { user = ctx->user ? ctx->user->user : ctx->client->user; if (!user) { errno = ENOTSUP; @@ -6385,7 +6386,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch cmd_flags = getCommandFlags(c); - if (flags & REDISMODULE_ARGV_SCRIPT_MODE) { + if (flags & VALKEYMODULE_ARGV_SCRIPT_MODE) { /* Basically on script mode we want to only allow commands that can * be executed on scripts (CMD_NOSCRIPT is not set on the command flags) */ if (cmd_flags & CMD_NOSCRIPT) { @@ -6398,10 +6399,10 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } } - if (flags & REDISMODULE_ARGV_RESPECT_DENY_OOM && server.maxmemory) { + if (flags & VALKEYMODULE_ARGV_RESPECT_DENY_OOM && server.maxmemory) { if (cmd_flags & CMD_DENYOOM) { int oom_state; - if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) { + if (ctx->flags & VALKEYMODULE_CTX_THREAD_SAFE) { /* On background thread we can not count on server.pre_command_oom_state. * Because it is only set on the main thread, in such case we will check * the actual memory usage. */ @@ -6419,11 +6420,11 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } } } else { - /* if we aren't OOM checking in RM_Call, we want further executions from this client to also not fail on OOM */ + /* if we aren't OOM checking in VM_Call, we want further executions from this client to also not fail on OOM */ c->flags |= CLIENT_ALLOW_OOM; } - if (flags & REDISMODULE_ARGV_NO_WRITES) { + if (flags & VALKEYMODULE_ARGV_NO_WRITES) { if (cmd_flags & CMD_WRITE) { errno = ENOSPC; if (error_as_call_replies) { @@ -6436,7 +6437,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } /* Script mode tests */ - if (flags & REDISMODULE_ARGV_SCRIPT_MODE) { + if (flags & VALKEYMODULE_ARGV_SCRIPT_MODE) { if (cmd_flags & CMD_WRITE) { /* on script mode, if a command is a write command, * We will not run it if we encounter disk error @@ -6487,10 +6488,10 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch /* Check if the user can run this command according to the current * ACLs. * - * If RM_SetContextUser has set a user, that user is used, otherwise + * If VM_SetContextUser has set a user, that user is used, otherwise * use the attached client's user. If there is no attached client user and no manually * set user, an error will be returned */ - if (flags & REDISMODULE_ARGV_RUN_AS_USER) { + if (flags & VALKEYMODULE_ARGV_RUN_AS_USER) { int acl_errpos; int acl_retval; @@ -6545,15 +6546,15 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } } - if (flags & REDISMODULE_ARGV_DRY_RUN) { + if (flags & VALKEYMODULE_ARGV_DRY_RUN) { goto cleanup; } /* We need to use a global replication_allowed flag in order to prevent - * replication of nested RM_Calls. Example: - * 1. module1.foo does RM_Call of module2.bar without replication (i.e. no '!') - * 2. module2.bar internally calls RM_Call of INCR with '!' - * 3. at the end of module1.foo we call RM_ReplicateVerbatim + * replication of nested VM_Calls. Example: + * 1. module1.foo does VM_Call of module2.bar without replication (i.e. no '!') + * 2. module2.bar internally calls VM_Call of INCR with '!' + * 3. at the end of module1.foo we call VM_ReplicateVerbatim * We want the replica/AOF to see only module1.foo and not the INCR from module2.bar */ int prev_replication_allowed = server.replication_allowed; server.replication_allowed = replicate && server.replication_allowed; @@ -6561,19 +6562,19 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch /* Run the command */ int call_flags = CMD_CALL_FROM_MODULE; if (replicate) { - if (!(flags & REDISMODULE_ARGV_NO_AOF)) + if (!(flags & VALKEYMODULE_ARGV_NO_AOF)) call_flags |= CMD_CALL_PROPAGATE_AOF; - if (!(flags & REDISMODULE_ARGV_NO_REPLICAS)) + if (!(flags & VALKEYMODULE_ARGV_NO_REPLICAS)) call_flags |= CMD_CALL_PROPAGATE_REPL; } call(c,call_flags); server.replication_allowed = prev_replication_allowed; if (c->flags & CLIENT_BLOCKED) { - serverAssert(flags & REDISMODULE_ARGV_ALLOW_BLOCK); + serverAssert(flags & VALKEYMODULE_ARGV_ALLOW_BLOCK); serverAssert(ctx->module); - RedisModuleAsyncRMCallPromise *promise = zmalloc(sizeof(RedisModuleAsyncRMCallPromise)); - *promise = (RedisModuleAsyncRMCallPromise) { + ValkeyModuleAsyncRMCallPromise *promise = zmalloc(sizeof(ValkeyModuleAsyncRMCallPromise)); + *promise = (ValkeyModuleAsyncRMCallPromise) { /* We start with ref_count value of 2 because this object is held * by the promise CallReply and the fake client that was used to execute the command. */ .ref_count = 2, @@ -6581,7 +6582,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch .on_unblocked = NULL, .private_data = NULL, .c = c, - .ctx = (ctx->flags & REDISMODULE_CTX_AUTO_MEMORY) ? ctx : NULL, + .ctx = (ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY) ? ctx : NULL, }; reply = callReplyCreatePromise(promise); c->bstate.async_rm_call_handle = promise; @@ -6595,11 +6596,11 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } c = NULL; /* Make sure not to free the client */ } else { - reply = moduleParseReply(c, (ctx->flags & REDISMODULE_CTX_AUTO_MEMORY) ? ctx : NULL); + reply = moduleParseReply(c, (ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY) ? ctx : NULL); } cleanup: - if (reply) autoMemoryAdd(ctx,REDISMODULE_AM_REPLY,reply); + if (reply) autoMemoryAdd(ctx,VALKEYMODULE_AM_REPLY,reply); if (ctx->module) ctx->module->in_call--; if (c) moduleReleaseTempClient(c); return reply; @@ -6607,7 +6608,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch /* Return a pointer, and a length, to the protocol returned by the command * that returned the reply object. */ -const char *RM_CallReplyProto(RedisModuleCallReply *reply, size_t *len) { +const char *VM_CallReplyProto(ValkeyModuleCallReply *reply, size_t *len) { return callReplyGetProto(reply, len); } @@ -6675,7 +6676,7 @@ moduleType *moduleTypeLookupModuleByNameInternal(const char *name, int ignore_ca dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -6725,7 +6726,7 @@ moduleType *moduleTypeLookupModuleByID(uint64_t id) { dictEntry *de; while ((de = dictNext(di)) != NULL && mt == NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -6774,9 +6775,9 @@ const char *moduleTypeModuleName(moduleType *mt) { /* Return the module name from a module command */ const char *moduleNameFromCommand(struct serverCommand *cmd) { - serverAssert(cmd->proc == RedisModuleCommandDispatcher); + serverAssert(cmd->proc == ValkeyModuleCommandDispatcher); - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; return cp->module->name; } @@ -6792,7 +6793,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj } void *newval = NULL; if (mt->copy2 != NULL) { - RedisModuleKeyOptCtx ctx = {fromkey, tokey, c->db->id, todb}; + ValkeyModuleKeyOptCtx ctx = {fromkey, tokey, c->db->id, todb}; newval = mt->copy2(&ctx, mv->value); } else { newval = mt->copy(fromkey, tokey, mv->value); @@ -6827,12 +6828,12 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * callback is able to check the encver value and act accordingly. * The encver must be a positive value between 0 and 1023. * - * * **typemethods_ptr** is a pointer to a RedisModuleTypeMethods structure + * * **typemethods_ptr** is a pointer to a ValkeyModuleTypeMethods structure * that should be populated with the methods callbacks and structure * version, like in the following example: * - * RedisModuleTypeMethods tm = { - * .version = REDISMODULE_TYPE_METHOD_VERSION, + * ValkeyModuleTypeMethods tm = { + * .version = VALKEYMODULE_TYPE_METHOD_VERSION, * .rdb_load = myType_RDBLoadCallBack, * .rdb_save = myType_RDBSaveCallBack, * .aof_rewrite = myType_AOFRewriteCallBack, @@ -6861,9 +6862,9 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * * **digest**: A callback function pointer that is used for `DEBUG DIGEST`. * * **free**: A callback function pointer that can free a type value. * * **aux_save**: A callback function pointer that saves out of keyspace data to RDB files. - * 'when' argument is either REDISMODULE_AUX_BEFORE_RDB or REDISMODULE_AUX_AFTER_RDB. + * 'when' argument is either VALKEYMODULE_AUX_BEFORE_RDB or VALKEYMODULE_AUX_AFTER_RDB. * * **aux_load**: A callback function pointer that loads out of keyspace data from RDB files. - * Similar to aux_save, returns REDISMODULE_OK on success, and ERR otherwise. + * Similar to aux_save, returns VALKEYMODULE_OK on success, and ERR otherwise. * * **free_effort**: A callback function pointer that used to determine whether the module's * memory needs to be lazy reclaimed. The module should return the complexity involved by * freeing the value. for example: how many pointers are gonna be freed. Note that if it @@ -6871,7 +6872,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * * **unlink**: A callback function pointer that used to notifies the module that the key has * been removed from the DB by redis, and may soon be freed by a background thread. Note that * it won't be called on FLUSHALL/FLUSHDB (both sync and async), and the module can use the - * RedisModuleEvent_FlushDB to hook into that. + * ValkeyModuleEvent_FlushDB to hook into that. * * **copy**: A callback function pointer that is used to make a copy of the specified key. * The module is expected to perform a deep copy of the specified value and return it. * In addition, hints about the names of the source and destination keys is provided. @@ -6880,28 +6881,28 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * called first, followed by a free callback to the value that is being replaced. * * * **defrag**: A callback function pointer that is used to request the module to defrag - * a key. The module should then iterate pointers and call the relevant RM_Defrag*() + * a key. The module should then iterate pointers and call the relevant VM_Defrag*() * functions to defragment pointers or complex types. The module should continue - * iterating as long as RM_DefragShouldStop() returns a zero value, and return a + * iterating as long as VM_DefragShouldStop() returns a zero value, and return a * zero value if finished or non-zero value if more work is left to be done. If more work - * needs to be done, RM_DefragCursorSet() and RM_DefragCursorGet() can be used to track + * needs to be done, VM_DefragCursorSet() and VM_DefragCursorGet() can be used to track * this work across different calls. * Normally, the defrag mechanism invokes the callback without a time limit, so - * RM_DefragShouldStop() always returns zero. The "late defrag" mechanism which has + * VM_DefragShouldStop() always returns zero. The "late defrag" mechanism which has * a time limit and provides cursor support is used only for keys that are determined * to have significant internal complexity. To determine this, the defrag mechanism * uses the free_effort callback and the 'active-defrag-max-scan-fields' config directive. * NOTE: The value is passed as a `void**` and the function is expected to update the * pointer if the top-level value pointer is defragmented and consequently changes. * - * * **mem_usage2**: Similar to `mem_usage`, but provides the `RedisModuleKeyOptCtx` parameter + * * **mem_usage2**: Similar to `mem_usage`, but provides the `ValkeyModuleKeyOptCtx` parameter * so that meta information such as key name and db id can be obtained, and * the `sample_size` for size estimation (see MEMORY USAGE command). - * * **free_effort2**: Similar to `free_effort`, but provides the `RedisModuleKeyOptCtx` parameter + * * **free_effort2**: Similar to `free_effort`, but provides the `ValkeyModuleKeyOptCtx` parameter * so that meta information such as key name and db id can be obtained. - * * **unlink2**: Similar to `unlink`, but provides the `RedisModuleKeyOptCtx` parameter + * * **unlink2**: Similar to `unlink`, but provides the `ValkeyModuleKeyOptCtx` parameter * so that meta information such as key name and db id can be obtained. - * * **copy2**: Similar to `copy`, but provides the `RedisModuleKeyOptCtx` parameter + * * **copy2**: Similar to `copy`, but provides the `ValkeyModuleKeyOptCtx` parameter * so that meta information such as key names and db ids can be obtained. * * **aux_save2**: Similar to `aux_save`, but with small semantic change, if the module * saves nothing on this callback then no data about this aux field will be written to the @@ -6910,23 +6911,23 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * Note: the module name "AAAAAAAAA" is reserved and produces an error, it * happens to be pretty lame as well. * - * If RedisModule_CreateDataType() is called outside of RedisModule_OnLoad() function, + * If ValkeyModule_CreateDataType() is called outside of ValkeyModule_OnLoad() function, * there is already a module registering a type with the same name, * or if the module name or encver is invalid, NULL is returned. * Otherwise the new type is registered into Redis, and a reference of - * type RedisModuleType is returned: the caller of the function should store + * type ValkeyModuleType is returned: the caller of the function should store * this reference into a global variable to make future use of it in the * modules type API, since a single module may register multiple types. * Example code fragment: * - * static RedisModuleType *BalancedTreeType; + * static ValkeyModuleType *BalancedTreeType; * - * int RedisModule_OnLoad(RedisModuleCtx *ctx) { + * int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx) { * // some code here ... - * BalancedTreeType = RM_CreateDataType(...); + * BalancedTreeType = VM_CreateDataType(...); * } */ -moduleType *RM_CreateDataType(RedisModuleCtx *ctx, const char *name, int encver, void *typemethods_ptr) { +moduleType *VM_CreateDataType(ValkeyModuleCtx *ctx, const char *name, int encver, void *typemethods_ptr) { if (!ctx->module->onload) return NULL; uint64_t id = moduleTypeEncodeId(name,encver); @@ -7002,41 +7003,41 @@ moduleType *RM_CreateDataType(RedisModuleCtx *ctx, const char *name, int encver, /* If the key is open for writing, set the specified module type object * as the value of the key, deleting the old value if any. - * On success REDISMODULE_OK is returned. If the key is not open for - * writing or there is an active iterator, REDISMODULE_ERR is returned. */ -int RM_ModuleTypeSetValue(RedisModuleKey *key, moduleType *mt, void *value) { - if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; - RM_DeleteKey(key); + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing or there is an active iterator, VALKEYMODULE_ERR is returned. */ +int VM_ModuleTypeSetValue(ValkeyModuleKey *key, moduleType *mt, void *value) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->iter) return VALKEYMODULE_ERR; + VM_DeleteKey(key); robj *o = createModuleObject(mt,value); setKey(key->ctx->client,key->db,key->key,o,SETKEY_NO_SIGNAL); decrRefCount(o); key->value = o; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on +/* Assuming ValkeyModule_KeyType() returned VALKEYMODULE_KEYTYPE_MODULE on * the key, returns the module type pointer of the value stored at key. * * If the key is NULL, is not associated with a module type, or is empty, * then NULL is returned instead. */ -moduleType *RM_ModuleTypeGetType(RedisModuleKey *key) { +moduleType *VM_ModuleTypeGetType(ValkeyModuleKey *key) { if (key == NULL || key->value == NULL || - RM_KeyType(key) != REDISMODULE_KEYTYPE_MODULE) return NULL; + VM_KeyType(key) != VALKEYMODULE_KEYTYPE_MODULE) return NULL; moduleValue *mv = key->value->ptr; return mv->type; } -/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on +/* Assuming ValkeyModule_KeyType() returned VALKEYMODULE_KEYTYPE_MODULE on * the key, returns the module type low-level value stored at key, as - * it was set by the user via RedisModule_ModuleTypeSetValue(). + * it was set by the user via ValkeyModule_ModuleTypeSetValue(). * * If the key is NULL, is not associated with a module type, or is empty, * then NULL is returned instead. */ -void *RM_ModuleTypeGetValue(RedisModuleKey *key) { +void *VM_ModuleTypeGetValue(ValkeyModuleKey *key) { if (key == NULL || key->value == NULL || - RM_KeyType(key) != REDISMODULE_KEYTYPE_MODULE) return NULL; + VM_KeyType(key) != VALKEYMODULE_KEYTYPE_MODULE) return NULL; moduleValue *mv = key->value->ptr; return mv->value; } @@ -7048,8 +7049,8 @@ void *RM_ModuleTypeGetValue(RedisModuleKey *key) { /* Called when there is a load error in the context of a module. On some * modules this cannot be recovered, but if the module declared capability * to handle errors, we'll raise a flag rather than exiting. */ -void moduleRDBLoadError(RedisModuleIO *io) { - if (io->type->module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS) { +void moduleRDBLoadError(ValkeyModuleIO *io) { + if (io->type->module->options & VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS) { io->error = 1; return; } @@ -7065,16 +7066,16 @@ void moduleRDBLoadError(RedisModuleIO *io) { } /* Returns 0 if there's at least one registered data type that did not declare - * REDISMODULE_OPTIONS_HANDLE_IO_ERRORS, in which case diskless loading should + * VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS, in which case diskless loading should * be avoided since it could cause data loss. */ int moduleAllDatatypesHandleErrors(void) { dictIterator *di = dictGetIterator(modules); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); if (listLength(module->types) && - !(module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS)) + !(module->options & VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS)) { dictReleaseIterator(di); return 0; @@ -7084,7 +7085,7 @@ int moduleAllDatatypesHandleErrors(void) { return 1; } -/* Returns 0 if module did not declare REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD, in which case +/* Returns 0 if module did not declare VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD, in which case * diskless async loading should be avoided because module doesn't know there can be traffic during * database full resynchronization. */ int moduleAllModulesHandleReplAsyncLoad(void) { @@ -7092,8 +7093,8 @@ int moduleAllModulesHandleReplAsyncLoad(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); - if (!(module->options & REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD)) { + struct ValkeyModule *module = dictGetVal(de); + if (!(module->options & VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD)) { dictReleaseIterator(di); return 0; } @@ -7103,13 +7104,13 @@ int moduleAllModulesHandleReplAsyncLoad(void) { } /* Returns true if any previous IO API failed. - * for `Load*` APIs the REDISMODULE_OPTIONS_HANDLE_IO_ERRORS flag must be set with - * RedisModule_SetModuleOptions first. */ -int RM_IsIOError(RedisModuleIO *io) { + * for `Load*` APIs the VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS flag must be set with + * ValkeyModule_SetModuleOptions first. */ +int VM_IsIOError(ValkeyModuleIO *io) { return io->error; } -static int flushRedisModuleIOBuffer(RedisModuleIO *io) { +static int flushRedisModuleIOBuffer(ValkeyModuleIO *io) { if (!io->pre_flush_buffer) return 0; /* We have data that must be flushed before saving the current data. @@ -7125,7 +7126,7 @@ static int flushRedisModuleIOBuffer(RedisModuleIO *io) { /* Save an unsigned 64 bit value into the RDB file. This function should only * be called in the context of the rdb_save method of modules implementing new * data types. */ -void RM_SaveUnsigned(RedisModuleIO *io, uint64_t value) { +void VM_SaveUnsigned(ValkeyModuleIO *io, uint64_t value) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7145,7 +7146,7 @@ void RM_SaveUnsigned(RedisModuleIO *io, uint64_t value) { /* Load an unsigned 64 bit value from the RDB file. This function should only * be called in the context of the `rdb_load` method of modules implementing * new data types. */ -uint64_t RM_LoadUnsigned(RedisModuleIO *io) { +uint64_t VM_LoadUnsigned(ValkeyModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_UINT) goto loaderr; @@ -7159,27 +7160,27 @@ uint64_t RM_LoadUnsigned(RedisModuleIO *io) { return 0; } -/* Like RedisModule_SaveUnsigned() but for signed 64 bit values. */ -void RM_SaveSigned(RedisModuleIO *io, int64_t value) { +/* Like ValkeyModule_SaveUnsigned() but for signed 64 bit values. */ +void VM_SaveSigned(ValkeyModuleIO *io, int64_t value) { union {uint64_t u; int64_t i;} conv; conv.i = value; - RM_SaveUnsigned(io,conv.u); + VM_SaveUnsigned(io,conv.u); } -/* Like RedisModule_LoadUnsigned() but for signed 64 bit values. */ -int64_t RM_LoadSigned(RedisModuleIO *io) { +/* Like ValkeyModule_LoadUnsigned() but for signed 64 bit values. */ +int64_t VM_LoadSigned(ValkeyModuleIO *io) { union {uint64_t u; int64_t i;} conv; - conv.u = RM_LoadUnsigned(io); + conv.u = VM_LoadUnsigned(io); return conv.i; } /* In the context of the rdb_save method of a module type, saves a - * string into the RDB file taking as input a RedisModuleString. + * string into the RDB file taking as input a ValkeyModuleString. * - * The string can be later loaded with RedisModule_LoadString() or + * The string can be later loaded with ValkeyModule_LoadString() or * other Load family functions expecting a serialized string inside * the RDB file. */ -void RM_SaveString(RedisModuleIO *io, RedisModuleString *s) { +void VM_SaveString(ValkeyModuleIO *io, ValkeyModuleString *s) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7196,9 +7197,9 @@ void RM_SaveString(RedisModuleIO *io, RedisModuleString *s) { io->error = 1; } -/* Like RedisModule_SaveString() but takes a raw C pointer and length +/* Like ValkeyModule_SaveString() but takes a raw C pointer and length * as input. */ -void RM_SaveStringBuffer(RedisModuleIO *io, const char *str, size_t len) { +void VM_SaveStringBuffer(ValkeyModuleIO *io, const char *str, size_t len) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7215,8 +7216,8 @@ void RM_SaveStringBuffer(RedisModuleIO *io, const char *str, size_t len) { io->error = 1; } -/* Implements RM_LoadString() and RM_LoadStringBuffer() */ -void *moduleLoadString(RedisModuleIO *io, int plain, size_t *lenptr) { +/* Implements VM_LoadString() and VM_LoadStringBuffer() */ +void *moduleLoadString(ValkeyModuleIO *io, int plain, size_t *lenptr) { if (io->error) return NULL; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_STRING) goto loaderr; @@ -7231,33 +7232,33 @@ void *moduleLoadString(RedisModuleIO *io, int plain, size_t *lenptr) { } /* In the context of the rdb_load method of a module data type, loads a string - * from the RDB file, that was previously saved with RedisModule_SaveString() + * from the RDB file, that was previously saved with ValkeyModule_SaveString() * functions family. * - * The returned string is a newly allocated RedisModuleString object, and - * the user should at some point free it with a call to RedisModule_FreeString(). + * The returned string is a newly allocated ValkeyModuleString object, and + * the user should at some point free it with a call to ValkeyModule_FreeString(). * - * If the data structure does not store strings as RedisModuleString objects, - * the similar function RedisModule_LoadStringBuffer() could be used instead. */ -RedisModuleString *RM_LoadString(RedisModuleIO *io) { + * If the data structure does not store strings as ValkeyModuleString objects, + * the similar function ValkeyModule_LoadStringBuffer() could be used instead. */ +ValkeyModuleString *VM_LoadString(ValkeyModuleIO *io) { return moduleLoadString(io,0,NULL); } -/* Like RedisModule_LoadString() but returns a heap allocated string that - * was allocated with RedisModule_Alloc(), and can be resized or freed with - * RedisModule_Realloc() or RedisModule_Free(). +/* Like ValkeyModule_LoadString() but returns a heap allocated string that + * was allocated with ValkeyModule_Alloc(), and can be resized or freed with + * ValkeyModule_Realloc() or ValkeyModule_Free(). * * The size of the string is stored at '*lenptr' if not NULL. * The returned string is not automatically NULL terminated, it is loaded * exactly as it was stored inside the RDB file. */ -char *RM_LoadStringBuffer(RedisModuleIO *io, size_t *lenptr) { +char *VM_LoadStringBuffer(ValkeyModuleIO *io, size_t *lenptr) { return moduleLoadString(io,1,lenptr); } /* In the context of the rdb_save method of a module data type, saves a double * value to the RDB file. The double can be a valid number, a NaN or infinity. - * It is possible to load back the value with RedisModule_LoadDouble(). */ -void RM_SaveDouble(RedisModuleIO *io, double value) { + * It is possible to load back the value with ValkeyModule_LoadDouble(). */ +void VM_SaveDouble(ValkeyModuleIO *io, double value) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7275,8 +7276,8 @@ void RM_SaveDouble(RedisModuleIO *io, double value) { } /* In the context of the rdb_save method of a module data type, loads back the - * double value saved by RedisModule_SaveDouble(). */ -double RM_LoadDouble(RedisModuleIO *io) { + * double value saved by ValkeyModule_SaveDouble(). */ +double VM_LoadDouble(ValkeyModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_DOUBLE) goto loaderr; @@ -7292,8 +7293,8 @@ double RM_LoadDouble(RedisModuleIO *io) { /* In the context of the rdb_save method of a module data type, saves a float * value to the RDB file. The float can be a valid number, a NaN or infinity. - * It is possible to load back the value with RedisModule_LoadFloat(). */ -void RM_SaveFloat(RedisModuleIO *io, float value) { + * It is possible to load back the value with ValkeyModule_LoadFloat(). */ +void VM_SaveFloat(ValkeyModuleIO *io, float value) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7311,8 +7312,8 @@ void RM_SaveFloat(RedisModuleIO *io, float value) { } /* In the context of the rdb_save method of a module data type, loads back the - * float value saved by RedisModule_SaveFloat(). */ -float RM_LoadFloat(RedisModuleIO *io) { + * float value saved by ValkeyModule_SaveFloat(). */ +float VM_LoadFloat(ValkeyModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_FLOAT) goto loaderr; @@ -7328,26 +7329,26 @@ float RM_LoadFloat(RedisModuleIO *io) { /* In the context of the rdb_save method of a module data type, saves a long double * value to the RDB file. The double can be a valid number, a NaN or infinity. - * It is possible to load back the value with RedisModule_LoadLongDouble(). */ -void RM_SaveLongDouble(RedisModuleIO *io, long double value) { + * It is possible to load back the value with ValkeyModule_LoadLongDouble(). */ +void VM_SaveLongDouble(ValkeyModuleIO *io, long double value) { if (io->error) return; char buf[MAX_LONG_DOUBLE_CHARS]; /* Long double has different number of bits in different platforms, so we * save it as a string type. */ size_t len = ld2string(buf,sizeof(buf),value,LD_STR_HEX); - RM_SaveStringBuffer(io,buf,len); + VM_SaveStringBuffer(io,buf,len); } /* In the context of the rdb_save method of a module data type, loads back the - * long double value saved by RedisModule_SaveLongDouble(). */ -long double RM_LoadLongDouble(RedisModuleIO *io) { + * long double value saved by ValkeyModule_SaveLongDouble(). */ +long double VM_LoadLongDouble(ValkeyModuleIO *io) { if (io->error) return 0; long double value; size_t len; - char* str = RM_LoadStringBuffer(io,&len); + char* str = VM_LoadStringBuffer(io,&len); if (!str) return 0; string2ld(str,len,&value); - RM_Free(str); + VM_Free(str); return value; } @@ -7359,7 +7360,7 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -7388,7 +7389,7 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { /* Add a new element to the digest. This function can be called multiple times * one element after the other, for all the elements that constitute a given * data structure. The function call must be followed by the call to - * `RedisModule_DigestEndSequence` eventually, when all the elements that are + * `ValkeyModule_DigestEndSequence` eventually, when all the elements that are * always in a given order are added. See the Redis Modules data types * documentation for more info. However this is a quick example that uses Redis * data types as an example. @@ -7423,20 +7424,20 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { * EndSequence(); * */ -void RM_DigestAddStringBuffer(RedisModuleDigest *md, const char *ele, size_t len) { +void VM_DigestAddStringBuffer(ValkeyModuleDigest *md, const char *ele, size_t len) { mixDigest(md->o,ele,len); } -/* Like `RedisModule_DigestAddStringBuffer()` but takes a `long long` as input +/* Like `ValkeyModule_DigestAddStringBuffer()` but takes a `long long` as input * that gets converted into a string before adding it to the digest. */ -void RM_DigestAddLongLong(RedisModuleDigest *md, long long ll) { +void VM_DigestAddLongLong(ValkeyModuleDigest *md, long long ll) { char buf[LONG_STR_SIZE]; size_t len = ll2string(buf,sizeof(buf),ll); mixDigest(md->o,buf,len); } -/* See the documentation for `RedisModule_DigestAddElement()`. */ -void RM_DigestEndSequence(RedisModuleDigest *md) { +/* See the documentation for `ValkeyModule_DigestAddElement()`. */ +void VM_DigestEndSequence(ValkeyModuleDigest *md) { xorDigest(md->x,md->o,sizeof(md->o)); memset(md->o,0,sizeof(md->o)); } @@ -7448,22 +7449,22 @@ void RM_DigestEndSequence(RedisModuleDigest *md) { * implement in order to allow a module to arbitrarily serialize/de-serialize * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. * - * Modules should generally use the REDISMODULE_OPTIONS_HANDLE_IO_ERRORS flag and + * Modules should generally use the VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS flag and * make sure the de-serialization code properly checks and handles IO errors * (freeing allocated buffers and returning a NULL). * * If this is NOT done, Redis will handle corrupted (or just truncated) serialized * data by producing an error message and terminating the process. */ -void *RM_LoadDataTypeFromStringEncver(const RedisModuleString *str, const moduleType *mt, int encver) { +void *VM_LoadDataTypeFromStringEncver(const ValkeyModuleString *str, const moduleType *mt, int encver) { rio payload; - RedisModuleIO io; + ValkeyModuleIO io; void *ret; rioInitWithBuffer(&payload, str->ptr); moduleInitIOContext(io,(moduleType *)mt,&payload,NULL,-1); - /* All RM_Save*() calls always write a version 2 compatible format, so we + /* All VM_Save*() calls always write a version 2 compatible format, so we * need to make sure we read the same. */ ret = mt->rdb_load(&io,encver); @@ -7474,23 +7475,23 @@ void *RM_LoadDataTypeFromStringEncver(const RedisModuleString *str, const module return ret; } -/* Similar to RM_LoadDataTypeFromStringEncver, original version of the API, kept +/* Similar to VM_LoadDataTypeFromStringEncver, original version of the API, kept * for backward compatibility. */ -void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *mt) { - return RM_LoadDataTypeFromStringEncver(str, mt, 0); +void *VM_LoadDataTypeFromString(const ValkeyModuleString *str, const moduleType *mt) { + return VM_LoadDataTypeFromStringEncver(str, mt, 0); } /* Encode a module data type 'mt' value 'data' into serialized form, and return it - * as a newly allocated RedisModuleString. + * as a newly allocated ValkeyModuleString. * * This call basically reuses the 'rdb_save' callback which module data types * implement in order to allow a module to arbitrarily serialize/de-serialize * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. */ -RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, const moduleType *mt) { +ValkeyModuleString *VM_SaveDataTypeToString(ValkeyModuleCtx *ctx, void *data, const moduleType *mt) { rio payload; - RedisModuleIO io; + ValkeyModuleIO io; rioInitWithBuffer(&payload,sdsempty()); moduleInitIOContext(io,(moduleType *)mt,&payload,NULL,-1); @@ -7503,18 +7504,18 @@ RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, cons return NULL; } else { robj *str = createObject(OBJ_STRING,payload.io.buffer.ptr); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,str); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,str); return str; } } /* Returns the name of the key currently being processed. */ -const RedisModuleString *RM_GetKeyNameFromDigest(RedisModuleDigest *dig) { +const ValkeyModuleString *VM_GetKeyNameFromDigest(ValkeyModuleDigest *dig) { return dig->key; } /* Returns the database id of the key currently being processed. */ -int RM_GetDbIdFromDigest(RedisModuleDigest *dig) { +int VM_GetDbIdFromDigest(ValkeyModuleDigest *dig) { return dig->dbid; } /* -------------------------------------------------------------------------- @@ -7523,10 +7524,10 @@ int RM_GetDbIdFromDigest(RedisModuleDigest *dig) { /* Emits a command into the AOF during the AOF rewriting process. This function * is only called in the context of the aof_rewrite method of data types exported - * by a module. The command works exactly like RedisModule_Call() in the way + * by a module. The command works exactly like ValkeyModule_Call() in the way * the parameters are passed, but it does not return anything as the error * handling is performed by Redis itself. */ -void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { +void VM_EmitAOF(ValkeyModuleIO *io, const char *cmdname, const char *fmt, ...) { if (io->error) return; struct serverCommand *cmd; robj **argv = NULL; @@ -7551,7 +7552,7 @@ void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { if (argv == NULL) { serverLog(LL_WARNING, "Fatal: AOF method for module data type '%s' tried to " - "call RedisModule_EmitAOF() with wrong format specifiers '%s'", + "call ValkeyModule_EmitAOF() with wrong format specifiers '%s'", io->type->name, fmt); io->error = 1; errno = EINVAL; @@ -7576,34 +7577,34 @@ void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { * ## IO context handling * -------------------------------------------------------------------------- */ -RedisModuleCtx *RM_GetContextFromIO(RedisModuleIO *io) { +ValkeyModuleCtx *VM_GetContextFromIO(ValkeyModuleIO *io) { if (io->ctx) return io->ctx; /* Can't have more than one... */ - io->ctx = zmalloc(sizeof(RedisModuleCtx)); - moduleCreateContext(io->ctx, io->type->module, REDISMODULE_CTX_NONE); + io->ctx = zmalloc(sizeof(ValkeyModuleCtx)); + moduleCreateContext(io->ctx, io->type->module, VALKEYMODULE_CTX_NONE); return io->ctx; } /* Returns the name of the key currently being processed. * There is no guarantee that the key name is always available, so this may return NULL. */ -const RedisModuleString *RM_GetKeyNameFromIO(RedisModuleIO *io) { +const ValkeyModuleString *VM_GetKeyNameFromIO(ValkeyModuleIO *io) { return io->key; } -/* Returns a RedisModuleString with the name of the key from RedisModuleKey. */ -const RedisModuleString *RM_GetKeyNameFromModuleKey(RedisModuleKey *key) { +/* Returns a ValkeyModuleString with the name of the key from ValkeyModuleKey. */ +const ValkeyModuleString *VM_GetKeyNameFromModuleKey(ValkeyModuleKey *key) { return key ? key->key : NULL; } -/* Returns a database id of the key from RedisModuleKey. */ -int RM_GetDbIdFromModuleKey(RedisModuleKey *key) { +/* Returns a database id of the key from ValkeyModuleKey. */ +int VM_GetDbIdFromModuleKey(ValkeyModuleKey *key) { return key ? key->db->id : -1; } /* Returns the database id of the key currently being processed. * There is no guarantee that this info is always available, so this may return -1. */ -int RM_GetDbIdFromIO(RedisModuleIO *io) { +int VM_GetDbIdFromIO(ValkeyModuleIO *io) { return io->dbid; } @@ -7613,11 +7614,11 @@ int RM_GetDbIdFromIO(RedisModuleIO *io) { /* This is the low level function implementing both: * - * RM_Log() - * RM_LogIOError() + * VM_Log() + * VM_LogIOError() * */ -void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va_list ap) { +void moduleLogRaw(ValkeyModule *module, const char *levelstr, const char *fmt, va_list ap) { char msg[LOG_MAX_LEN]; size_t name_len; int level; @@ -7639,10 +7640,10 @@ void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va * printf-alike specifiers, while level is a string describing the log * level to use when emitting the log, and must be one of the following: * - * * "debug" (`REDISMODULE_LOGLEVEL_DEBUG`) - * * "verbose" (`REDISMODULE_LOGLEVEL_VERBOSE`) - * * "notice" (`REDISMODULE_LOGLEVEL_NOTICE`) - * * "warning" (`REDISMODULE_LOGLEVEL_WARNING`) + * * "debug" (`VALKEYMODULE_LOGLEVEL_DEBUG`) + * * "verbose" (`VALKEYMODULE_LOGLEVEL_VERBOSE`) + * * "notice" (`VALKEYMODULE_LOGLEVEL_NOTICE`) + * * "warning" (`VALKEYMODULE_LOGLEVEL_WARNING`) * * If the specified log level is invalid, verbose is used by default. * There is a fixed limit to the length of the log line this function is able @@ -7653,7 +7654,7 @@ void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va * caller for instance threads or callbacks, in which case a generic "module" * will be used instead of the module name. */ -void RM_Log(RedisModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { +void VM_Log(ValkeyModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { va_list ap; va_start(ap, fmt); moduleLogRaw(ctx? ctx->module: NULL,levelstr,fmt,ap); @@ -7665,7 +7666,7 @@ void RM_Log(RedisModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { * This function should be used when a callback is returning a critical * error to the caller since cannot load or save the data for some * critical reason. */ -void RM_LogIOError(RedisModuleIO *io, const char *levelstr, const char *fmt, ...) { +void VM_LogIOError(ValkeyModuleIO *io, const char *levelstr, const char *fmt, ...) { va_list ap; va_start(ap, fmt); moduleLogRaw(io->type->module,levelstr,fmt,ap); @@ -7674,20 +7675,20 @@ void RM_LogIOError(RedisModuleIO *io, const char *levelstr, const char *fmt, ... /* Redis-like assert function. * - * The macro `RedisModule_Assert(expression)` is recommended, rather than + * The macro `ValkeyModule_Assert(expression)` is recommended, rather than * calling this function directly. * * A failed assertion will shut down the server and produce logging information * that looks identical to information generated by Redis itself. */ -void RM__Assert(const char *estr, const char *file, int line) { +void VM__Assert(const char *estr, const char *file, int line) { _serverAssert(estr, file, line); } /* Allows adding event to the latency monitor to be observed by the LATENCY * command. The call is skipped if the latency is smaller than the configured * latency-monitor-threshold. */ -void RM_LatencyAddSample(const char *event, mstime_t latency) { +void VM_LatencyAddSample(const char *event, mstime_t latency) { if (latency >= server.latency_monitor_threshold) latencyAddSample(event, latency); } @@ -7701,7 +7702,7 @@ void RM_LatencyAddSample(const char *event, mstime_t latency) { /* Returns 1 if the client already in the moduleUnblocked list, 0 otherwise. */ int isModuleClientUnblocked(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; return bc->unblocked == 1; } @@ -7716,18 +7717,18 @@ int isModuleClientUnblocked(client *c) { * is a pending threaded operation involving the blocked client, we'll know * that the client no longer exists and no reply callback should be called. * - * The structure RedisModuleBlockedClient will be always deallocated when + * The structure ValkeyModuleBlockedClient will be always deallocated when * running the list of clients blocked by a module that need to be unblocked. */ void unblockClientFromModule(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; /* Call the disconnection callback if any. Note that * bc->disconnect_callback is set to NULL if the client gets disconnected * by the module itself or because of a timeout, so the callback will NOT * get called if this is not an actual disconnection event. */ if (bc->disconnect_callback) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_NONE); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_NONE); ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; bc->disconnect_callback(&ctx,bc); @@ -7736,19 +7737,19 @@ void unblockClientFromModule(client *c) { /* If we made it here and client is still blocked it means that the command * timed-out, client was killed or disconnected and disconnect_callback was - * not implemented (or it was, but RM_UnblockClient was not called from + * not implemented (or it was, but VM_UnblockClient was not called from * within it, as it should). * We must call moduleUnblockClient in order to free privdata and - * RedisModuleBlockedClient. + * ValkeyModuleBlockedClient. * * Note that we only do that for clients that are blocked on keys, for which - * the contract is that the module should not call RM_UnblockClient under + * the contract is that the module should not call VM_UnblockClient under * normal circumstances. * Clients implementing threads and working with private data should be - * aware that calling RM_UnblockClient for every blocked client is their + * aware that calling VM_UnblockClient for every blocked client is their * responsibility, and if they fail to do so memory may leak. Ideally they * should implement the disconnect and timeout callbacks and call - * RM_UnblockClient, but any other way is also acceptable. */ + * VM_UnblockClient, but any other way is also acceptable. */ if (bc->blocked_on_keys && !bc->unblocked) moduleUnblockClient(c); @@ -7756,36 +7757,36 @@ void unblockClientFromModule(client *c) { } /* Block a client in the context of a module: this function implements both - * RM_BlockClient() and RM_BlockClientOnKeys() depending on the fact the + * VM_BlockClient() and VM_BlockClientOnKeys() depending on the fact the * keys are passed or not. * * When not blocking for keys, the keys, numkeys, and privdata parameters are * not needed. The privdata in that case must be NULL, since later is - * RM_UnblockClient() that will provide some private data that the reply + * VM_UnblockClient() that will provide some private data that the reply * callback will receive. * - * Instead when blocking for keys, normally RM_UnblockClient() will not be + * Instead when blocking for keys, normally VM_UnblockClient() will not be * called (because the client will unblock when the key is modified), so * 'privdata' should be provided in that case, so that once the client is * unlocked and the reply callback is called, it will receive its associated * private data. * - * Even when blocking on keys, RM_UnblockClient() can be called however, but + * Even when blocking on keys, VM_UnblockClient() can be called however, but * in that case the privdata argument is disregarded, because we pass the * reply callback the privdata that is set here while blocking. * */ -RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleAuthCallback auth_reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), - long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata, +ValkeyModuleBlockedClient *moduleBlockClient(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleAuthCallback auth_reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), + long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata, int flags) { client *c = ctx->client; int islua = scriptIsRunning(); int ismulti = server.in_exec; - c->bstate.module_blocked_handle = zmalloc(sizeof(RedisModuleBlockedClient)); - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + c->bstate.module_blocked_handle = zmalloc(sizeof(ValkeyModuleBlockedClient)); + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; ctx->module->blocked_clients++; /* We need to handle the invalid operation of calling modules blocking @@ -7797,7 +7798,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF bc->reply_callback = reply_callback; bc->auth_reply_cb = auth_reply_callback; bc->timeout_callback = timeout_callback; - bc->disconnect_callback = NULL; /* Set by RM_SetDisconnectCallback() */ + bc->disconnect_callback = NULL; /* Set by VM_SetDisconnectCallback() */ bc->free_privdata = free_privdata; bc->privdata = privdata; bc->reply_client = moduleAllocTempClient(); @@ -7826,7 +7827,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF addReplyError(c, islua ? "Blocking module command called from Lua script" : "Blocking module command called from transaction"); - } else if (ctx->flags & REDISMODULE_CTX_BLOCKED_REPLY) { + } else if (ctx->flags & VALKEYMODULE_CTX_BLOCKED_REPLY) { c->bstate.module_blocked_handle = NULL; addReplyError(c, "Blocking module command called from a Reply callback context"); } else if (!auth_reply_callback && clientHasModuleAuthInProgress(c)) { @@ -7834,7 +7835,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF addReplyError(c, "Clients undergoing module based authentication can only be blocked on auth"); } else { if (keys) { - blockForKeys(c,BLOCKED_MODULE,keys,numkeys,timeout,flags&REDISMODULE_BLOCK_UNBLOCK_DELETED); + blockForKeys(c,BLOCKED_MODULE,keys,numkeys,timeout,flags&VALKEYMODULE_BLOCK_UNBLOCK_DELETED); } else { c->bstate.timeout = timeout; blockClient(c,BLOCKED_MODULE); @@ -7850,17 +7851,17 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF * (with AUTH field provided) commands are called. * The callbacks will be called with a module context along with a username and a password, and are * expected to take one of the following actions: - * (1) Authenticate - Use the RM_AuthenticateClient* API and return REDISMODULE_AUTH_HANDLED. + * (1) Authenticate - Use the VM_AuthenticateClient* API and return VALKEYMODULE_AUTH_HANDLED. * This will immediately end the auth chain as successful and add the OK reply. - * (2) Deny Authentication - Return REDISMODULE_AUTH_HANDLED without authenticating or blocking the + * (2) Deny Authentication - Return VALKEYMODULE_AUTH_HANDLED without authenticating or blocking the * client. Optionally, `err` can be set to a custom error message and `err` will be automatically * freed by the server. * This will immediately end the auth chain as unsuccessful and add the ERR reply. - * (3) Block a client on authentication - Use the RM_BlockClientOnAuth API and return - * REDISMODULE_AUTH_HANDLED. Here, the client will be blocked until the RM_UnblockClient API is used - * which will trigger the auth reply callback (provided through the RM_BlockClientOnAuth). + * (3) Block a client on authentication - Use the VM_BlockClientOnAuth API and return + * VALKEYMODULE_AUTH_HANDLED. Here, the client will be blocked until the VM_UnblockClient API is used + * which will trigger the auth reply callback (provided through the VM_BlockClientOnAuth). * In this reply callback, the Module should authenticate, deny or skip handling authentication. - * (4) Skip handling Authentication - Return REDISMODULE_AUTH_NOT_HANDLED without blocking the + * (4) Skip handling Authentication - Return VALKEYMODULE_AUTH_NOT_HANDLED without blocking the * client. This will allow the engine to attempt the next module auth callback. * If none of the callbacks authenticate or deny auth, then password based auth is attempted and * will authenticate or add failure logs and reply to the clients accordingly. @@ -7870,44 +7871,44 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF * * The following is an example of how non-blocking module based authentication can be used: * - * int auth_cb(RedisModuleCtx *ctx, RedisModuleString *username, RedisModuleString *password, RedisModuleString **err) { - * const char *user = RedisModule_StringPtrLen(username, NULL); - * const char *pwd = RedisModule_StringPtrLen(password, NULL); + * int auth_cb(ValkeyModuleCtx *ctx, ValkeyModuleString *username, ValkeyModuleString *password, ValkeyModuleString **err) { + * const char *user = ValkeyModule_StringPtrLen(username, NULL); + * const char *pwd = ValkeyModule_StringPtrLen(password, NULL); * if (!strcmp(user,"foo") && !strcmp(pwd,"valid_password")) { - * RedisModule_AuthenticateClientWithACLUser(ctx, "foo", 3, NULL, NULL, NULL); - * return REDISMODULE_AUTH_HANDLED; + * ValkeyModule_AuthenticateClientWithACLUser(ctx, "foo", 3, NULL, NULL, NULL); + * return VALKEYMODULE_AUTH_HANDLED; * } * * else if (!strcmp(user,"foo") && !strcmp(pwd,"wrong_password")) { - * RedisModuleString *log = RedisModule_CreateString(ctx, "Module Auth", 11); - * RedisModule_ACLAddLogEntryByUserName(ctx, username, log, REDISMODULE_ACL_LOG_AUTH); - * RedisModule_FreeString(ctx, log); + * ValkeyModuleString *log = ValkeyModule_CreateString(ctx, "Module Auth", 11); + * ValkeyModule_ACLAddLogEntryByUserName(ctx, username, log, VALKEYMODULE_ACL_LOG_AUTH); + * ValkeyModule_FreeString(ctx, log); * const char *err_msg = "Auth denied by Misc Module."; - * *err = RedisModule_CreateString(ctx, err_msg, strlen(err_msg)); - * return REDISMODULE_AUTH_HANDLED; + * *err = ValkeyModule_CreateString(ctx, err_msg, strlen(err_msg)); + * return VALKEYMODULE_AUTH_HANDLED; * } - * return REDISMODULE_AUTH_NOT_HANDLED; + * return VALKEYMODULE_AUTH_NOT_HANDLED; * } * - * int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - * if (RedisModule_Init(ctx,"authmodule",1,REDISMODULE_APIVER_1)== REDISMODULE_ERR) - * return REDISMODULE_ERR; - * RedisModule_RegisterAuthCallback(ctx, auth_cb); - * return REDISMODULE_OK; + * int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) { + * if (ValkeyModule_Init(ctx,"authmodule",1,VALKEYMODULE_APIVER_1)== VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; + * ValkeyModule_RegisterAuthCallback(ctx, auth_cb); + * return VALKEYMODULE_OK; * } */ -void RM_RegisterAuthCallback(RedisModuleCtx *ctx, RedisModuleAuthCallback cb) { - RedisModuleAuthCtx *auth_ctx = zmalloc(sizeof(RedisModuleAuthCtx)); +void VM_RegisterAuthCallback(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback cb) { + ValkeyModuleAuthCtx *auth_ctx = zmalloc(sizeof(ValkeyModuleAuthCtx)); auth_ctx->module = ctx->module; auth_ctx->auth_cb = cb; listAddNodeHead(moduleAuthCallbacks, auth_ctx); } /* Helper function to invoke the free private data callback of a Module blocked client. */ -void moduleInvokeFreePrivDataCallback(client *c, RedisModuleBlockedClient *bc) { +void moduleInvokeFreePrivDataCallback(client *c, ValkeyModuleBlockedClient *bc) { if (bc->privdata && bc->free_privdata) { - RedisModuleCtx ctx; - int ctx_flags = c == NULL ? REDISMODULE_CTX_BLOCKED_DISCONNECTED : REDISMODULE_CTX_NONE; + ValkeyModuleCtx ctx; + int ctx_flags = c == NULL ? VALKEYMODULE_CTX_BLOCKED_DISCONNECTED : VALKEYMODULE_CTX_NONE; moduleCreateContext(&ctx, bc->module, ctx_flags); ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; @@ -7917,12 +7918,12 @@ void moduleInvokeFreePrivDataCallback(client *c, RedisModuleBlockedClient *bc) { } /* Unregisters all the module auth callbacks that have been registered by this Module. */ -void moduleUnregisterAuthCBs(RedisModule *module) { +void moduleUnregisterAuthCBs(ValkeyModule *module) { listIter li; listNode *ln; listRewind(moduleAuthCallbacks, &li); while ((ln = listNext(&li))) { - RedisModuleAuthCtx *ctx = listNodeValue(ln); + ValkeyModuleAuthCtx *ctx = listNodeValue(ln); if (ctx->module == module) { listDelNode(moduleAuthCallbacks, ln); zfree(ctx); @@ -7934,11 +7935,11 @@ void moduleUnregisterAuthCBs(RedisModule *module) { * Returns the result of the module auth callback. */ int attemptNextAuthCb(client *c, robj *username, robj *password, robj **err) { int handle_next_callback = c->module_auth_ctx == NULL; - RedisModuleAuthCtx *cur_auth_ctx = NULL; + ValkeyModuleAuthCtx *cur_auth_ctx = NULL; listNode *ln; listIter li; listRewind(moduleAuthCallbacks, &li); - int result = REDISMODULE_AUTH_NOT_HANDLED; + int result = VALKEYMODULE_AUTH_NOT_HANDLED; while((ln = listNext(&li))) { cur_auth_ctx = listNodeValue(ln); /* Skip over the previously attempted auth contexts. */ @@ -7948,32 +7949,32 @@ int attemptNextAuthCb(client *c, robj *username, robj *password, robj **err) { } /* Remove the module auth complete flag before we attempt the next cb. */ c->flags &= ~CLIENT_MODULE_AUTH_HAS_RESULT; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, cur_auth_ctx->module, REDISMODULE_CTX_NONE); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cur_auth_ctx->module, VALKEYMODULE_CTX_NONE); ctx.client = c; *err = NULL; c->module_auth_ctx = cur_auth_ctx; result = cur_auth_ctx->auth_cb(&ctx, username, password, err); moduleFreeContext(&ctx); - if (result == REDISMODULE_AUTH_HANDLED) break; + if (result == VALKEYMODULE_AUTH_HANDLED) break; /* If Auth was not handled (allowed/denied/blocked) by the Module, try the next auth cb. */ } return result; } /* Helper function to handle a reprocessed unblocked auth client. - * Returns REDISMODULE_AUTH_NOT_HANDLED if the client was not reprocessed after a blocking module + * Returns VALKEYMODULE_AUTH_NOT_HANDLED if the client was not reprocessed after a blocking module * auth operation. * Otherwise, we attempt the auth reply callback & the free priv data callback, update fields and * return the result of the reply callback. */ int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, robj **err) { - int result = REDISMODULE_AUTH_NOT_HANDLED; + int result = VALKEYMODULE_AUTH_NOT_HANDLED; if (!c->module_blocked_client) return result; - RedisModuleBlockedClient *bc = (RedisModuleBlockedClient *) c->module_blocked_client; + ValkeyModuleBlockedClient *bc = (ValkeyModuleBlockedClient *) c->module_blocked_client; bc->client = c; if (bc->auth_reply_cb) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_BLOCKED_REPLY); ctx.blocked_privdata = bc->privdata; ctx.blocked_ready_key = NULL; ctx.client = bc->client; @@ -7990,7 +7991,7 @@ int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, r } /* Helper function to attempt Module based authentication through module auth callbacks. - * Here, the Module is expected to authenticate the client using the RedisModule APIs and to add ACL + * Here, the Module is expected to authenticate the client using the ValkeyModule APIs and to add ACL * logs in case of errors. * Returns one of the following codes: * AUTH_OK - Indicates that a module handled and authenticated the client. @@ -8002,16 +8003,16 @@ int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, r int checkModuleAuthentication(client *c, robj *username, robj *password, robj **err) { if (!listLength(moduleAuthCallbacks)) return AUTH_NOT_HANDLED; int result = attemptBlockedAuthReplyCallback(c, username, password, err); - if (result == REDISMODULE_AUTH_NOT_HANDLED) { + if (result == VALKEYMODULE_AUTH_NOT_HANDLED) { result = attemptNextAuthCb(c, username, password, err); } if (c->flags & CLIENT_BLOCKED) { - /* Modules are expected to return REDISMODULE_AUTH_HANDLED when blocking clients. */ - serverAssert(result == REDISMODULE_AUTH_HANDLED); + /* Modules are expected to return VALKEYMODULE_AUTH_HANDLED when blocking clients. */ + serverAssert(result == VALKEYMODULE_AUTH_HANDLED); return AUTH_BLOCKED; } c->module_auth_ctx = NULL; - if (result == REDISMODULE_AUTH_NOT_HANDLED) { + if (result == VALKEYMODULE_AUTH_NOT_HANDLED) { c->flags &= ~CLIENT_MODULE_AUTH_HAS_RESULT; return AUTH_NOT_HANDLED; } @@ -8025,26 +8026,26 @@ int checkModuleAuthentication(client *c, robj *username, robj *password, robj ** /* This function is called from module.c in order to check if a module * blocked for BLOCKED_MODULE and subtype 'on keys' (bc->blocked_on_keys true) * can really be unblocked, since the module was able to serve the client. - * If the callback returns REDISMODULE_OK, then the client can be unblocked, + * If the callback returns VALKEYMODULE_OK, then the client can be unblocked, * otherwise the client remains blocked and we'll retry again when one of * the keys it blocked for becomes "ready" again. * This function returns 1 if client was served (and should be unblocked) */ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { int served = 0; - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; /* Protect against re-processing: don't serve clients that are already - * in the unblocking list for any reason (including RM_UnblockClient() + * in the unblocking list for any reason (including VM_UnblockClient() * explicit call). See #6798. */ if (bc->unblocked) return 0; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_BLOCKED_REPLY); ctx.blocked_ready_key = key; ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; ctx.blocked_client = bc; - if (bc->reply_callback(&ctx,(void**)c->argv,c->argc) == REDISMODULE_OK) + if (bc->reply_callback(&ctx,(void**)c->argv,c->argc) == VALKEYMODULE_OK) served = 1; moduleFreeContext(&ctx); return served; @@ -8052,30 +8053,30 @@ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { /* Block a client in the context of a blocking command, returning a handle * which will be used, later, in order to unblock the client with a call to - * RedisModule_UnblockClient(). The arguments specify callback functions + * ValkeyModule_UnblockClient(). The arguments specify callback functions * and a timeout after which the client is unblocked. * * The callbacks are called in the following contexts: * - * reply_callback: called after a successful RedisModule_UnblockClient() + * reply_callback: called after a successful ValkeyModule_UnblockClient() * call in order to reply to the client and unblock it. * * timeout_callback: called when the timeout is reached or if `CLIENT UNBLOCK` * is invoked, in order to send an error to the client. * * free_privdata: called in order to free the private data that is passed - * by RedisModule_UnblockClient() call. + * by ValkeyModule_UnblockClient() call. * - * Note: RedisModule_UnblockClient should be called for every blocked client, + * Note: ValkeyModule_UnblockClient should be called for every blocked client, * even if client was killed, timed-out or disconnected. Failing to do so * will result in memory leaks. * - * There are some cases where RedisModule_BlockClient() cannot be used: + * There are some cases where ValkeyModule_BlockClient() cannot be used: * * 1. If the client is a Lua script. * 2. If the client is executing a MULTI block. * - * In these cases, a call to RedisModule_BlockClient() will **not** block the + * In these cases, a call to ValkeyModule_BlockClient() will **not** block the * client, but instead produce a specific error reply. * * A module that registers a timeout_callback function can also be unblocked @@ -8086,26 +8087,26 @@ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { * * Measuring background time: By default the time spent in the blocked command * is not account for the total command duration. To include such time you should - * use RM_BlockedClientMeasureTimeStart() and RM_BlockedClientMeasureTimeEnd() one, + * use VM_BlockedClientMeasureTimeStart() and VM_BlockedClientMeasureTimeEnd() one, * or multiple times within the blocking command background work. */ -RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), +ValkeyModuleBlockedClient *VM_BlockClient(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, NULL,0,NULL,0); } /* Block the current client for module authentication in the background. If module auth is not in - * progress on the client, the API returns NULL. Otherwise, the client is blocked and the RM_BlockedClient - * is returned similar to the RM_BlockClient API. + * progress on the client, the API returns NULL. Otherwise, the client is blocked and the VM_BlockedClient + * is returned similar to the VM_BlockClient API. * Note: Only use this API from the context of a module auth callback. */ -RedisModuleBlockedClient *RM_BlockClientOnAuth(RedisModuleCtx *ctx, RedisModuleAuthCallback reply_callback, - void (*free_privdata)(RedisModuleCtx*,void*)) { +ValkeyModuleBlockedClient *VM_BlockClientOnAuth(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback reply_callback, + void (*free_privdata)(ValkeyModuleCtx*,void*)) { if (!clientHasModuleAuthInProgress(ctx->client)) { addReplyError(ctx->client, "Module blocking client on auth when not currently undergoing module authentication"); return NULL; } - RedisModuleBlockedClient *bc = moduleBlockClient(ctx,NULL,reply_callback,NULL,free_privdata,0, NULL,0,NULL,0); + ValkeyModuleBlockedClient *bc = moduleBlockClient(ctx,NULL,reply_callback,NULL,free_privdata,0, NULL,0,NULL,0); if (ctx->client->flags & CLIENT_BLOCKED) { ctx->client->flags |= CLIENT_PENDING_COMMAND; } @@ -8113,16 +8114,16 @@ RedisModuleBlockedClient *RM_BlockClientOnAuth(RedisModuleCtx *ctx, RedisModuleA } /* Get the private data that was previusely set on a blocked client */ -void *RM_BlockClientGetPrivateData(RedisModuleBlockedClient *blocked_client) { +void *VM_BlockClientGetPrivateData(ValkeyModuleBlockedClient *blocked_client) { return blocked_client->privdata; } /* Set private data on a blocked client */ -void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void *private_data) { +void VM_BlockClientSetPrivateData(ValkeyModuleBlockedClient *blocked_client, void *private_data) { blocked_client->privdata = private_data; } -/* This call is similar to RedisModule_BlockClient(), however in this case we +/* This call is similar to ValkeyModule_BlockClient(), however in this case we * don't just block the client, but also ask Redis to unblock it automatically * once certain keys become "ready", that is, contain more data. * @@ -8140,31 +8141,31 @@ void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void * on a list key, an RPUSH command may unblock our client and so forth. * 2. If you are implementing your native data type, or if you want to add new * unblocking conditions in addition to "1", you can call the modules API - * RedisModule_SignalKeyAsReady(). + * ValkeyModule_SignalKeyAsReady(). * * Anyway we can't be sure if the client should be unblocked just because the * key is signaled as ready: for instance a successive operation may change the * key, or a client in queue before this one can be served, modifying the key * as well and making it empty again. So when a client is blocked with - * RedisModule_BlockClientOnKeys() the reply callback is not called after - * RM_UnblockClient() is called, but every time a key is signaled as ready: - * if the reply callback can serve the client, it returns REDISMODULE_OK - * and the client is unblocked, otherwise it will return REDISMODULE_ERR + * ValkeyModule_BlockClientOnKeys() the reply callback is not called after + * VM_UnblockClient() is called, but every time a key is signaled as ready: + * if the reply callback can serve the client, it returns VALKEYMODULE_OK + * and the client is unblocked, otherwise it will return VALKEYMODULE_ERR * and we'll try again later. * * The reply callback can access the key that was signaled as ready by - * calling the API RedisModule_GetBlockedClientReadyKey(), that returns - * just the string name of the key as a RedisModuleString object. + * calling the API ValkeyModule_GetBlockedClientReadyKey(), that returns + * just the string name of the key as a ValkeyModuleString object. * * Thanks to this system we can setup complex blocking scenarios, like * unblocking a client only if a list contains at least 5 items or other * more fancy logics. * - * Note that another difference with RedisModule_BlockClient(), is that here + * Note that another difference with ValkeyModule_BlockClient(), is that here * we pass the private data directly when blocking the client: it will * be accessible later in the reply callback. Normally when blocking with - * RedisModule_BlockClient() the private data to reply to the client is - * passed when calling RedisModule_UnblockClient() but here the unblocking + * ValkeyModule_BlockClient() the private data to reply to the client is + * passed when calling ValkeyModule_UnblockClient() but here the unblocking * is performed by Redis itself, so we need to have some private data before * hand. The private data is used to store any information about the specific * unblocking operation that you are implementing. Such information will be @@ -8173,44 +8174,44 @@ void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void * However the reply callback will be able to access the argument vector of * the command, so the private data is often not needed. * - * Note: Under normal circumstances RedisModule_UnblockClient should not be + * Note: Under normal circumstances ValkeyModule_UnblockClient should not be * called for clients that are blocked on keys (Either the key will * become ready or a timeout will occur). If for some reason you do want - * to call RedisModule_UnblockClient it is possible: Client will be + * to call ValkeyModule_UnblockClient it is possible: Client will be * handled as if it were timed-out (You must implement the timeout * callback in that case). */ -RedisModuleBlockedClient *RM_BlockClientOnKeys(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), - long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata) { +ValkeyModuleBlockedClient *VM_BlockClientOnKeys(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), + long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, keys,numkeys,privdata,0); } -/* Same as RedisModule_BlockClientOnKeys, but can take REDISMODULE_BLOCK_* flags - * Can be either REDISMODULE_BLOCK_UNBLOCK_DEFAULT, which means default behavior (same - * as calling RedisModule_BlockClientOnKeys) +/* Same as ValkeyModule_BlockClientOnKeys, but can take VALKEYMODULE_BLOCK_* flags + * Can be either VALKEYMODULE_BLOCK_UNBLOCK_DEFAULT, which means default behavior (same + * as calling ValkeyModule_BlockClientOnKeys) * * The flags is a bit mask of these: * - * - `REDISMODULE_BLOCK_UNBLOCK_DELETED`: The clients should to be awakened in case any of `keys` are deleted. + * - `VALKEYMODULE_BLOCK_UNBLOCK_DELETED`: The clients should to be awakened in case any of `keys` are deleted. * Mostly useful for commands that require the key to exist (like XREADGROUP) */ -RedisModuleBlockedClient *RM_BlockClientOnKeysWithFlags(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), - long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata, +ValkeyModuleBlockedClient *VM_BlockClientOnKeysWithFlags(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), + long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata, int flags) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, keys,numkeys,privdata,flags); } /* This function is used in order to potentially unblock a client blocked - * on keys with RedisModule_BlockClientOnKeys(). When this function is called, + * on keys with ValkeyModule_BlockClientOnKeys(). When this function is called, * all the clients blocked for this key will get their reply_callback called. */ -void RM_SignalKeyAsReady(RedisModuleCtx *ctx, RedisModuleString *key) { +void VM_SignalKeyAsReady(ValkeyModuleCtx *ctx, ValkeyModuleString *key) { signalKeyAsReady(ctx->client->db, key, OBJ_MODULE); } -/* Implements RM_UnblockClient() and moduleUnblockClient(). */ -int moduleUnblockClientByHandle(RedisModuleBlockedClient *bc, void *privdata) { +/* Implements VM_UnblockClient() and moduleUnblockClient(). */ +int moduleUnblockClientByHandle(ValkeyModuleBlockedClient *bc, void *privdata) { pthread_mutex_lock(&moduleUnblockedClientsMutex); if (!bc->blocked_on_keys) bc->privdata = privdata; bc->unblocked = 1; @@ -8221,24 +8222,24 @@ int moduleUnblockClientByHandle(RedisModuleBlockedClient *bc, void *privdata) { } listAddNodeTail(moduleUnblockedClients,bc); pthread_mutex_unlock(&moduleUnblockedClientsMutex); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This API is used by the Redis core to unblock a client that was blocked * by a module. */ void moduleUnblockClient(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; moduleUnblockClientByHandle(bc,NULL); } /* Return true if the client 'c' was blocked by a module using - * RM_BlockClientOnKeys(). */ + * VM_BlockClientOnKeys(). */ int moduleClientIsBlockedOnKeys(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; return bc->blocked_on_keys; } -/* Unblock a client blocked by `RedisModule_BlockedClient`. This will trigger +/* Unblock a client blocked by `ValkeyModule_BlockedClient`. This will trigger * the reply callbacks to be called in order to reply to the client. * The 'privdata' argument will be accessible by the reply callback, so * the caller of this function can pass any value that is needed in order to @@ -8251,38 +8252,38 @@ int moduleClientIsBlockedOnKeys(client *c) { * Note 1: this function can be called from threads spawned by the module. * * Note 2: when we unblock a client that is blocked for keys using the API - * RedisModule_BlockClientOnKeys(), the privdata argument here is not used. + * ValkeyModule_BlockClientOnKeys(), the privdata argument here is not used. * Unblocking a client that was blocked for keys using this API will still * require the client to get some reply, so the function will use the * "timeout" handler in order to do so (The privdata provided in - * RedisModule_BlockClientOnKeys() is accessible from the timeout - * callback via RM_GetBlockedClientPrivateData). */ -int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) { + * ValkeyModule_BlockClientOnKeys() is accessible from the timeout + * callback via VM_GetBlockedClientPrivateData). */ +int VM_UnblockClient(ValkeyModuleBlockedClient *bc, void *privdata) { if (bc->blocked_on_keys) { /* In theory the user should always pass the timeout handler as an * argument, but better to be safe than sorry. */ - if (bc->timeout_callback == NULL) return REDISMODULE_ERR; - if (bc->unblocked) return REDISMODULE_OK; + if (bc->timeout_callback == NULL) return VALKEYMODULE_ERR; + if (bc->unblocked) return VALKEYMODULE_OK; if (bc->client) moduleBlockedClientTimedOut(bc->client, 1); } moduleUnblockClientByHandle(bc,privdata); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Abort a blocked client blocking operation: the client will be unblocked * without firing any callback. */ -int RM_AbortBlock(RedisModuleBlockedClient *bc) { +int VM_AbortBlock(ValkeyModuleBlockedClient *bc) { bc->reply_callback = NULL; bc->disconnect_callback = NULL; bc->auth_reply_cb = NULL; - return RM_UnblockClient(bc,NULL); + return VM_UnblockClient(bc,NULL); } /* Set a callback that will be called if a blocked client disconnects - * before the module has a chance to call RedisModule_UnblockClient() + * before the module has a chance to call ValkeyModule_UnblockClient() * * Usually what you want to do there, is to cleanup your module state - * so that you can call RedisModule_UnblockClient() safely, otherwise + * so that you can call ValkeyModule_UnblockClient() safely, otherwise * the client will remain blocked forever if the timeout is large. * * Notes: @@ -8294,21 +8295,21 @@ int RM_AbortBlock(RedisModuleBlockedClient *bc) { * a timeout. In such a case, the client is unblocked automatically * and the timeout callback is called. */ -void RM_SetDisconnectCallback(RedisModuleBlockedClient *bc, RedisModuleDisconnectFunc callback) { +void VM_SetDisconnectCallback(ValkeyModuleBlockedClient *bc, ValkeyModuleDisconnectFunc callback) { bc->disconnect_callback = callback; } /* This function will check the moduleUnblockedClients queue in order to * call the reply callback and really unblock the client. * - * Clients end into this list because of calls to RM_UnblockClient(), + * Clients end into this list because of calls to VM_UnblockClient(), * however it is possible that while the module was doing work for the * blocked client, it was terminated by Redis (for timeout or other reasons). - * When this happens the RedisModuleBlockedClient structure in the queue + * When this happens the ValkeyModuleBlockedClient structure in the queue * will have the 'client' field set to NULL. */ void moduleHandleBlockedClients(void) { listNode *ln; - RedisModuleBlockedClient *bc; + ValkeyModuleBlockedClient *bc; pthread_mutex_lock(&moduleUnblockedClientsMutex); while (listLength(moduleUnblockedClients)) { @@ -8323,14 +8324,14 @@ void moduleHandleBlockedClients(void) { /* Call the reply callback if the client is valid and we have * any callback. However the callback is not called if the client - * was blocked on keys (RM_BlockClientOnKeys()), because we already + * was blocked on keys (VM_BlockClientOnKeys()), because we already * called such callback in moduleTryServeClientBlockedOnKey() when * the key was signaled as ready. */ long long prev_error_replies = server.stat_total_error_replies; uint64_t reply_us = 0; if (c && !bc->blocked_on_keys && bc->reply_callback) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_BLOCKED_REPLY); ctx.blocked_privdata = bc->privdata; ctx.blocked_ready_key = NULL; ctx.client = bc->client; @@ -8411,7 +8412,7 @@ int moduleBlockedClientMayTimeout(client *c) { if (c->bstate.btype != BLOCKED_MODULE) return 1; - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; return (bc && bc->timeout_callback != NULL); } @@ -8427,16 +8428,16 @@ int moduleBlockedClientMayTimeout(client *c) { * of the client synchronously. This ensures that we can reply to the client before * resetClient() is called. */ void moduleBlockedClientTimedOut(client *c, int from_module) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; /* Protect against re-processing: don't serve clients that are already - * in the unblocking list for any reason (including RM_UnblockClient() + * in the unblocking list for any reason (including VM_UnblockClient() * explicit call). See #6798. */ if (bc->unblocked) return; - RedisModuleCtx ctx; - int flags = REDISMODULE_CTX_BLOCKED_TIMEOUT; - if (from_module) flags |= REDISMODULE_CTX_THREAD_SAFE; + ValkeyModuleCtx ctx; + int flags = VALKEYMODULE_CTX_BLOCKED_TIMEOUT; + if (from_module) flags |= VALKEYMODULE_CTX_THREAD_SAFE; moduleCreateContext(&ctx, bc->module, flags); ctx.client = bc->client; ctx.blocked_client = bc; @@ -8465,24 +8466,24 @@ void moduleBlockedClientTimedOut(client *c, int from_module) { /* Return non-zero if a module command was called in order to fill the * reply for a blocked client. */ -int RM_IsBlockedReplyRequest(RedisModuleCtx *ctx) { - return (ctx->flags & REDISMODULE_CTX_BLOCKED_REPLY) != 0; +int VM_IsBlockedReplyRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_BLOCKED_REPLY) != 0; } /* Return non-zero if a module command was called in order to fill the * reply for a blocked client that timed out. */ -int RM_IsBlockedTimeoutRequest(RedisModuleCtx *ctx) { - return (ctx->flags & REDISMODULE_CTX_BLOCKED_TIMEOUT) != 0; +int VM_IsBlockedTimeoutRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_BLOCKED_TIMEOUT) != 0; } -/* Get the private data set by RedisModule_UnblockClient() */ -void *RM_GetBlockedClientPrivateData(RedisModuleCtx *ctx) { +/* Get the private data set by ValkeyModule_UnblockClient() */ +void *VM_GetBlockedClientPrivateData(ValkeyModuleCtx *ctx) { return ctx->blocked_privdata; } /* Get the key that is ready when the reply callback is called in the context - * of a client blocked by RedisModule_BlockClientOnKeys(). */ -RedisModuleString *RM_GetBlockedClientReadyKey(RedisModuleCtx *ctx) { + * of a client blocked by ValkeyModule_BlockClientOnKeys(). */ +ValkeyModuleString *VM_GetBlockedClientReadyKey(ValkeyModuleCtx *ctx) { return ctx->blocked_ready_key; } @@ -8490,15 +8491,15 @@ RedisModuleString *RM_GetBlockedClientReadyKey(RedisModuleCtx *ctx) { * This is useful in the reply and timeout callbacks of blocked clients, * before sometimes the module has the blocked client handle references * around, and wants to cleanup it. */ -RedisModuleBlockedClient *RM_GetBlockedClientHandle(RedisModuleCtx *ctx) { +ValkeyModuleBlockedClient *VM_GetBlockedClientHandle(ValkeyModuleCtx *ctx) { return ctx->blocked_client; } /* Return true if when the free callback of a blocked client is called, * the reason for the client to be unblocked is that it disconnected * while it was blocked. */ -int RM_BlockedClientDisconnected(RedisModuleCtx *ctx) { - return (ctx->flags & REDISMODULE_CTX_BLOCKED_DISCONNECTED) != 0; +int VM_BlockedClientDisconnected(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_BLOCKED_DISCONNECTED) != 0; } /* -------------------------------------------------------------------------- @@ -8508,27 +8509,27 @@ int RM_BlockedClientDisconnected(RedisModuleCtx *ctx) { /* Return a context which can be used inside threads to make Redis context * calls with certain modules APIs. If 'bc' is not NULL then the module will * be bound to a blocked client, and it will be possible to use the - * `RedisModule_Reply*` family of functions to accumulate a reply for when the + * `ValkeyModule_Reply*` family of functions to accumulate a reply for when the * client will be unblocked. Otherwise the thread safe context will be * detached by a specific client. * * To call non-reply APIs, the thread safe context must be prepared with: * - * RedisModule_ThreadSafeContextLock(ctx); + * ValkeyModule_ThreadSafeContextLock(ctx); * ... make your call here ... - * RedisModule_ThreadSafeContextUnlock(ctx); + * ValkeyModule_ThreadSafeContextUnlock(ctx); * - * This is not needed when using `RedisModule_Reply*` functions, assuming + * This is not needed when using `ValkeyModule_Reply*` functions, assuming * that a blocked client was used when the context was created, otherwise - * no RedisModule_Reply* call should be made at all. + * no ValkeyModule_Reply* call should be made at all. * * NOTE: If you're creating a detached thread safe context (bc is NULL), - * consider using `RM_GetDetachedThreadSafeContext` which will also retain + * consider using `VM_GetDetachedThreadSafeContext` which will also retain * the module ID and thus be more useful for logging. */ -RedisModuleCtx *RM_GetThreadSafeContext(RedisModuleBlockedClient *bc) { - RedisModuleCtx *ctx = zmalloc(sizeof(*ctx)); - RedisModule *module = bc ? bc->module : NULL; - int flags = REDISMODULE_CTX_THREAD_SAFE; +ValkeyModuleCtx *VM_GetThreadSafeContext(ValkeyModuleBlockedClient *bc) { + ValkeyModuleCtx *ctx = zmalloc(sizeof(*ctx)); + ValkeyModule *module = bc ? bc->module : NULL; + int flags = VALKEYMODULE_CTX_THREAD_SAFE; /* Creating a new client object is costly. To avoid that, we have an * internal pool of client objects. In blockClient(), a client object is @@ -8540,7 +8541,7 @@ RedisModuleCtx *RM_GetThreadSafeContext(RedisModuleBlockedClient *bc) { * Assuming creating detached context is rare and not that performance * critical, we avoid synchronizing access to the client pool by creating * a new client */ - if (!bc) flags |= REDISMODULE_CTX_NEW_CLIENT; + if (!bc) flags |= VALKEYMODULE_CTX_NEW_CLIENT; moduleCreateContext(ctx, module, flags); /* Even when the context is associated with a blocked client, we can't * access it safely from another thread, so we use a fake client here @@ -8563,17 +8564,17 @@ RedisModuleCtx *RM_GetThreadSafeContext(RedisModuleBlockedClient *bc) { * * This is useful for modules that wish to hold a global context over * a long term, for purposes such as logging. */ -RedisModuleCtx *RM_GetDetachedThreadSafeContext(RedisModuleCtx *ctx) { - RedisModuleCtx *new_ctx = zmalloc(sizeof(*new_ctx)); +ValkeyModuleCtx *VM_GetDetachedThreadSafeContext(ValkeyModuleCtx *ctx) { + ValkeyModuleCtx *new_ctx = zmalloc(sizeof(*new_ctx)); /* We create a new client object for the detached context. - * See RM_GetThreadSafeContext() for more information */ + * See VM_GetThreadSafeContext() for more information */ moduleCreateContext(new_ctx, ctx->module, - REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_NEW_CLIENT); + VALKEYMODULE_CTX_THREAD_SAFE|VALKEYMODULE_CTX_NEW_CLIENT); return new_ctx; } /* Release a thread safe context. */ -void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) { +void VM_FreeThreadSafeContext(ValkeyModuleCtx *ctx) { moduleFreeContext(ctx); zfree(ctx); } @@ -8583,35 +8584,35 @@ void moduleGILAfterLock(void) { * code block which already opened a context. */ serverAssert(server.execution_nesting == 0); /* Bump up the nesting level to prevent immediate propagation - * of possible RM_Call from th thread */ + * of possible VM_Call from th thread */ enterExecutionUnit(1, 0); } /* Acquire the server lock before executing a thread safe API call. - * This is not needed for `RedisModule_Reply*` calls when there is + * This is not needed for `ValkeyModule_Reply*` calls when there is * a blocked client connected to the thread safe context. */ -void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) { +void VM_ThreadSafeContextLock(ValkeyModuleCtx *ctx) { UNUSED(ctx); moduleAcquireGIL(); moduleGILAfterLock(); } -/* Similar to RM_ThreadSafeContextLock but this function +/* Similar to VM_ThreadSafeContextLock but this function * would not block if the server lock is already acquired. * - * If successful (lock acquired) REDISMODULE_OK is returned, - * otherwise REDISMODULE_ERR is returned and errno is set + * If successful (lock acquired) VALKEYMODULE_OK is returned, + * otherwise VALKEYMODULE_ERR is returned and errno is set * accordingly. */ -int RM_ThreadSafeContextTryLock(RedisModuleCtx *ctx) { +int VM_ThreadSafeContextTryLock(ValkeyModuleCtx *ctx) { UNUSED(ctx); int res = moduleTryAcquireGIL(); if(res != 0) { errno = res; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } moduleGILAfterLock(); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void moduleGILBeforeUnlock(void) { @@ -8627,7 +8628,7 @@ void moduleGILBeforeUnlock(void) { } /* Release the server lock after a thread safe API call was executed. */ -void RM_ThreadSafeContextUnlock(RedisModuleCtx *ctx) { +void VM_ThreadSafeContextUnlock(ValkeyModuleCtx *ctx) { UNUSED(ctx); moduleGILBeforeUnlock(); moduleReleaseGIL(); @@ -8658,32 +8659,32 @@ void moduleReleaseGIL(void) { * etc), and the subscriber callback receives only events that match a specific * mask of event types. * - * When subscribing to notifications with RedisModule_SubscribeToKeyspaceEvents + * When subscribing to notifications with ValkeyModule_SubscribeToKeyspaceEvents * the module must provide an event type-mask, denoting the events the subscriber * is interested in. This can be an ORed mask of any of the following flags: * - * - REDISMODULE_NOTIFY_GENERIC: Generic commands like DEL, EXPIRE, RENAME - * - REDISMODULE_NOTIFY_STRING: String events - * - REDISMODULE_NOTIFY_LIST: List events - * - REDISMODULE_NOTIFY_SET: Set events - * - REDISMODULE_NOTIFY_HASH: Hash events - * - REDISMODULE_NOTIFY_ZSET: Sorted Set events - * - REDISMODULE_NOTIFY_EXPIRED: Expiration events - * - REDISMODULE_NOTIFY_EVICTED: Eviction events - * - REDISMODULE_NOTIFY_STREAM: Stream events - * - REDISMODULE_NOTIFY_MODULE: Module types events - * - REDISMODULE_NOTIFY_KEYMISS: Key-miss events + * - VALKEYMODULE_NOTIFY_GENERIC: Generic commands like DEL, EXPIRE, RENAME + * - VALKEYMODULE_NOTIFY_STRING: String events + * - VALKEYMODULE_NOTIFY_LIST: List events + * - VALKEYMODULE_NOTIFY_SET: Set events + * - VALKEYMODULE_NOTIFY_HASH: Hash events + * - VALKEYMODULE_NOTIFY_ZSET: Sorted Set events + * - VALKEYMODULE_NOTIFY_EXPIRED: Expiration events + * - VALKEYMODULE_NOTIFY_EVICTED: Eviction events + * - VALKEYMODULE_NOTIFY_STREAM: Stream events + * - VALKEYMODULE_NOTIFY_MODULE: Module types events + * - VALKEYMODULE_NOTIFY_KEYMISS: Key-miss events * Notice, key-miss event is the only type * of event that is fired from within a read command. - * Performing RM_Call with a write command from within + * Performing VM_Call with a write command from within * this notification is wrong and discourage. It will * cause the read command that trigger the event to be * replicated to the AOF/Replica. - * - REDISMODULE_NOTIFY_ALL: All events (Excluding REDISMODULE_NOTIFY_KEYMISS) - * - REDISMODULE_NOTIFY_LOADED: A special notification available only for modules, + * - VALKEYMODULE_NOTIFY_ALL: All events (Excluding VALKEYMODULE_NOTIFY_KEYMISS) + * - VALKEYMODULE_NOTIFY_LOADED: A special notification available only for modules, * indicates that the key was loaded from persistence. * Notice, when this event fires, the given key - * can not be retained, use RM_CreateStringFromString + * can not be retained, use VM_CreateStringFromString * instead. * * We do not distinguish between key events and keyspace events, and it is up @@ -8691,9 +8692,9 @@ void moduleReleaseGIL(void) { * * The subscriber signature is: * - * int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, + * int (*ValkeyModuleNotificationFunc) (ValkeyModuleCtx *ctx, int type, * const char *event, - * RedisModuleString *key); + * ValkeyModuleString *key); * * `type` is the event type bit, that must match the mask given at registration * time. The event string is the actual command being executed, and key is the @@ -8714,19 +8715,19 @@ void moduleReleaseGIL(void) { * that the notification code will be executed in the middle on Redis logic * (commands logic, eviction, expire). Changing the key space while the logic * runs is dangerous and discouraged. In order to react to key space events with - * write actions, please refer to `RM_AddPostNotificationJob`. + * write actions, please refer to `VM_AddPostNotificationJob`. * * See https://redis.io/topics/notifications for more information. */ -int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNotificationFunc callback) { - RedisModuleKeyspaceSubscriber *sub = zmalloc(sizeof(*sub)); +int VM_SubscribeToKeyspaceEvents(ValkeyModuleCtx *ctx, int types, ValkeyModuleNotificationFunc callback) { + ValkeyModuleKeyspaceSubscriber *sub = zmalloc(sizeof(*sub)); sub->module = ctx->module; sub->event_mask = types; sub->notify_callback = callback; sub->active = 0; listAddNodeTail(moduleKeyspaceSubscribers, sub); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void firePostExecutionUnitJobs(void) { @@ -8738,11 +8739,11 @@ void firePostExecutionUnitJobs(void) { enterExecutionUnit(0, 0); while (listLength(modulePostExecUnitJobs) > 0) { listNode *ln = listFirst(modulePostExecUnitJobs); - RedisModulePostExecUnitJob *job = listNodeValue(ln); + ValkeyModulePostExecUnitJob *job = listNodeValue(ln); listDelNode(modulePostExecUnitJobs, ln); - RedisModuleCtx ctx; - moduleCreateContext(&ctx, job->module, REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, job->module, VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, job->dbid); job->callback(&ctx, job->pd); @@ -8755,8 +8756,8 @@ void firePostExecutionUnitJobs(void) { } /* When running inside a key space notification callback, it is dangerous and highly discouraged to perform any write - * operation (See `RM_SubscribeToKeyspaceEvents`). In order to still perform write actions in this scenario, - * Redis provides `RM_AddPostNotificationJob` API. The API allows to register a job callback which Redis will call + * operation (See `VM_SubscribeToKeyspaceEvents`). In order to still perform write actions in this scenario, + * Redis provides `VM_AddPostNotificationJob` API. The API allows to register a job callback which Redis will call * when the following condition are promised to be fulfilled: * 1. It is safe to perform any write operation. * 2. The job will be called atomically along side the key space notification. @@ -8769,13 +8770,13 @@ void firePostExecutionUnitJobs(void) { * * 'free_pd' can be NULL and in such case will not be used. * - * Return REDISMODULE_OK on success and REDISMODULE_ERR if was called while loading data from disk (AOF or RDB) or + * Return VALKEYMODULE_OK on success and VALKEYMODULE_ERR if was called while loading data from disk (AOF or RDB) or * if the instance is a readonly replica. */ -int RM_AddPostNotificationJob(RedisModuleCtx *ctx, RedisModulePostNotificationJobFunc callback, void *privdata, void (*free_privdata)(void*)) { +int VM_AddPostNotificationJob(ValkeyModuleCtx *ctx, ValkeyModulePostNotificationJobFunc callback, void *privdata, void (*free_privdata)(void*)) { if (server.loading|| (server.masterhost && server.repl_slave_ro)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - RedisModulePostExecUnitJob *job = zmalloc(sizeof(*job)); + ValkeyModulePostExecUnitJob *job = zmalloc(sizeof(*job)); job->module = ctx->module; job->callback = callback; job->pd = privdata; @@ -8783,21 +8784,21 @@ int RM_AddPostNotificationJob(RedisModuleCtx *ctx, RedisModulePostNotificationJo job->dbid = ctx->client->db->id; listAddNodeTail(modulePostExecUnitJobs, job); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Get the configured bitmap of notify-keyspace-events (Could be used - * for additional filtering in RedisModuleNotificationFunc) */ -int RM_GetNotifyKeyspaceEvents(void) { + * for additional filtering in ValkeyModuleNotificationFunc) */ +int VM_GetNotifyKeyspaceEvents(void) { return server.notify_keyspace_events; } /* Expose notifyKeyspaceEvent to modules */ -int RM_NotifyKeyspaceEvent(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) { +int VM_NotifyKeyspaceEvent(ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key) { if (!ctx || !ctx->client) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; notifyKeyspaceEvent(type, (char *)event, key, ctx->client->db->id); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Dispatcher for keyspace notifications to module subscriber functions. @@ -8809,7 +8810,7 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) /* Ugly hack to handle modules which use write commands from within * notify_callback, which they should NOT do! - * Modules should use RedisModules_AddPostNotificationJob instead. + * Modules should use ValkeyModules_AddPostNotificationJob instead. * * Anyway, we want any propagated commands from within notify_callback * to be propagated inside a MULTI/EXEC together with the original @@ -8834,13 +8835,13 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) type &= ~(NOTIFY_KEYEVENT | NOTIFY_KEYSPACE); while((ln = listNext(&li))) { - RedisModuleKeyspaceSubscriber *sub = ln->value; + ValkeyModuleKeyspaceSubscriber *sub = ln->value; /* Only notify subscribers on events matching the registration, * and avoid subscribers triggering themselves */ if ((sub->event_mask & type) && - (sub->active == 0 || (sub->module->options & REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS))) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, sub->module, REDISMODULE_CTX_TEMP_CLIENT); + (sub->active == 0 || (sub->module->options & VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS))) { + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, sub->module, VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, dbid); /* mark the handler as active to avoid reentrant loops. @@ -8860,12 +8861,12 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) } /* Unsubscribe any notification subscribers this module has upon unloading */ -void moduleUnsubscribeNotifications(RedisModule *module) { +void moduleUnsubscribeNotifications(ValkeyModule *module) { listIter li; listNode *ln; listRewind(moduleKeyspaceSubscribers,&li); while((ln = listNext(&li))) { - RedisModuleKeyspaceSubscriber *sub = ln->value; + ValkeyModuleKeyspaceSubscriber *sub = ln->value; if (sub->module == module) { listDelNode(moduleKeyspaceSubscribers, ln); zfree(sub); @@ -8878,15 +8879,15 @@ void moduleUnsubscribeNotifications(RedisModule *module) { * -------------------------------------------------------------------------- */ /* The Cluster message callback function pointer type. */ -typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*ValkeyModuleClusterMessageReceiver)(ValkeyModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); /* This structure identifies a registered caller: it must match a given module * ID, for a given message type. The callback function is just the function * that was registered as receiver. */ typedef struct moduleClusterReceiver { uint64_t module_id; - RedisModuleClusterMessageReceiver callback; - struct RedisModule *module; + ValkeyModuleClusterMessageReceiver callback; + struct ValkeyModule *module; struct moduleClusterReceiver *next; } moduleClusterReceiver; @@ -8894,7 +8895,7 @@ typedef struct moduleClusterNodeInfo { int flags; char ip[NET_IP_STR_LEN]; int port; - char master_id[40]; /* Only if flags & REDISMODULE_NODE_MASTER is true. */ + char master_id[40]; /* Only if flags & VALKEYMODULE_NODE_PRIMARY is true. */ } mdouleClusterNodeInfo; /* We have an array of message types: each bucket is a linked list of @@ -8906,8 +8907,8 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8 moduleClusterReceiver *r = clusterReceivers[type]; while(r) { if (r->module_id == module_id) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, r->module, REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, r->module, VALKEYMODULE_CTX_TEMP_CLIENT); r->callback(&ctx,sender_id,type,payload,len); moduleFreeContext(&ctx); return; @@ -8921,7 +8922,7 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8 * with the one provided, otherwise if the callback is set to NULL and there * is already a callback for this function, the callback is unregistered * (so this API call is also used in order to delete the receiver). */ -void RM_RegisterClusterMessageReceiver(RedisModuleCtx *ctx, uint8_t type, RedisModuleClusterMessageReceiver callback) { +void VM_RegisterClusterMessageReceiver(ValkeyModuleCtx *ctx, uint8_t type, ValkeyModuleClusterMessageReceiver callback) { if (!server.cluster_enabled) return; uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0); @@ -8959,60 +8960,60 @@ void RM_RegisterClusterMessageReceiver(RedisModuleCtx *ctx, uint8_t type, RedisM } /* Send a message to all the nodes in the cluster if `target` is NULL, otherwise - * at the specified target, which is a REDISMODULE_NODE_ID_LEN bytes node ID, as + * at the specified target, which is a VALKEYMODULE_NODE_ID_LEN bytes node ID, as * returned by the receiver callback or by the nodes iteration functions. * - * The function returns REDISMODULE_OK if the message was successfully sent, + * The function returns VALKEYMODULE_OK if the message was successfully sent, * otherwise if the node is not connected or such node ID does not map to any - * known cluster node, REDISMODULE_ERR is returned. */ -int RM_SendClusterMessage(RedisModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) { - if (!server.cluster_enabled) return REDISMODULE_ERR; + * known cluster node, VALKEYMODULE_ERR is returned. */ +int VM_SendClusterMessage(ValkeyModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) { + if (!server.cluster_enabled) return VALKEYMODULE_ERR; uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0); if (clusterSendModuleMessageToTarget(target_id,module_id,type,msg,len) == C_OK) - return REDISMODULE_OK; + return VALKEYMODULE_OK; else - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Return an array of string pointers, each string pointer points to a cluster - * node ID of exactly REDISMODULE_NODE_ID_LEN bytes (without any null term). + * node ID of exactly VALKEYMODULE_NODE_ID_LEN bytes (without any null term). * The number of returned node IDs is stored into `*numnodes`. * However if this function is called by a module not running an a Redis * instance with Redis Cluster enabled, NULL is returned instead. * - * The IDs returned can be used with RedisModule_GetClusterNodeInfo() in order + * The IDs returned can be used with ValkeyModule_GetClusterNodeInfo() in order * to get more information about single node. * * The array returned by this function must be freed using the function - * RedisModule_FreeClusterNodesList(). + * ValkeyModule_FreeClusterNodesList(). * * Example: * * size_t count, j; - * char **ids = RedisModule_GetClusterNodesList(ctx,&count); + * char **ids = ValkeyModule_GetClusterNodesList(ctx,&count); * for (j = 0; j < count; j++) { - * RedisModule_Log(ctx,"notice","Node %.*s", - * REDISMODULE_NODE_ID_LEN,ids[j]); + * ValkeyModule_Log(ctx,"notice","Node %.*s", + * VALKEYMODULE_NODE_ID_LEN,ids[j]); * } - * RedisModule_FreeClusterNodesList(ids); + * ValkeyModule_FreeClusterNodesList(ids); */ -char **RM_GetClusterNodesList(RedisModuleCtx *ctx, size_t *numnodes) { +char **VM_GetClusterNodesList(ValkeyModuleCtx *ctx, size_t *numnodes) { UNUSED(ctx); if (!server.cluster_enabled) return NULL; return getClusterNodesList(numnodes); } -/* Free the node list obtained with RedisModule_GetClusterNodesList. */ -void RM_FreeClusterNodesList(char **ids) { +/* Free the node list obtained with ValkeyModule_GetClusterNodesList. */ +void VM_FreeClusterNodesList(char **ids) { if (ids == NULL) return; for (int j = 0; ids[j]; j++) zfree(ids[j]); zfree(ids); } -/* Return this node ID (REDISMODULE_CLUSTER_ID_LEN bytes) or NULL if the cluster +/* Return this node ID (VALKEYMODULE_CLUSTER_ID_LEN bytes) or NULL if the cluster * is disabled. */ -const char *RM_GetMyClusterID(void) { +const char *VM_GetMyClusterID(void) { if (!server.cluster_enabled) return NULL; return getMyClusterId(); } @@ -9021,38 +9022,38 @@ const char *RM_GetMyClusterID(void) { * (handshake, noaddress, ...) so that the number of active nodes may actually * be smaller, but not greater than this number. If the instance is not in * cluster mode, zero is returned. */ -size_t RM_GetClusterSize(void) { +size_t VM_GetClusterSize(void) { if (!server.cluster_enabled) return 0; return getClusterSize(); } /* Populate the specified info for the node having as ID the specified 'id', - * then returns REDISMODULE_OK. Otherwise if the format of node ID is invalid - * or the node ID does not exist from the POV of this local node, REDISMODULE_ERR + * then returns VALKEYMODULE_OK. Otherwise if the format of node ID is invalid + * or the node ID does not exist from the POV of this local node, VALKEYMODULE_ERR * is returned. * * The arguments `ip`, `master_id`, `port` and `flags` can be NULL in case we don't * need to populate back certain info. If an `ip` and `master_id` (only populated * if the instance is a slave) are specified, they point to buffers holding - * at least REDISMODULE_NODE_ID_LEN bytes. The strings written back as `ip` + * at least VALKEYMODULE_NODE_ID_LEN bytes. The strings written back as `ip` * and `master_id` are not null terminated. * * The list of flags reported is the following: * - * * REDISMODULE_NODE_MYSELF: This node - * * REDISMODULE_NODE_MASTER: The node is a master - * * REDISMODULE_NODE_SLAVE: The node is a replica - * * REDISMODULE_NODE_PFAIL: We see the node as failing - * * REDISMODULE_NODE_FAIL: The cluster agrees the node is failing - * * REDISMODULE_NODE_NOFAILOVER: The slave is configured to never failover + * * VALKEYMODULE_NODE_MYSELF: This node + * * VALKEYMODULE_NODE_PRIMARY: The node is a primary + * * VALKEYMODULE_NODE_REPLICA: The node is a replica + * * VALKEYMODULE_NODE_PFAIL: We see the node as failing + * * VALKEYMODULE_NODE_FAIL: The cluster agrees the node is failing + * * VALKEYMODULE_NODE_NOFAILOVER: The slave is configured to never failover */ -int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) { +int VM_GetClusterNodeInfo(ValkeyModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) { UNUSED(ctx); clusterNode *node = clusterLookupNode(id, strlen(id)); if (node == NULL || clusterNodePending(node)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ip) redis_strlcpy(ip, clusterNodeIp(node),NET_IP_STR_LEN); @@ -9062,9 +9063,9 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m * field to zero bytes, so that when the field can't be populated the * function kinda remains predictable. */ if (clusterNodeIsSlave(node) && clusterNodeGetSlaveof(node)) - memcpy(master_id, clusterNodeGetName(clusterNodeGetSlaveof(node)) ,REDISMODULE_NODE_ID_LEN); + memcpy(master_id, clusterNodeGetName(clusterNodeGetSlaveof(node)) ,VALKEYMODULE_NODE_ID_LEN); else - memset(master_id,0,REDISMODULE_NODE_ID_LEN); + memset(master_id,0,VALKEYMODULE_NODE_ID_LEN); } if (port) *port = getNodeDefaultClientPort(node); @@ -9072,14 +9073,14 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m * we can provide binary compatibility. */ if (flags) { *flags = 0; - if (clusterNodeIsMyself(node)) *flags |= REDISMODULE_NODE_MYSELF; - if (clusterNodeIsMaster(node)) *flags |= REDISMODULE_NODE_MASTER; - if (clusterNodeIsSlave(node)) *flags |= REDISMODULE_NODE_SLAVE; - if (clusterNodeTimedOut(node)) *flags |= REDISMODULE_NODE_PFAIL; - if (clusterNodeIsFailing(node)) *flags |= REDISMODULE_NODE_FAIL; - if (clusterNodeIsNoFailover(node)) *flags |= REDISMODULE_NODE_NOFAILOVER; + if (clusterNodeIsMyself(node)) *flags |= VALKEYMODULE_NODE_MYSELF; + if (clusterNodeIsMaster(node)) *flags |= VALKEYMODULE_NODE_PRIMARY; + if (clusterNodeIsSlave(node)) *flags |= VALKEYMODULE_NODE_REPLICA; + if (clusterNodeTimedOut(node)) *flags |= VALKEYMODULE_NODE_PFAIL; + if (clusterNodeIsFailing(node)) *flags |= VALKEYMODULE_NODE_FAIL; + if (clusterNodeIsNoFailover(node)) *flags |= VALKEYMODULE_NODE_NOFAILOVER; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Set Redis Cluster flags in order to change the normal behavior of @@ -9100,24 +9101,24 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m * partitioning according to the Redis Cluster algorithm. * Slots information will still be propagated across the * cluster, but without effect. */ -void RM_SetClusterFlags(RedisModuleCtx *ctx, uint64_t flags) { +void VM_SetClusterFlags(ValkeyModuleCtx *ctx, uint64_t flags) { UNUSED(ctx); - if (flags & REDISMODULE_CLUSTER_FLAG_NO_FAILOVER) + if (flags & VALKEYMODULE_CLUSTER_FLAG_NO_FAILOVER) server.cluster_module_flags |= CLUSTER_MODULE_FLAG_NO_FAILOVER; - if (flags & REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION) + if (flags & VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION) server.cluster_module_flags |= CLUSTER_MODULE_FLAG_NO_REDIRECTION; } /* Returns the cluster slot of a key, similar to the `CLUSTER KEYSLOT` command. * This function works even if cluster mode is not enabled. */ -unsigned int RM_ClusterKeySlot(RedisModuleString *key) { +unsigned int VM_ClusterKeySlot(ValkeyModuleString *key) { return keyHashSlot(key->ptr, sdslen(key->ptr)); } /* Returns a short string that can be used as a key or as a hash tag in a key, * such that the key maps to the given cluster slot. Returns NULL if slot is not * a valid slot. */ -const char *RM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { +const char *VM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { return (slot < CLUSTER_SLOTS) ? crc16_slot_table[slot] : NULL; } @@ -9143,15 +9144,15 @@ const char *RM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { static rax *Timers; /* The radix tree of all the timers sorted by expire. */ long long aeTimer = -1; /* Main event loop (ae.c) timer identifier. */ -typedef void (*RedisModuleTimerProc)(RedisModuleCtx *ctx, void *data); +typedef void (*ValkeyModuleTimerProc)(ValkeyModuleCtx *ctx, void *data); /* The timer descriptor, stored as value in the radix tree. */ -typedef struct RedisModuleTimer { - RedisModule *module; /* Module reference. */ - RedisModuleTimerProc callback; /* The callback to invoke on expire. */ +typedef struct ValkeyModuleTimer { + ValkeyModule *module; /* Module reference. */ + ValkeyModuleTimerProc callback; /* The callback to invoke on expire. */ void *data; /* Private data for the callback. */ int dbid; /* Database number selected by the original client. */ -} RedisModuleTimer; +} ValkeyModuleTimer; /* This is the timer handler that is called by the main event loop. We schedule * this timer to be called when the nearest of our module timers will expire. */ @@ -9172,9 +9173,9 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client memcpy(&expiretime,ri.key,sizeof(expiretime)); expiretime = ntohu64(expiretime); if (now >= expiretime) { - RedisModuleTimer *timer = ri.data; - RedisModuleCtx ctx; - moduleCreateContext(&ctx,timer->module,REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleTimer *timer = ri.data; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx,timer->module,VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, timer->dbid); timer->callback(&ctx,timer->data); moduleFreeContext(&ctx); @@ -9207,7 +9208,7 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client * the specified function using `data` as argument. The returned timer ID can be * used to get information from the timer or to stop it before it fires. * Note that for the common use case of a repeating timer (Re-registration - * of the timer inside the RedisModuleTimerProc callback) it matters when + * of the timer inside the ValkeyModuleTimerProc callback) it matters when * this API is called: * If it is called at the beginning of 'callback' it means * the event will triggered every 'period'. @@ -9215,8 +9216,8 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client * there will 'period' milliseconds gaps between events. * (If the time it takes to execute 'callback' is negligible the two * statements above mean the same) */ -RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisModuleTimerProc callback, void *data) { - RedisModuleTimer *timer = zmalloc(sizeof(*timer)); +ValkeyModuleTimerID VM_CreateTimer(ValkeyModuleCtx *ctx, mstime_t period, ValkeyModuleTimerProc callback, void *data) { + ValkeyModuleTimer *timer = zmalloc(sizeof(*timer)); timer->module = ctx->module; timer->callback = callback; timer->data = data; @@ -9260,54 +9261,54 @@ RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisMod return key; } -/* Stop a timer, returns REDISMODULE_OK if the timer was found, belonged to the - * calling module, and was stopped, otherwise REDISMODULE_ERR is returned. +/* Stop a timer, returns VALKEYMODULE_OK if the timer was found, belonged to the + * calling module, and was stopped, otherwise VALKEYMODULE_ERR is returned. * If not NULL, the data pointer is set to the value of the data argument when * the timer was created. */ -int RM_StopTimer(RedisModuleCtx *ctx, RedisModuleTimerID id, void **data) { +int VM_StopTimer(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, void **data) { void *result; if (!raxFind(Timers,(unsigned char*)&id,sizeof(id),&result)) - return REDISMODULE_ERR; - RedisModuleTimer *timer = result; + return VALKEYMODULE_ERR; + ValkeyModuleTimer *timer = result; if (timer->module != ctx->module) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (data) *data = timer->data; raxRemove(Timers,(unsigned char*)&id,sizeof(id),NULL); zfree(timer); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Obtain information about a timer: its remaining time before firing * (in milliseconds), and the private data pointer associated with the timer. * If the timer specified does not exist or belongs to a different module - * no information is returned and the function returns REDISMODULE_ERR, otherwise - * REDISMODULE_OK is returned. The arguments remaining or data can be NULL if + * no information is returned and the function returns VALKEYMODULE_ERR, otherwise + * VALKEYMODULE_OK is returned. The arguments remaining or data can be NULL if * the caller does not need certain information. */ -int RM_GetTimerInfo(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remaining, void **data) { +int VM_GetTimerInfo(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, uint64_t *remaining, void **data) { void *result; if (!raxFind(Timers,(unsigned char*)&id,sizeof(id),&result)) - return REDISMODULE_ERR; - RedisModuleTimer *timer = result; + return VALKEYMODULE_ERR; + ValkeyModuleTimer *timer = result; if (timer->module != ctx->module) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (remaining) { int64_t rem = ntohu64(id)-ustime(); if (rem < 0) rem = 0; *remaining = rem/1000; /* Scale to milliseconds. */ } if (data) *data = timer->data; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Query timers to see if any timer belongs to the module. * Return 1 if any timer was found, otherwise 0 would be returned. */ -int moduleHoldsTimer(struct RedisModule *module) { +int moduleHoldsTimer(struct ValkeyModule *module) { raxIterator iter; int found = 0; raxStart(&iter,Timers); raxSeek(&iter,"^",NULL,0); while (raxNext(&iter)) { - RedisModuleTimer *timer = iter.data; + ValkeyModuleTimer *timer = iter.data; if (timer->module == module) { found = 1; break; @@ -9322,13 +9323,13 @@ int moduleHoldsTimer(struct RedisModule *module) { * --------------------------------------------------------------------------*/ typedef struct EventLoopData { - RedisModuleEventLoopFunc rFunc; - RedisModuleEventLoopFunc wFunc; + ValkeyModuleEventLoopFunc rFunc; + ValkeyModuleEventLoopFunc wFunc; void *user_data; } EventLoopData; typedef struct EventLoopOneShot { - RedisModuleEventLoopOneShotFunc func; + ValkeyModuleEventLoopOneShotFunc func; void *user_data; } EventLoopOneShot; @@ -9337,9 +9338,9 @@ static pthread_mutex_t moduleEventLoopMutex = PTHREAD_MUTEX_INITIALIZER; static int eventLoopToAeMask(int mask) { int aeMask = 0; - if (mask & REDISMODULE_EVENTLOOP_READABLE) + if (mask & VALKEYMODULE_EVENTLOOP_READABLE) aeMask |= AE_READABLE; - if (mask & REDISMODULE_EVENTLOOP_WRITABLE) + if (mask & VALKEYMODULE_EVENTLOOP_WRITABLE) aeMask |= AE_WRITABLE; return aeMask; } @@ -9347,9 +9348,9 @@ static int eventLoopToAeMask(int mask) { static int eventLoopFromAeMask(int ae_mask) { int mask = 0; if (ae_mask & AE_READABLE) - mask |= REDISMODULE_EVENTLOOP_READABLE; + mask |= VALKEYMODULE_EVENTLOOP_READABLE; if (ae_mask & AE_WRITABLE) - mask |= REDISMODULE_EVENTLOOP_WRITABLE; + mask |= VALKEYMODULE_EVENTLOOP_WRITABLE; return mask; } @@ -9369,12 +9370,12 @@ static void eventLoopCbWritable(struct aeEventLoop *ae, int fd, void *user_data, * * * `mask` must be one of the following values: * - * * `REDISMODULE_EVENTLOOP_READABLE` - * * `REDISMODULE_EVENTLOOP_WRITABLE` - * * `REDISMODULE_EVENTLOOP_READABLE | REDISMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE` + * * `VALKEYMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE | VALKEYMODULE_EVENTLOOP_WRITABLE` * - * On success REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to the following values: + * On success VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to the following values: * * * ERANGE: `fd` is negative or higher than `maxclients` Redis config. * * EINVAL: `callback` is NULL or `mask` value is invalid. @@ -9388,23 +9389,23 @@ static void eventLoopCbWritable(struct aeEventLoop *ae, int fd, void *user_data, * int bytes = read(fd,buf,sizeof(buf)); * printf("Read %d bytes \n", bytes); * } - * RM_EventLoopAdd(fd, REDISMODULE_EVENTLOOP_READABLE, onReadable, NULL); + * VM_EventLoopAdd(fd, VALKEYMODULE_EVENTLOOP_READABLE, onReadable, NULL); */ -int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_data) { +int VM_EventLoopAdd(int fd, int mask, ValkeyModuleEventLoopFunc func, void *user_data) { if (fd < 0 || fd >= aeGetSetSize(server.el)) { errno = ERANGE; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (!func || mask & ~(REDISMODULE_EVENTLOOP_READABLE | - REDISMODULE_EVENTLOOP_WRITABLE)) { + if (!func || mask & ~(VALKEYMODULE_EVENTLOOP_READABLE | + VALKEYMODULE_EVENTLOOP_WRITABLE)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* We are going to register stub callbacks to 'ae' for two reasons: * - * - "ae" callback signature is different from RedisModuleEventLoopCallback, + * - "ae" callback signature is different from ValkeyModuleEventLoopCallback, * that will be handled it in our stub callbacks. * - We need to remap 'mask' value to provide binary compatibility. * @@ -9417,7 +9418,7 @@ int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_ data = zcalloc(sizeof(*data)); aeFileProc *aeProc; - if (mask & REDISMODULE_EVENTLOOP_READABLE) + if (mask & VALKEYMODULE_EVENTLOOP_READABLE) aeProc = eventLoopCbReadable; else aeProc = eventLoopCbWritable; @@ -9427,43 +9428,43 @@ int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_ if (aeCreateFileEvent(server.el, fd, aeMask, aeProc, data) != AE_OK) { if (aeGetFileEvents(server.el, fd) == AE_NONE) zfree(data); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } data->user_data = user_data; - if (mask & REDISMODULE_EVENTLOOP_READABLE) + if (mask & VALKEYMODULE_EVENTLOOP_READABLE) data->rFunc = func; - if (mask & REDISMODULE_EVENTLOOP_WRITABLE) + if (mask & VALKEYMODULE_EVENTLOOP_WRITABLE) data->wFunc = func; errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Delete a pipe / socket event from the event loop. * * * `mask` must be one of the following values: * - * * `REDISMODULE_EVENTLOOP_READABLE` - * * `REDISMODULE_EVENTLOOP_WRITABLE` - * * `REDISMODULE_EVENTLOOP_READABLE | REDISMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE` + * * `VALKEYMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE | VALKEYMODULE_EVENTLOOP_WRITABLE` * - * On success REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to the following values: + * On success VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to the following values: * * * ERANGE: `fd` is negative or higher than `maxclients` Redis config. * * EINVAL: `mask` value is invalid. */ -int RM_EventLoopDel(int fd, int mask) { +int VM_EventLoopDel(int fd, int mask) { if (fd < 0 || fd >= aeGetSetSize(server.el)) { errno = ERANGE; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (mask & ~(REDISMODULE_EVENTLOOP_READABLE | - REDISMODULE_EVENTLOOP_WRITABLE)) { + if (mask & ~(VALKEYMODULE_EVENTLOOP_READABLE | + VALKEYMODULE_EVENTLOOP_WRITABLE)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* After deleting the event, if fd does not have any registered event @@ -9474,17 +9475,17 @@ int RM_EventLoopDel(int fd, int mask) { zfree(data); errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This function can be called from other threads to trigger callback on Redis - * main thread. On success REDISMODULE_OK is returned. If `func` is NULL - * REDISMODULE_ERR is returned and errno is set to EINVAL. + * main thread. On success VALKEYMODULE_OK is returned. If `func` is NULL + * VALKEYMODULE_ERR is returned and errno is set to EINVAL. */ -int RM_EventLoopAddOneShot(RedisModuleEventLoopOneShotFunc func, void *user_data) { +int VM_EventLoopAddOneShot(ValkeyModuleEventLoopOneShotFunc func, void *user_data) { if (!func) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } EventLoopOneShot *oneshot = zmalloc(sizeof(*oneshot)); @@ -9501,7 +9502,7 @@ int RM_EventLoopAddOneShot(RedisModuleEventLoopOneShotFunc func, void *user_data } errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This function will check the moduleEventLoopOneShots queue in order to @@ -9572,7 +9573,7 @@ void revokeClientAuthentication(client *c) { /* Cleanup all clients that have been authenticated with this module. This * is called from onUnload() to give the module a chance to cleanup any * resources associated with clients it has authenticated. */ -static void moduleFreeAuthenticatedClients(RedisModule *module) { +static void moduleFreeAuthenticatedClients(ValkeyModule *module) { listIter li; listNode *ln; listRewind(server.clients,&li); @@ -9580,7 +9581,7 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { client *c = listNodeValue(ln); if (!c->auth_module) continue; - RedisModule *auth_module = (RedisModule *) c->auth_module; + ValkeyModule *auth_module = (ValkeyModule *) c->auth_module; if (auth_module == module) { revokeClientAuthentication(c); } @@ -9589,9 +9590,9 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { /* Creates a Redis ACL user that the module can use to authenticate a client. * After obtaining the user, the module should set what such user can do - * using the RM_SetUserACL() function. Once configured, the user + * using the VM_SetUserACL() function. Once configured, the user * can be used in order to authenticate a connection, with the specified - * ACL rules, using the RedisModule_AuthClientWithUser() function. + * ACL rules, using the ValkeyModule_AuthClientWithUser() function. * * Note that: * @@ -9602,13 +9603,13 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { * * The created user can be used to authenticate multiple Redis connections. * * The caller can later free the user using the function - * RM_FreeModuleUser(). When this function is called, if there are + * VM_FreeModuleUser(). When this function is called, if there are * still clients authenticated with this user, they are disconnected. * The function to free the user should only be used when the caller really * wants to invalidate the user to define a new one with different * capabilities. */ -RedisModuleUser *RM_CreateModuleUser(const char *name) { - RedisModuleUser *new_user = zmalloc(sizeof(RedisModuleUser)); +ValkeyModuleUser *VM_CreateModuleUser(const char *name) { + ValkeyModuleUser *new_user = zmalloc(sizeof(ValkeyModuleUser)); new_user->user = ACLCreateUnlinkedUser(); new_user->free_user = 1; @@ -9619,33 +9620,33 @@ RedisModuleUser *RM_CreateModuleUser(const char *name) { } /* Frees a given user and disconnects all of the clients that have been - * authenticated with it. See RM_CreateModuleUser for detailed usage.*/ -int RM_FreeModuleUser(RedisModuleUser *user) { + * authenticated with it. See VM_CreateModuleUser for detailed usage.*/ +int VM_FreeModuleUser(ValkeyModuleUser *user) { if (user->free_user) ACLFreeUserAndKillClients(user->user); zfree(user); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Sets the permissions of a user created through the redis module * interface. The syntax is the same as ACL SETUSER, so refer to the - * documentation in acl.c for more information. See RM_CreateModuleUser + * documentation in acl.c for more information. See VM_CreateModuleUser * for detailed usage. * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on failure + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on failure * and will set an errno describing why the operation failed. */ -int RM_SetModuleUserACL(RedisModuleUser *user, const char* acl) { +int VM_SetModuleUserACL(ValkeyModuleUser *user, const char* acl) { return ACLSetUser(user->user, acl, -1); } /* Sets the permission of a user with a complete ACL string, such as one * would use on the redis ACL SETUSER command line API. This differs from - * RM_SetModuleUserACL, which only takes single ACL operations at a time. + * VM_SetModuleUserACL, which only takes single ACL operations at a time. * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on failure - * if a RedisModuleString is provided in error, a string describing the error + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on failure + * if a ValkeyModuleString is provided in error, a string describing the error * will be returned */ -int RM_SetModuleUserACLString(RedisModuleCtx *ctx, RedisModuleUser *user, const char *acl, RedisModuleString **error) { +int VM_SetModuleUserACLString(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, const char *acl, ValkeyModuleString **error) { serverAssert(user != NULL); int argc; @@ -9658,55 +9659,55 @@ int RM_SetModuleUserACLString(RedisModuleCtx *ctx, RedisModuleUser *user, const if (err) { if (error) { *error = createObject(OBJ_STRING, err); - if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, *error); + if (ctx != NULL) autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, *error); } else { sdsfree(err); } - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Get the ACL string for a given user - * Returns a RedisModuleString + * Returns a ValkeyModuleString */ -RedisModuleString *RM_GetModuleUserACLString(RedisModuleUser *user) { +ValkeyModuleString *VM_GetModuleUserACLString(ValkeyModuleUser *user) { serverAssert(user != NULL); return ACLDescribeUser(user->user); } /* Retrieve the user name of the client connection behind the current context. - * The user name can be used later, in order to get a RedisModuleUser. - * See more information in RM_GetModuleUserFromUserName. + * The user name can be used later, in order to get a ValkeyModuleUser. + * See more information in VM_GetModuleUserFromUserName. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. */ -RedisModuleString *RM_GetCurrentUserName(RedisModuleCtx *ctx) { - return RM_CreateString(ctx,ctx->client->user->name,sdslen(ctx->client->user->name)); +ValkeyModuleString *VM_GetCurrentUserName(ValkeyModuleCtx *ctx) { + return VM_CreateString(ctx,ctx->client->user->name,sdslen(ctx->client->user->name)); } -/* A RedisModuleUser can be used to check if command, key or channel can be executed or +/* A ValkeyModuleUser can be used to check if command, key or channel can be executed or * accessed according to the ACLs rules associated with that user. - * When a Module wants to do ACL checks on a general ACL user (not created by RM_CreateModuleUser), - * it can get the RedisModuleUser from this API, based on the user name retrieved by RM_GetCurrentUserName. + * When a Module wants to do ACL checks on a general ACL user (not created by VM_CreateModuleUser), + * it can get the ValkeyModuleUser from this API, based on the user name retrieved by VM_GetCurrentUserName. * - * Since a general ACL user can be deleted at any time, this RedisModuleUser should be used only in the context + * Since a general ACL user can be deleted at any time, this ValkeyModuleUser should be used only in the context * where this function was called. In order to do ACL checks out of that context, the Module can store the user name, * and call this API at any other context. * * Returns NULL if the user is disabled or the user does not exist. - * The caller should later free the user using the function RM_FreeModuleUser().*/ -RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) { + * The caller should later free the user using the function VM_FreeModuleUser().*/ +ValkeyModuleUser *VM_GetModuleUserFromUserName(ValkeyModuleString *name) { /* First, verify that the user exist */ user *acl_user = ACLGetUserByName(name->ptr, sdslen(name->ptr)); if (acl_user == NULL) { return NULL; } - RedisModuleUser *new_user = zmalloc(sizeof(RedisModuleUser)); + ValkeyModuleUser *new_user = zmalloc(sizeof(ValkeyModuleUser)); new_user->user = acl_user; new_user->free_user = 0; return new_user; @@ -9714,136 +9715,136 @@ RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) { /* Checks if the command can be executed by the user, according to the ACLs associated with it. * - * On success a REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to the following values: + * On success a VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to the following values: * * * ENOENT: Specified command does not exist. * * EACCES: Command cannot be executed, according to ACL rules */ -int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **argv, int argc) { +int VM_ACLCheckCommandPermissions(ValkeyModuleUser *user, ValkeyModuleString **argv, int argc) { int keyidxptr; struct serverCommand *cmd; /* Find command */ if ((cmd = lookupCommand(argv, argc)) == NULL) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ACLCheckAllUserCommandPerm(user->user, cmd, argv, argc, &keyidxptr) != ACL_OK) { errno = EACCES; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Check if the key can be accessed by the user according to the ACLs attached to the user * and the flags representing the key access. The flags are the same that are used in the - * keyspec for logical operations. These flags are documented in RedisModule_SetCommandInfo as - * the REDISMODULE_CMD_KEY_ACCESS, REDISMODULE_CMD_KEY_UPDATE, REDISMODULE_CMD_KEY_INSERT, - * and REDISMODULE_CMD_KEY_DELETE flags. + * keyspec for logical operations. These flags are documented in ValkeyModule_SetCommandInfo as + * the VALKEYMODULE_CMD_KEY_ACCESS, VALKEYMODULE_CMD_KEY_UPDATE, VALKEYMODULE_CMD_KEY_INSERT, + * and VALKEYMODULE_CMD_KEY_DELETE flags. * * If no flags are supplied, the user is still required to have some access to the key for * this command to return successfully. * - * If the user is able to access the key then REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to one of the following values: + * If the user is able to access the key then VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to one of the following values: * * * EINVAL: The provided flags are invalid. * * EACCESS: The user does not have permission to access the key. */ -int RM_ACLCheckKeyPermissions(RedisModuleUser *user, RedisModuleString *key, int flags) { - const int allow_mask = (REDISMODULE_CMD_KEY_ACCESS - | REDISMODULE_CMD_KEY_INSERT - | REDISMODULE_CMD_KEY_DELETE - | REDISMODULE_CMD_KEY_UPDATE); +int VM_ACLCheckKeyPermissions(ValkeyModuleUser *user, ValkeyModuleString *key, int flags) { + const int allow_mask = (VALKEYMODULE_CMD_KEY_ACCESS + | VALKEYMODULE_CMD_KEY_INSERT + | VALKEYMODULE_CMD_KEY_DELETE + | VALKEYMODULE_CMD_KEY_UPDATE); if ((flags & allow_mask) != flags) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } int keyspec_flags = moduleConvertKeySpecsFlags(flags, 0); if (ACLUserCheckKeyPerm(user->user, key->ptr, sdslen(key->ptr), keyspec_flags) != ACL_OK) { errno = EACCES; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Check if the pubsub channel can be accessed by the user based off of the given - * access flags. See RM_ChannelAtPosWithFlags for more information about the + * access flags. See VM_ChannelAtPosWithFlags for more information about the * possible flags that can be passed in. * - * If the user is able to access the pubsub channel then REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to one of the following values: + * If the user is able to access the pubsub channel then VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to one of the following values: * * * EINVAL: The provided flags are invalid. * * EACCESS: The user does not have permission to access the pubsub channel. */ -int RM_ACLCheckChannelPermissions(RedisModuleUser *user, RedisModuleString *ch, int flags) { - const int allow_mask = (REDISMODULE_CMD_CHANNEL_PUBLISH - | REDISMODULE_CMD_CHANNEL_SUBSCRIBE - | REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE - | REDISMODULE_CMD_CHANNEL_PATTERN); +int VM_ACLCheckChannelPermissions(ValkeyModuleUser *user, ValkeyModuleString *ch, int flags) { + const int allow_mask = (VALKEYMODULE_CMD_CHANNEL_PUBLISH + | VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE + | VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE + | VALKEYMODULE_CMD_CHANNEL_PATTERN); if ((flags & allow_mask) != flags) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Unsubscribe permissions are currently always allowed. */ - if (flags & REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE){ - return REDISMODULE_OK; + if (flags & VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE){ + return VALKEYMODULE_OK; } - int is_pattern = flags & REDISMODULE_CMD_CHANNEL_PATTERN; + int is_pattern = flags & VALKEYMODULE_CMD_CHANNEL_PATTERN; if (ACLUserCheckChannelPerm(user->user, ch->ptr, is_pattern) != ACL_OK) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Helper function to map a RedisModuleACLLogEntryReason to ACL Log entry reason. */ -int moduleGetACLLogEntryReason(RedisModuleACLLogEntryReason reason) { +/* Helper function to map a ValkeyModuleACLLogEntryReason to ACL Log entry reason. */ +int moduleGetACLLogEntryReason(ValkeyModuleACLLogEntryReason reason) { int acl_reason = 0; switch (reason) { - case REDISMODULE_ACL_LOG_AUTH: acl_reason = ACL_DENIED_AUTH; break; - case REDISMODULE_ACL_LOG_KEY: acl_reason = ACL_DENIED_KEY; break; - case REDISMODULE_ACL_LOG_CHANNEL: acl_reason = ACL_DENIED_CHANNEL; break; - case REDISMODULE_ACL_LOG_CMD: acl_reason = ACL_DENIED_CMD; break; + case VALKEYMODULE_ACL_LOG_AUTH: acl_reason = ACL_DENIED_AUTH; break; + case VALKEYMODULE_ACL_LOG_KEY: acl_reason = ACL_DENIED_KEY; break; + case VALKEYMODULE_ACL_LOG_CHANNEL: acl_reason = ACL_DENIED_CHANNEL; break; + case VALKEYMODULE_ACL_LOG_CMD: acl_reason = ACL_DENIED_CMD; break; default: break; } return acl_reason; } /* Adds a new entry in the ACL log. - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on error. + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on error. * * For more information about ACL log, please refer to https://redis.io/commands/acl-log */ -int RM_ACLAddLogEntry(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleString *object, RedisModuleACLLogEntryReason reason) { +int VM_ACLAddLogEntry(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) { int acl_reason = moduleGetACLLogEntryReason(reason); - if (!acl_reason) return REDISMODULE_ERR; + if (!acl_reason) return VALKEYMODULE_ERR; addACLLogEntry(ctx->client, acl_reason, ACL_LOG_CTX_MODULE, -1, user->user->name, sdsdup(object->ptr)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Adds a new entry in the ACL log with the `username` RedisModuleString provided. - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on error. +/* Adds a new entry in the ACL log with the `username` ValkeyModuleString provided. + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on error. * * For more information about ACL log, please refer to https://redis.io/commands/acl-log */ -int RM_ACLAddLogEntryByUserName(RedisModuleCtx *ctx, RedisModuleString *username, RedisModuleString *object, RedisModuleACLLogEntryReason reason) { +int VM_ACLAddLogEntryByUserName(ValkeyModuleCtx *ctx, ValkeyModuleString *username, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) { int acl_reason = moduleGetACLLogEntryReason(reason); - if (!acl_reason) return REDISMODULE_ERR; + if (!acl_reason) return VALKEYMODULE_ERR; addACLLogEntry(ctx->client, acl_reason, ACL_LOG_CTX_MODULE, -1, username->ptr, sdsdup(object->ptr)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Authenticate the client associated with the context with - * the provided user. Returns REDISMODULE_OK on success and - * REDISMODULE_ERR on error. + * the provided user. Returns VALKEYMODULE_OK on success and + * VALKEYMODULE_ERR on error. * * This authentication can be tracked with the optional callback and private * data fields. The callback will be called whenever the user of the client @@ -9855,20 +9856,20 @@ int RM_ACLAddLogEntryByUserName(RedisModuleCtx *ctx, RedisModuleString *username * * If client_id is not NULL, it will be filled with the id of the client * that was authenticated. This can be used with the - * RM_DeauthenticateAndCloseClient() API in order to deauthenticate a + * VM_DeauthenticateAndCloseClient() API in order to deauthenticate a * previously authenticated client if the authentication is no longer valid. * * For expensive authentication operations, it is recommended to block the * client and do the authentication in the background and then attach the user * to the client in a threadsafe context. */ -static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { +static int authenticateClientWithUser(ValkeyModuleCtx *ctx, user *user, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { if (user->flags & USER_FLAG_DISABLED) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Avoid settings which are meaningless and will be lost */ if (!ctx->client || (ctx->client->flags & CLIENT_MODULE)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } moduleNotifyUserChanged(ctx->client); @@ -9890,29 +9891,29 @@ static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModu *client_id = ctx->client->id; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Authenticate the current context's user with the provided redis acl user. - * Returns REDISMODULE_ERR if the user is disabled. + * Returns VALKEYMODULE_ERR if the user is disabled. * * See authenticateClientWithUser for information about callback, client_id, * and general usage for authentication. */ -int RM_AuthenticateClientWithUser(RedisModuleCtx *ctx, RedisModuleUser *module_user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { +int VM_AuthenticateClientWithUser(ValkeyModuleCtx *ctx, ValkeyModuleUser *module_user, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { return authenticateClientWithUser(ctx, module_user->user, callback, privdata, client_id); } /* Authenticate the current context's user with the provided redis acl user. - * Returns REDISMODULE_ERR if the user is disabled or the user does not exist. + * Returns VALKEYMODULE_ERR if the user is disabled or the user does not exist. * * See authenticateClientWithUser for information about callback, client_id, * and general usage for authentication. */ -int RM_AuthenticateClientWithACLUser(RedisModuleCtx *ctx, const char *name, size_t len, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { +int VM_AuthenticateClientWithACLUser(ValkeyModuleCtx *ctx, const char *name, size_t len, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { user *acl_user = ACLGetUserByName(name, len); if (!acl_user) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } return authenticateClientWithUser(ctx, acl_user, callback, privdata, client_id); } @@ -9920,23 +9921,23 @@ int RM_AuthenticateClientWithACLUser(RedisModuleCtx *ctx, const char *name, size /* Deauthenticate and close the client. The client resources will not be * immediately freed, but will be cleaned up in a background job. This is * the recommended way to deauthenticate a client since most clients can't - * handle users becoming deauthenticated. Returns REDISMODULE_ERR when the - * client doesn't exist and REDISMODULE_OK when the operation was successful. + * handle users becoming deauthenticated. Returns VALKEYMODULE_ERR when the + * client doesn't exist and VALKEYMODULE_OK when the operation was successful. * - * The client ID is returned from the RM_AuthenticateClientWithUser and - * RM_AuthenticateClientWithACLUser APIs, but can be obtained through + * The client ID is returned from the VM_AuthenticateClientWithUser and + * VM_AuthenticateClientWithACLUser APIs, but can be obtained through * the CLIENT api or through server events. * * This function is not thread safe, and must be executed within the context * of a command or thread safe context. */ -int RM_DeauthenticateAndCloseClient(RedisModuleCtx *ctx, uint64_t client_id) { +int VM_DeauthenticateAndCloseClient(ValkeyModuleCtx *ctx, uint64_t client_id) { UNUSED(ctx); client *c = lookupClientByID(client_id); - if (c == NULL) return REDISMODULE_ERR; + if (c == NULL) return VALKEYMODULE_ERR; /* Revoke also marks client to be closed ASAP */ revokeClientAuthentication(c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Redact the client command argument specified at the given position. Redacted arguments @@ -9946,21 +9947,21 @@ int RM_DeauthenticateAndCloseClient(RedisModuleCtx *ctx, uint64_t client_id) { * * Note that the command name, position 0, can not be redacted. * - * Returns REDISMODULE_OK if the argument was redacted and REDISMODULE_ERR if there + * Returns VALKEYMODULE_OK if the argument was redacted and VALKEYMODULE_ERR if there * was an invalid parameter passed in or the position is outside the client * argument range. */ -int RM_RedactClientCommandArgument(RedisModuleCtx *ctx, int pos) { +int VM_RedactClientCommandArgument(ValkeyModuleCtx *ctx, int pos) { if (!ctx || !ctx->client || pos <= 0 || ctx->client->argc <= pos) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } redactClientCommandArgument(ctx->client, pos); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return the X.509 client-side certificate used by the client to authenticate * this connection. * - * The return value is an allocated RedisModuleString that is a X.509 certificate + * The return value is an allocated ValkeyModuleString that is a X.509 certificate * encoded in PEM (Base64) format. It should be freed (or auto-freed) by the caller. * * A NULL value is returned in the following conditions: @@ -9969,15 +9970,15 @@ int RM_RedactClientCommandArgument(RedisModuleCtx *ctx, int pos) { * - Connection is not a TLS connection * - Connection is a TLS connection but no client certificate was used */ -RedisModuleString *RM_GetClientCertificate(RedisModuleCtx *ctx, uint64_t client_id) { +ValkeyModuleString *VM_GetClientCertificate(ValkeyModuleCtx *ctx, uint64_t client_id) { client *c = lookupClientByID(client_id); if (c == NULL) return NULL; sds cert = connGetPeerCert(c->conn); if (!cert) return NULL; - RedisModuleString *s = createObject(OBJ_STRING, cert); - if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, s); + ValkeyModuleString *s = createObject(OBJ_STRING, cert); + if (ctx != NULL) autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, s); return s; } @@ -10003,51 +10004,51 @@ RedisModuleString *RM_GetClientCertificate(RedisModuleCtx *ctx, uint64_t client_ * reclaim the dictionary memory, as well as the strings returned by the * Next / Prev dictionary iterator calls. */ -RedisModuleDict *RM_CreateDict(RedisModuleCtx *ctx) { - struct RedisModuleDict *d = zmalloc(sizeof(*d)); +ValkeyModuleDict *VM_CreateDict(ValkeyModuleCtx *ctx) { + struct ValkeyModuleDict *d = zmalloc(sizeof(*d)); d->rax = raxNew(); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_DICT,d); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_DICT,d); return d; } -/* Free a dictionary created with RM_CreateDict(). You need to pass the +/* Free a dictionary created with VM_CreateDict(). You need to pass the * context pointer 'ctx' only if the dictionary was created using the * context instead of passing NULL. */ -void RM_FreeDict(RedisModuleCtx *ctx, RedisModuleDict *d) { - if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_DICT,d); +void VM_FreeDict(ValkeyModuleCtx *ctx, ValkeyModuleDict *d) { + if (ctx != NULL) autoMemoryFreed(ctx,VALKEYMODULE_AM_DICT,d); raxFree(d->rax); zfree(d); } /* Return the size of the dictionary (number of keys). */ -uint64_t RM_DictSize(RedisModuleDict *d) { +uint64_t VM_DictSize(ValkeyModuleDict *d) { return raxSize(d->rax); } /* Store the specified key into the dictionary, setting its value to the * pointer 'ptr'. If the key was added with success, since it did not - * already exist, REDISMODULE_OK is returned. Otherwise if the key already - * exists the function returns REDISMODULE_ERR. */ -int RM_DictSetC(RedisModuleDict *d, void *key, size_t keylen, void *ptr) { + * already exist, VALKEYMODULE_OK is returned. Otherwise if the key already + * exists the function returns VALKEYMODULE_ERR. */ +int VM_DictSetC(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) { int retval = raxTryInsert(d->rax,key,keylen,ptr,NULL); - return (retval == 1) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == 1) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictSetC() but will replace the key with the new +/* Like ValkeyModule_DictSetC() but will replace the key with the new * value if the key already exists. */ -int RM_DictReplaceC(RedisModuleDict *d, void *key, size_t keylen, void *ptr) { +int VM_DictReplaceC(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) { int retval = raxInsert(d->rax,key,keylen,ptr,NULL); - return (retval == 1) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == 1) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictSetC() but takes the key as a RedisModuleString. */ -int RM_DictSet(RedisModuleDict *d, RedisModuleString *key, void *ptr) { - return RM_DictSetC(d,key->ptr,sdslen(key->ptr),ptr); +/* Like ValkeyModule_DictSetC() but takes the key as a ValkeyModuleString. */ +int VM_DictSet(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) { + return VM_DictSetC(d,key->ptr,sdslen(key->ptr),ptr); } -/* Like RedisModule_DictReplaceC() but takes the key as a RedisModuleString. */ -int RM_DictReplace(RedisModuleDict *d, RedisModuleString *key, void *ptr) { - return RM_DictReplaceC(d,key->ptr,sdslen(key->ptr),ptr); +/* Like ValkeyModule_DictReplaceC() but takes the key as a ValkeyModuleString. */ +int VM_DictReplace(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) { + return VM_DictReplaceC(d,key->ptr,sdslen(key->ptr),ptr); } /* Return the value stored at the specified key. The function returns NULL @@ -10055,33 +10056,33 @@ int RM_DictReplace(RedisModuleDict *d, RedisModuleString *key, void *ptr) { * NULL at key. So, optionally, if the 'nokey' pointer is not NULL, it will * be set by reference to 1 if the key does not exist, or to 0 if the key * exists. */ -void *RM_DictGetC(RedisModuleDict *d, void *key, size_t keylen, int *nokey) { +void *VM_DictGetC(ValkeyModuleDict *d, void *key, size_t keylen, int *nokey) { void *res = NULL; int found = raxFind(d->rax,key,keylen,&res); if (nokey) *nokey = !found; return res; } -/* Like RedisModule_DictGetC() but takes the key as a RedisModuleString. */ -void *RM_DictGet(RedisModuleDict *d, RedisModuleString *key, int *nokey) { - return RM_DictGetC(d,key->ptr,sdslen(key->ptr),nokey); +/* Like ValkeyModule_DictGetC() but takes the key as a ValkeyModuleString. */ +void *VM_DictGet(ValkeyModuleDict *d, ValkeyModuleString *key, int *nokey) { + return VM_DictGetC(d,key->ptr,sdslen(key->ptr),nokey); } -/* Remove the specified key from the dictionary, returning REDISMODULE_OK if - * the key was found and deleted, or REDISMODULE_ERR if instead there was +/* Remove the specified key from the dictionary, returning VALKEYMODULE_OK if + * the key was found and deleted, or VALKEYMODULE_ERR if instead there was * no such key in the dictionary. When the operation is successful, if * 'oldval' is not NULL, then '*oldval' is set to the value stored at the * key before it was deleted. Using this feature it is possible to get * a pointer to the value (for instance in order to release it), without - * having to call RedisModule_DictGet() before deleting the key. */ -int RM_DictDelC(RedisModuleDict *d, void *key, size_t keylen, void *oldval) { + * having to call ValkeyModule_DictGet() before deleting the key. */ +int VM_DictDelC(ValkeyModuleDict *d, void *key, size_t keylen, void *oldval) { int retval = raxRemove(d->rax,key,keylen,oldval); - return retval ? REDISMODULE_OK : REDISMODULE_ERR; + return retval ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictDelC() but gets the key as a RedisModuleString. */ -int RM_DictDel(RedisModuleDict *d, RedisModuleString *key, void *oldval) { - return RM_DictDelC(d,key->ptr,sdslen(key->ptr),oldval); +/* Like ValkeyModule_DictDelC() but gets the key as a ValkeyModuleString. */ +int VM_DictDel(ValkeyModuleDict *d, ValkeyModuleString *key, void *oldval) { + return VM_DictDelC(d,key->ptr,sdslen(key->ptr),oldval); } /* Return an iterator, setup in order to start iterating from the specified @@ -10101,45 +10102,45 @@ int RM_DictDel(RedisModuleDict *d, RedisModuleString *key, void *oldval) { * just pass NULL with a length of 0. * * If the element to start the iteration cannot be seeked based on the - * key and operator passed, RedisModule_DictNext() / Prev() will just return - * REDISMODULE_ERR at the first call, otherwise they'll produce elements. + * key and operator passed, ValkeyModule_DictNext() / Prev() will just return + * VALKEYMODULE_ERR at the first call, otherwise they'll produce elements. */ -RedisModuleDictIter *RM_DictIteratorStartC(RedisModuleDict *d, const char *op, void *key, size_t keylen) { - RedisModuleDictIter *di = zmalloc(sizeof(*di)); +ValkeyModuleDictIter *VM_DictIteratorStartC(ValkeyModuleDict *d, const char *op, void *key, size_t keylen) { + ValkeyModuleDictIter *di = zmalloc(sizeof(*di)); di->dict = d; raxStart(&di->ri,d->rax); raxSeek(&di->ri,op,key,keylen); return di; } -/* Exactly like RedisModule_DictIteratorStartC, but the key is passed as a - * RedisModuleString. */ -RedisModuleDictIter *RM_DictIteratorStart(RedisModuleDict *d, const char *op, RedisModuleString *key) { - return RM_DictIteratorStartC(d,op,key->ptr,sdslen(key->ptr)); +/* Exactly like ValkeyModule_DictIteratorStartC, but the key is passed as a + * ValkeyModuleString. */ +ValkeyModuleDictIter *VM_DictIteratorStart(ValkeyModuleDict *d, const char *op, ValkeyModuleString *key) { + return VM_DictIteratorStartC(d,op,key->ptr,sdslen(key->ptr)); } -/* Release the iterator created with RedisModule_DictIteratorStart(). This call +/* Release the iterator created with ValkeyModule_DictIteratorStart(). This call * is mandatory otherwise a memory leak is introduced in the module. */ -void RM_DictIteratorStop(RedisModuleDictIter *di) { +void VM_DictIteratorStop(ValkeyModuleDictIter *di) { raxStop(&di->ri); zfree(di); } -/* After its creation with RedisModule_DictIteratorStart(), it is possible to +/* After its creation with ValkeyModule_DictIteratorStart(), it is possible to * change the currently selected element of the iterator by using this * API call. The result based on the operator and key is exactly like - * the function RedisModule_DictIteratorStart(), however in this case the - * return value is just REDISMODULE_OK in case the seeked element was found, - * or REDISMODULE_ERR in case it was not possible to seek the specified + * the function ValkeyModule_DictIteratorStart(), however in this case the + * return value is just VALKEYMODULE_OK in case the seeked element was found, + * or VALKEYMODULE_ERR in case it was not possible to seek the specified * element. It is possible to reseek an iterator as many times as you want. */ -int RM_DictIteratorReseekC(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) { +int VM_DictIteratorReseekC(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) { return raxSeek(&di->ri,op,key,keylen); } -/* Like RedisModule_DictIteratorReseekC() but takes the key as a - * RedisModuleString. */ -int RM_DictIteratorReseek(RedisModuleDictIter *di, const char *op, RedisModuleString *key) { - return RM_DictIteratorReseekC(di,op,key->ptr,sdslen(key->ptr)); +/* Like ValkeyModule_DictIteratorReseekC() but takes the key as a + * ValkeyModuleString. */ +int VM_DictIteratorReseek(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) { + return VM_DictIteratorReseekC(di,op,key->ptr,sdslen(key->ptr)); } /* Return the current item of the dictionary iterator `di` and steps to the @@ -10148,14 +10149,14 @@ int RM_DictIteratorReseek(RedisModuleDictIter *di, const char *op, RedisModuleSt * to a string representing the key is provided, and the `*keylen` length * is set by reference (if keylen is not NULL). The `*dataptr`, if not NULL * is set to the value of the pointer stored at the returned key as auxiliary - * data (as set by the RedisModule_DictSet API). + * data (as set by the ValkeyModule_DictSet API). * * Usage example: * * ... create the iterator here ... * char *key; * void *data; - * while((key = RedisModule_DictNextC(iter,&keylen,&data)) != NULL) { + * while((key = ValkeyModule_DictNextC(iter,&keylen,&data)) != NULL) { * printf("%.*s %p\n", (int)keylen, key, data); * } * @@ -10167,71 +10168,71 @@ int RM_DictIteratorReseek(RedisModuleDictIter *di, const char *op, RedisModuleSt * The validity of the returned pointer is until the next call to the * next/prev iterator step. Also the pointer is no longer valid once the * iterator is released. */ -void *RM_DictNextC(RedisModuleDictIter *di, size_t *keylen, void **dataptr) { +void *VM_DictNextC(ValkeyModuleDictIter *di, size_t *keylen, void **dataptr) { if (!raxNext(&di->ri)) return NULL; if (keylen) *keylen = di->ri.key_len; if (dataptr) *dataptr = di->ri.data; return di->ri.key; } -/* This function is exactly like RedisModule_DictNext() but after returning +/* This function is exactly like ValkeyModule_DictNext() but after returning * the currently selected element in the iterator, it selects the previous * element (lexicographically smaller) instead of the next one. */ -void *RM_DictPrevC(RedisModuleDictIter *di, size_t *keylen, void **dataptr) { +void *VM_DictPrevC(ValkeyModuleDictIter *di, size_t *keylen, void **dataptr) { if (!raxPrev(&di->ri)) return NULL; if (keylen) *keylen = di->ri.key_len; if (dataptr) *dataptr = di->ri.data; return di->ri.key; } -/* Like RedisModuleNextC(), but instead of returning an internally allocated +/* Like ValkeyModuleNextC(), but instead of returning an internally allocated * buffer and key length, it returns directly a module string object allocated * in the specified context 'ctx' (that may be NULL exactly like for the main - * API RedisModule_CreateString). + * API ValkeyModule_CreateString). * * The returned string object should be deallocated after use, either manually * or by using a context that has automatic memory management active. */ -RedisModuleString *RM_DictNext(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) { +ValkeyModuleString *VM_DictNext(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) { size_t keylen; - void *key = RM_DictNextC(di,&keylen,dataptr); + void *key = VM_DictNextC(di,&keylen,dataptr); if (key == NULL) return NULL; - return RM_CreateString(ctx,key,keylen); + return VM_CreateString(ctx,key,keylen); } -/* Like RedisModule_DictNext() but after returning the currently selected +/* Like ValkeyModule_DictNext() but after returning the currently selected * element in the iterator, it selects the previous element (lexicographically * smaller) instead of the next one. */ -RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) { +ValkeyModuleString *VM_DictPrev(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) { size_t keylen; - void *key = RM_DictPrevC(di,&keylen,dataptr); + void *key = VM_DictPrevC(di,&keylen,dataptr); if (key == NULL) return NULL; - return RM_CreateString(ctx,key,keylen); + return VM_CreateString(ctx,key,keylen); } /* Compare the element currently pointed by the iterator to the specified * element given by key/keylen, according to the operator 'op' (the set of - * valid operators are the same valid for RedisModule_DictIteratorStart). - * If the comparison is successful the command returns REDISMODULE_OK - * otherwise REDISMODULE_ERR is returned. + * valid operators are the same valid for ValkeyModule_DictIteratorStart). + * If the comparison is successful the command returns VALKEYMODULE_OK + * otherwise VALKEYMODULE_ERR is returned. * * This is useful when we want to just emit a lexicographical range, so * in the loop, as we iterate elements, we can also check if we are still * on range. * - * The function return REDISMODULE_ERR if the iterator reached the + * The function return VALKEYMODULE_ERR if the iterator reached the * end of elements condition as well. */ -int RM_DictCompareC(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) { - if (raxEOF(&di->ri)) return REDISMODULE_ERR; +int VM_DictCompareC(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) { + if (raxEOF(&di->ri)) return VALKEYMODULE_ERR; int res = raxCompare(&di->ri,op,key,keylen); - return res ? REDISMODULE_OK : REDISMODULE_ERR; + return res ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictCompareC but gets the key to compare with the current - * iterator key as a RedisModuleString. */ -int RM_DictCompare(RedisModuleDictIter *di, const char *op, RedisModuleString *key) { - if (raxEOF(&di->ri)) return REDISMODULE_ERR; +/* Like ValkeyModule_DictCompareC but gets the key to compare with the current + * iterator key as a ValkeyModuleString. */ +int VM_DictCompare(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) { + if (raxEOF(&di->ri)) return VALKEYMODULE_ERR; int res = raxCompare(&di->ri,op,key->ptr,sdslen(key->ptr)); - return res ? REDISMODULE_OK : REDISMODULE_ERR; + return res ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } @@ -10241,20 +10242,20 @@ int RM_DictCompare(RedisModuleDictIter *di, const char *op, RedisModuleString *k * ## Modules Info fields * -------------------------------------------------------------------------- */ -int RM_InfoEndDictField(RedisModuleInfoCtx *ctx); +int VM_InfoEndDictField(ValkeyModuleInfoCtx *ctx); /* Used to start a new section, before adding any fields. the section name will * be prefixed by `_` and must only include A-Z,a-z,0-9. * NULL or empty string indicates the default section (only ``) is used. - * When return value is REDISMODULE_ERR, the section should and will be skipped. */ -int RM_InfoAddSection(RedisModuleInfoCtx *ctx, const char *name) { + * When return value is VALKEYMODULE_ERR, the section should and will be skipped. */ +int VM_InfoAddSection(ValkeyModuleInfoCtx *ctx, const char *name) { sds full_name = sdsdup(ctx->module->name); if (name != NULL && strlen(name) > 0) full_name = sdscatfmt(full_name, "_%s", name); /* Implicitly end dicts, instead of returning an error which is likely un checked. */ if (ctx->in_dict_field) - RM_InfoEndDictField(ctx); + VM_InfoEndDictField(ctx); /* proceed only if: * 1) no section was requested (emit all) @@ -10266,25 +10267,25 @@ int RM_InfoAddSection(RedisModuleInfoCtx *ctx, const char *name) { { sdsfree(full_name); ctx->in_section = 0; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } if (ctx->sections++) ctx->info = sdscat(ctx->info,"\r\n"); ctx->info = sdscatfmt(ctx->info, "# %S\r\n", full_name); ctx->in_section = 1; sdsfree(full_name); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Starts a dict field, similar to the ones in INFO KEYSPACE. Use normal - * RedisModule_InfoAddField* functions to add the items to this field, and - * terminate with RedisModule_InfoEndDictField. */ -int RM_InfoBeginDictField(RedisModuleInfoCtx *ctx, const char *name) { + * ValkeyModule_InfoAddField* functions to add the items to this field, and + * terminate with ValkeyModule_InfoEndDictField. */ +int VM_InfoBeginDictField(ValkeyModuleInfoCtx *ctx, const char *name) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Implicitly end dicts, instead of returning an error which is likely un checked. */ if (ctx->in_dict_field) - RM_InfoEndDictField(ctx); + VM_InfoEndDictField(ctx); char *tmpmodname, *tmpname; ctx->info = sdscatfmt(ctx->info, "%s_%s:", @@ -10293,123 +10294,123 @@ int RM_InfoBeginDictField(RedisModuleInfoCtx *ctx, const char *name) { if (tmpmodname != NULL) zfree(tmpmodname); if (tmpname != NULL) zfree(tmpname); ctx->in_dict_field = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Ends a dict field, see RedisModule_InfoBeginDictField */ -int RM_InfoEndDictField(RedisModuleInfoCtx *ctx) { +/* Ends a dict field, see ValkeyModule_InfoBeginDictField */ +int VM_InfoEndDictField(ValkeyModuleInfoCtx *ctx) { if (!ctx->in_dict_field) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* trim the last ',' if found. */ if (ctx->info[sdslen(ctx->info)-1]==',') sdsIncrLen(ctx->info, -1); ctx->info = sdscat(ctx->info, "\r\n"); ctx->in_dict_field = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Used by RedisModuleInfoFunc to add info fields. +/* Used by ValkeyModuleInfoFunc to add info fields. * Each field will be automatically prefixed by `_`. * Field names or values must not include `\r\n` or `:`. */ -int RM_InfoAddFieldString(RedisModuleInfoCtx *ctx, const char *field, RedisModuleString *value) { +int VM_InfoAddFieldString(ValkeyModuleInfoCtx *ctx, const char *field, ValkeyModuleString *value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%S,", field, (sds)value->ptr); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%S\r\n", ctx->module->name, field, (sds)value->ptr); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldCString(RedisModuleInfoCtx *ctx, const char *field, const char *value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldCString(ValkeyModuleInfoCtx *ctx, const char *field, const char *value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%s,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%s\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldDouble(RedisModuleInfoCtx *ctx, const char *field, double value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldDouble(ValkeyModuleInfoCtx *ctx, const char *field, double value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatprintf(ctx->info, "%s=%.17g,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatprintf(ctx->info, "%s_%s:%.17g\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldLongLong(RedisModuleInfoCtx *ctx, const char *field, long long value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldLongLong(ValkeyModuleInfoCtx *ctx, const char *field, long long value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%I,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%I\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldULongLong(RedisModuleInfoCtx *ctx, const char *field, unsigned long long value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldULongLong(ValkeyModuleInfoCtx *ctx, const char *field, unsigned long long value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%U,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%U\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Registers callback for the INFO command. The callback should add INFO fields - * by calling the `RedisModule_InfoAddField*()` functions. */ -int RM_RegisterInfoFunc(RedisModuleCtx *ctx, RedisModuleInfoFunc cb) { + * by calling the `ValkeyModule_InfoAddField*()` functions. */ +int VM_RegisterInfoFunc(ValkeyModuleCtx *ctx, ValkeyModuleInfoFunc cb) { ctx->module->info_cb = cb; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } sds modulesCollectInfo(sds info, dict *sections_dict, int for_crash_report, int sections) { @@ -10417,14 +10418,14 @@ sds modulesCollectInfo(sds info, dict *sections_dict, int for_crash_report, int dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); if (!module->info_cb) continue; - RedisModuleInfoCtx info_ctx = {module, sections_dict, info, sections, 0, 0}; + ValkeyModuleInfoCtx info_ctx = {module, sections_dict, info, sections, 0, 0}; module->info_cb(&info_ctx, for_crash_report); /* Implicitly end dicts (no way to handle errors, and we must add the newline). */ if (info_ctx.in_dict_field) - RM_InfoEndDictField(&info_ctx); + VM_InfoEndDictField(&info_ctx); info = info_ctx.info; sections = info_ctx.sections; } @@ -10435,13 +10436,13 @@ sds modulesCollectInfo(sds info, dict *sections_dict, int for_crash_report, int /* Get information about the server similar to the one that returns from the * INFO command. This function takes an optional 'section' argument that may * be NULL. The return value holds the output and can be used with - * RedisModule_ServerInfoGetField and alike to get the individual fields. - * When done, it needs to be freed with RedisModule_FreeServerInfo or with the + * ValkeyModule_ServerInfoGetField and alike to get the individual fields. + * When done, it needs to be freed with ValkeyModule_FreeServerInfo or with the * automatic memory management mechanism if enabled. */ -RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *section) { - struct RedisModuleServerInfoData *d = zmalloc(sizeof(*d)); +ValkeyModuleServerInfoData *VM_GetServerInfo(ValkeyModuleCtx *ctx, const char *section) { + struct ValkeyModuleServerInfoData *d = zmalloc(sizeof(*d)); d->rax = raxNew(); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_INFO,d); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_INFO,d); int all = 0, everything = 0; robj *argv[1]; argv[0] = section ? createStringObject(section, strlen(section)) : NULL; @@ -10467,90 +10468,90 @@ RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *sec return d; } -/* Free data created with RM_GetServerInfo(). You need to pass the +/* Free data created with VM_GetServerInfo(). You need to pass the * context pointer 'ctx' only if the dictionary was created using the * context instead of passing NULL. */ -void RM_FreeServerInfo(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) { - if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_INFO,data); +void VM_FreeServerInfo(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data) { + if (ctx != NULL) autoMemoryFreed(ctx,VALKEYMODULE_AM_INFO,data); raxFreeWithCallback(data->rax, (void(*)(void*))sdsfree); zfree(data); } -/* Get the value of a field from data collected with RM_GetServerInfo(). You +/* Get the value of a field from data collected with VM_GetServerInfo(). You * need to pass the context pointer 'ctx' only if you want to use auto memory * mechanism to release the returned string. Return value will be NULL if the * field was not found. */ -RedisModuleString *RM_ServerInfoGetField(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field) { +ValkeyModuleString *VM_ServerInfoGetField(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data, const char* field) { void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) return NULL; sds val = result; - RedisModuleString *o = createStringObject(val,sdslen(val)); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); + ValkeyModuleString *o = createStringObject(val,sdslen(val)); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,o); return o; } -/* Similar to RM_ServerInfoGetField, but returns a char* which should not be freed but the caller. */ -const char *RM_ServerInfoGetFieldC(RedisModuleServerInfoData *data, const char* field) { +/* Similar to VM_ServerInfoGetField, but returns a char* which should not be freed but the caller. */ +const char *VM_ServerInfoGetFieldC(ValkeyModuleServerInfoData *data, const char* field) { void *result = NULL; raxFind(data->rax, (unsigned char *)field, strlen(field), &result); return result; } -/* Get the value of a field from data collected with RM_GetServerInfo(). If the +/* Get the value of a field from data collected with VM_GetServerInfo(). If the * field is not found, or is not numerical or out of range, return value will be - * 0, and the optional out_err argument will be set to REDISMODULE_ERR. */ -long long RM_ServerInfoGetFieldSigned(RedisModuleServerInfoData *data, const char* field, int *out_err) { + * 0, and the optional out_err argument will be set to VALKEYMODULE_ERR. */ +long long VM_ServerInfoGetFieldSigned(ValkeyModuleServerInfoData *data, const char* field, int *out_err) { long long ll; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } sds val = result; if (!string2ll(val,sdslen(val),&ll)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } - if (out_err) *out_err = REDISMODULE_OK; + if (out_err) *out_err = VALKEYMODULE_OK; return ll; } -/* Get the value of a field from data collected with RM_GetServerInfo(). If the +/* Get the value of a field from data collected with VM_GetServerInfo(). If the * field is not found, or is not numerical or out of range, return value will be - * 0, and the optional out_err argument will be set to REDISMODULE_ERR. */ -unsigned long long RM_ServerInfoGetFieldUnsigned(RedisModuleServerInfoData *data, const char* field, int *out_err) { + * 0, and the optional out_err argument will be set to VALKEYMODULE_ERR. */ +unsigned long long VM_ServerInfoGetFieldUnsigned(ValkeyModuleServerInfoData *data, const char* field, int *out_err) { unsigned long long ll; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } sds val = result; if (!string2ull(val,&ll)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } - if (out_err) *out_err = REDISMODULE_OK; + if (out_err) *out_err = VALKEYMODULE_OK; return ll; } -/* Get the value of a field from data collected with RM_GetServerInfo(). If the +/* Get the value of a field from data collected with VM_GetServerInfo(). If the * field is not found, or is not a double, return value will be 0, and the - * optional out_err argument will be set to REDISMODULE_ERR. */ -double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* field, int *out_err) { + * optional out_err argument will be set to VALKEYMODULE_ERR. */ +double VM_ServerInfoGetFieldDouble(ValkeyModuleServerInfoData *data, const char* field, int *out_err) { double dbl; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } sds val = result; if (!string2d(val,sdslen(val),&dbl)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } - if (out_err) *out_err = REDISMODULE_OK; + if (out_err) *out_err = VALKEYMODULE_OK; return dbl; } @@ -10562,14 +10563,14 @@ double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* * initialized seed. This function is fast so can be used to generate * many bytes without any effect on the operating system entropy pool. * Currently this function is not thread safe. */ -void RM_GetRandomBytes(unsigned char *dst, size_t len) { +void VM_GetRandomBytes(unsigned char *dst, size_t len) { getRandomBytes(dst,len); } -/* Like RedisModule_GetRandomBytes() but instead of setting the string to +/* Like ValkeyModule_GetRandomBytes() but instead of setting the string to * random bytes the string is set to random characters in the in the * hex charset [0-9a-f]. */ -void RM_GetRandomHexChars(char *dst, size_t len) { +void VM_GetRandomHexChars(char *dst, size_t len) { getRandomHexChars(dst,len); } @@ -10579,25 +10580,25 @@ void RM_GetRandomHexChars(char *dst, size_t len) { /* This function is called by a module in order to export some API with a * given name. Other modules will be able to use this API by calling the - * symmetrical function RM_GetSharedAPI() and casting the return value to + * symmetrical function VM_GetSharedAPI() and casting the return value to * the right function pointer. * - * The function will return REDISMODULE_OK if the name is not already taken, - * otherwise REDISMODULE_ERR will be returned and no operation will be + * The function will return VALKEYMODULE_OK if the name is not already taken, + * otherwise VALKEYMODULE_ERR will be returned and no operation will be * performed. * * IMPORTANT: the apiname argument should be a string literal with static * lifetime. The API relies on the fact that it will always be valid in * the future. */ -int RM_ExportSharedAPI(RedisModuleCtx *ctx, const char *apiname, void *func) { - RedisModuleSharedAPI *sapi = zmalloc(sizeof(*sapi)); +int VM_ExportSharedAPI(ValkeyModuleCtx *ctx, const char *apiname, void *func) { + ValkeyModuleSharedAPI *sapi = zmalloc(sizeof(*sapi)); sapi->module = ctx->module; sapi->func = func; if (dictAdd(server.sharedapi, (char*)apiname, sapi) != DICT_OK) { zfree(sapi); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Request an exported API pointer. The return value is just a void pointer @@ -10627,16 +10628,16 @@ int RM_ExportSharedAPI(RedisModuleCtx *ctx, const char *apiname, void *func) { * static int api_loaded = 0; * if (api_loaded != 0) return 1; // APIs already resolved. * - * myFunctionPointer = RedisModule_GetSharedAPI("..."); + * myFunctionPointer = ValkeyModule_GetSharedAPI("..."); * if (myFunctionPointer == NULL) return 0; * * return 1; * } */ -void *RM_GetSharedAPI(RedisModuleCtx *ctx, const char *apiname) { +void *VM_GetSharedAPI(ValkeyModuleCtx *ctx, const char *apiname) { dictEntry *de = dictFind(server.sharedapi, apiname); if (de == NULL) return NULL; - RedisModuleSharedAPI *sapi = dictGetVal(de); + ValkeyModuleSharedAPI *sapi = dictGetVal(de); if (listSearchKey(sapi->module->usedby,ctx->module) == NULL) { listAddNodeTail(sapi->module->usedby,ctx->module); listAddNodeTail(ctx->module->using,sapi->module); @@ -10650,13 +10651,13 @@ void *RM_GetSharedAPI(RedisModuleCtx *ctx, const char *apiname) { * used by other modules. * * The number of unregistered APIs is returned. */ -int moduleUnregisterSharedAPI(RedisModule *module) { +int moduleUnregisterSharedAPI(ValkeyModule *module) { int count = 0; dictIterator *di = dictGetSafeIterator(server.sharedapi); dictEntry *de; while ((de = dictNext(di)) != NULL) { const char *apiname = dictGetKey(de); - RedisModuleSharedAPI *sapi = dictGetVal(de); + ValkeyModuleSharedAPI *sapi = dictGetVal(de); if (sapi->module == module) { dictDelete(server.sharedapi,apiname); zfree(sapi); @@ -10671,14 +10672,14 @@ int moduleUnregisterSharedAPI(RedisModule *module) { * This is usually called when a module is unloaded. * * Returns the number of modules this module was using APIs from. */ -int moduleUnregisterUsedAPI(RedisModule *module) { +int moduleUnregisterUsedAPI(ValkeyModule *module) { listIter li; listNode *ln; int count = 0; listRewind(module->using,&li); while((ln = listNext(&li))) { - RedisModule *used = ln->value; + ValkeyModule *used = ln->value; listNode *ln = listSearchKey(used->usedby,module); if (ln) { listDelNode(used->usedby,ln); @@ -10692,14 +10693,14 @@ int moduleUnregisterUsedAPI(RedisModule *module) { * This is called when a module is being unloaded. * * Returns the number of filters unregistered. */ -int moduleUnregisterFilters(RedisModule *module) { +int moduleUnregisterFilters(ValkeyModule *module) { listIter li; listNode *ln; int count = 0; listRewind(module->filters,&li); while((ln = listNext(&li))) { - RedisModuleCommandFilter *filter = ln->value; + ValkeyModuleCommandFilter *filter = ln->value; listNode *ln = listSearchKey(moduleCommandFilters,filter); if (ln) { listDelNode(moduleCommandFilters,ln); @@ -10724,18 +10725,18 @@ int moduleUnregisterFilters(RedisModule *module) { * filter applies in all execution paths including: * * 1. Invocation by a client. - * 2. Invocation through `RedisModule_Call()` by any module. + * 2. Invocation through `ValkeyModule_Call()` by any module. * 3. Invocation through Lua `redis.call()`. * 4. Replication of a command from a master. * * The filter executes in a special filter context, which is different and more - * limited than a RedisModuleCtx. Because the filter affects any command, it + * limited than a ValkeyModuleCtx. Because the filter affects any command, it * must be implemented in a very efficient way to reduce the performance impact * on Redis. All Redis Module API calls that require a valid context (such as - * `RedisModule_Call()`, `RedisModule_OpenKey()`, etc.) are not supported in a + * `ValkeyModule_Call()`, `ValkeyModule_OpenKey()`, etc.) are not supported in a * filter context. * - * The `RedisModuleCommandFilterCtx` can be used to inspect or modify the + * The `ValkeyModuleCommandFilterCtx` can be used to inspect or modify the * executed command and its arguments. As the filter executes before Redis * begins processing the command, any change will affect the way the command is * processed. For example, a module can override Redis commands this way: @@ -10749,12 +10750,12 @@ int moduleUnregisterFilters(RedisModule *module) { * and therefore executes the module's own command. * * Note that in the above use case, if `MODULE.SET` itself uses - * `RedisModule_Call()` the filter will be applied on that call as well. If - * that is not desired, the `REDISMODULE_CMDFILTER_NOSELF` flag can be set when + * `ValkeyModule_Call()` the filter will be applied on that call as well. If + * that is not desired, the `VALKEYMODULE_CMDFILTER_NOSELF` flag can be set when * registering the filter. * - * The `REDISMODULE_CMDFILTER_NOSELF` flag prevents execution flows that - * originate from the module's own `RM_Call()` from reaching the filter. This + * The `VALKEYMODULE_CMDFILTER_NOSELF` flag prevents execution flows that + * originate from the module's own `VM_Call()` from reaching the filter. This * flag is effective for all execution flows, including nested ones, as long as * the execution begins from the module's command context or a thread-safe * context that is associated with a blocking command. @@ -10765,8 +10766,8 @@ int moduleUnregisterFilters(RedisModule *module) { * If multiple filters are registered (by the same or different modules), they * are executed in the order of registration. */ -RedisModuleCommandFilter *RM_RegisterCommandFilter(RedisModuleCtx *ctx, RedisModuleCommandFilterFunc callback, int flags) { - RedisModuleCommandFilter *filter = zmalloc(sizeof(*filter)); +ValkeyModuleCommandFilter *VM_RegisterCommandFilter(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilterFunc callback, int flags) { + ValkeyModuleCommandFilter *filter = zmalloc(sizeof(*filter)); filter->module = ctx->module; filter->callback = callback; filter->flags = flags; @@ -10778,23 +10779,23 @@ RedisModuleCommandFilter *RM_RegisterCommandFilter(RedisModuleCtx *ctx, RedisMod /* Unregister a command filter. */ -int RM_UnregisterCommandFilter(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter) { +int VM_UnregisterCommandFilter(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilter *filter) { listNode *ln; /* A module can only remove its own filters */ - if (filter->module != ctx->module) return REDISMODULE_ERR; + if (filter->module != ctx->module) return VALKEYMODULE_ERR; ln = listSearchKey(moduleCommandFilters,filter); - if (!ln) return REDISMODULE_ERR; + if (!ln) return VALKEYMODULE_ERR; listDelNode(moduleCommandFilters,ln); ln = listSearchKey(ctx->module->filters,filter); - if (!ln) return REDISMODULE_ERR; /* Shouldn't happen */ + if (!ln) return VALKEYMODULE_ERR; /* Shouldn't happen */ listDelNode(ctx->module->filters,ln); zfree(filter); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void moduleCallCommandFilters(client *c) { @@ -10804,7 +10805,7 @@ void moduleCallCommandFilters(client *c) { listNode *ln; listRewind(moduleCommandFilters,&li); - RedisModuleCommandFilterCtx filter = { + ValkeyModuleCommandFilterCtx filter = { .argv = c->argv, .argv_len = c->argv_len, .argc = c->argc, @@ -10812,12 +10813,12 @@ void moduleCallCommandFilters(client *c) { }; while((ln = listNext(&li))) { - RedisModuleCommandFilter *f = ln->value; + ValkeyModuleCommandFilter *f = ln->value; - /* Skip filter if REDISMODULE_CMDFILTER_NOSELF is set and module is + /* Skip filter if VALKEYMODULE_CMDFILTER_NOSELF is set and module is * currently processing a command. */ - if ((f->flags & REDISMODULE_CMDFILTER_NOSELF) && f->module->in_call) continue; + if ((f->flags & VALKEYMODULE_CMDFILTER_NOSELF) && f->module->in_call) continue; /* Call filter */ f->callback(&filter); @@ -10831,7 +10832,7 @@ void moduleCallCommandFilters(client *c) { /* Return the number of arguments a filtered command has. The number of * arguments include the command itself. */ -int RM_CommandFilterArgsCount(RedisModuleCommandFilterCtx *fctx) +int VM_CommandFilterArgsCount(ValkeyModuleCommandFilterCtx *fctx) { return fctx->argc; } @@ -10839,26 +10840,26 @@ int RM_CommandFilterArgsCount(RedisModuleCommandFilterCtx *fctx) /* Return the specified command argument. The first argument (position 0) is * the command itself, and the rest are user-provided args. */ -RedisModuleString *RM_CommandFilterArgGet(RedisModuleCommandFilterCtx *fctx, int pos) +ValkeyModuleString *VM_CommandFilterArgGet(ValkeyModuleCommandFilterCtx *fctx, int pos) { if (pos < 0 || pos >= fctx->argc) return NULL; return fctx->argv[pos]; } /* Modify the filtered command by inserting a new argument at the specified - * position. The specified RedisModuleString argument may be used by Redis + * position. The specified ValkeyModuleString argument may be used by Redis * after the filter context is destroyed, so it must not be auto-memory * allocated, freed or used elsewhere. */ -int RM_CommandFilterArgInsert(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) +int VM_CommandFilterArgInsert(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) { int i; - if (pos < 0 || pos > fctx->argc) return REDISMODULE_ERR; + if (pos < 0 || pos > fctx->argc) return VALKEYMODULE_ERR; if (fctx->argv_len < fctx->argc+1) { fctx->argv_len = fctx->argc+1; - fctx->argv = zrealloc(fctx->argv, fctx->argv_len*sizeof(RedisModuleString *)); + fctx->argv = zrealloc(fctx->argv, fctx->argv_len*sizeof(ValkeyModuleString *)); } for (i = fctx->argc; i > pos; i--) { fctx->argv[i] = fctx->argv[i-1]; @@ -10866,31 +10867,31 @@ int RM_CommandFilterArgInsert(RedisModuleCommandFilterCtx *fctx, int pos, RedisM fctx->argv[pos] = arg; fctx->argc++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Modify the filtered command by replacing an existing argument with a new one. - * The specified RedisModuleString argument may be used by Redis after the + * The specified ValkeyModuleString argument may be used by Redis after the * filter context is destroyed, so it must not be auto-memory allocated, freed * or used elsewhere. */ -int RM_CommandFilterArgReplace(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) +int VM_CommandFilterArgReplace(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) { - if (pos < 0 || pos >= fctx->argc) return REDISMODULE_ERR; + if (pos < 0 || pos >= fctx->argc) return VALKEYMODULE_ERR; decrRefCount(fctx->argv[pos]); fctx->argv[pos] = arg; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Modify the filtered command by deleting an argument at the specified * position. */ -int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos) +int VM_CommandFilterArgDelete(ValkeyModuleCommandFilterCtx *fctx, int pos) { int i; - if (pos < 0 || pos >= fctx->argc) return REDISMODULE_ERR; + if (pos < 0 || pos >= fctx->argc) return VALKEYMODULE_ERR; decrRefCount(fctx->argv[pos]); for (i = pos; i < fctx->argc-1; i++) { @@ -10898,46 +10899,46 @@ int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos) } fctx->argc--; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Get Client ID for client that issued the command we are filtering */ -unsigned long long RM_CommandFilterGetClientId(RedisModuleCommandFilterCtx *fctx) { +unsigned long long VM_CommandFilterGetClientId(ValkeyModuleCommandFilterCtx *fctx) { return fctx->c->id; } -/* For a given pointer allocated via RedisModule_Alloc() or - * RedisModule_Realloc(), return the amount of memory allocated for it. +/* For a given pointer allocated via ValkeyModule_Alloc() or + * ValkeyModule_Realloc(), return the amount of memory allocated for it. * Note that this may be different (larger) than the memory we allocated * with the allocation calls, since sometimes the underlying allocator * will allocate more memory. */ -size_t RM_MallocSize(void* ptr) { +size_t VM_MallocSize(void* ptr) { return zmalloc_size(ptr); } -/* Similar to RM_MallocSize, the difference is that RM_MallocUsableSize +/* Similar to VM_MallocSize, the difference is that VM_MallocUsableSize * returns the usable size of memory by the module. */ -size_t RM_MallocUsableSize(void *ptr) { +size_t VM_MallocUsableSize(void *ptr) { /* It is safe to use 'zmalloc_usable_size()' to manipulate additional * memory space, as we guarantee that the compiler can recognize this - * after 'RM_Alloc', 'RM_TryAlloc', 'RM_Realloc', or 'RM_Calloc'. */ + * after 'VM_Alloc', 'VM_TryAlloc', 'VM_Realloc', or 'VM_Calloc'. */ return zmalloc_usable_size(ptr); } -/* Same as RM_MallocSize, except it works on RedisModuleString pointers. +/* Same as VM_MallocSize, except it works on ValkeyModuleString pointers. */ -size_t RM_MallocSizeString(RedisModuleString* str) { +size_t VM_MallocSizeString(ValkeyModuleString* str) { serverAssert(str->type == OBJ_STRING); return sizeof(*str) + getStringObjectSdsUsedMemory(str); } -/* Same as RM_MallocSize, except it works on RedisModuleDict pointers. +/* Same as VM_MallocSize, except it works on ValkeyModuleDict pointers. * Note that the returned value is only the overhead of the underlying structures, * it does not include the allocation size of the keys and values. */ -size_t RM_MallocSizeDict(RedisModuleDict* dict) { - size_t size = sizeof(RedisModuleDict) + sizeof(rax); +size_t VM_MallocSizeDict(ValkeyModuleDict* dict) { + size_t size = sizeof(ValkeyModuleDict) + sizeof(rax); size += dict->rax->numnodes * sizeof(raxNode); /* For more info about this weird line, see streamRadixTreeMemoryUsage */ size += dict->rax->numnodes * sizeof(long)*30; @@ -10952,7 +10953,7 @@ size_t RM_MallocSizeDict(RedisModuleDict* dict) { * * Exactly 1 - Memory limit reached. * * Greater 1 - More memory used than the configured limit. */ -float RM_GetUsedMemoryRatio(void){ +float VM_GetUsedMemoryRatio(void){ float level; getMaxmemoryState(NULL, NULL, NULL, &level); return level; @@ -10962,27 +10963,27 @@ float RM_GetUsedMemoryRatio(void){ * ## Scanning keyspace and hashes * -------------------------------------------------------------------------- */ -typedef void (*RedisModuleScanCB)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata); +typedef void (*ValkeyModuleScanCB)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, ValkeyModuleKey *key, void *privdata); typedef struct { - RedisModuleCtx *ctx; + ValkeyModuleCtx *ctx; void* user_data; - RedisModuleScanCB fn; + ValkeyModuleScanCB fn; } ScanCBData; -typedef struct RedisModuleScanCursor{ +typedef struct ValkeyModuleScanCursor{ unsigned long long cursor; int done; -}RedisModuleScanCursor; +}ValkeyModuleScanCursor; static void moduleScanCallback(void *privdata, const dictEntry *de) { ScanCBData *data = privdata; sds key = dictGetKey(de); robj* val = dictGetVal(de); - RedisModuleString *keyname = createObject(OBJ_STRING,sdsdup(key)); + ValkeyModuleString *keyname = createObject(OBJ_STRING,sdsdup(key)); /* Setup the key handle. */ - RedisModuleKey kp = {0}; - moduleInitKey(&kp, data->ctx, keyname, val, REDISMODULE_READ); + ValkeyModuleKey kp = {0}; + moduleInitKey(&kp, data->ctx, keyname, val, VALKEYMODULE_READ); data->fn(data->ctx, keyname, &kp, data->user_data); @@ -10990,22 +10991,22 @@ static void moduleScanCallback(void *privdata, const dictEntry *de) { decrRefCount(keyname); } -/* Create a new cursor to be used with RedisModule_Scan */ -RedisModuleScanCursor *RM_ScanCursorCreate(void) { - RedisModuleScanCursor* cursor = zmalloc(sizeof(*cursor)); +/* Create a new cursor to be used with ValkeyModule_Scan */ +ValkeyModuleScanCursor *VM_ScanCursorCreate(void) { + ValkeyModuleScanCursor* cursor = zmalloc(sizeof(*cursor)); cursor->cursor = 0; cursor->done = 0; return cursor; } /* Restart an existing cursor. The keys will be rescanned. */ -void RM_ScanCursorRestart(RedisModuleScanCursor *cursor) { +void VM_ScanCursorRestart(ValkeyModuleScanCursor *cursor) { cursor->cursor = 0; cursor->done = 0; } /* Destroy the cursor struct. */ -void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { +void VM_ScanCursorDestroy(ValkeyModuleScanCursor *cursor) { zfree(cursor); } @@ -11014,41 +11015,41 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { * * Callback for scan implementation. * - * void scan_callback(RedisModuleCtx *ctx, RedisModuleString *keyname, - * RedisModuleKey *key, void *privdata); + * void scan_callback(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, + * ValkeyModuleKey *key, void *privdata); * * - `ctx`: the redis module context provided to for the scan. * - `keyname`: owned by the caller and need to be retained if used after this * function. * - `key`: holds info on the key and value, it is provided as best effort, in * some cases it might be NULL, in which case the user should (can) use - * RedisModule_OpenKey() (and CloseKey too). + * ValkeyModule_OpenKey() (and CloseKey too). * when it is provided, it is owned by the caller and will be free when the * callback returns. - * - `privdata`: the user data provided to RedisModule_Scan(). + * - `privdata`: the user data provided to ValkeyModule_Scan(). * * The way it should be used: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * while(RedisModule_Scan(ctx, c, callback, privateData)); - * RedisModule_ScanCursorDestroy(c); + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * while(ValkeyModule_Scan(ctx, c, callback, privateData)); + * ValkeyModule_ScanCursorDestroy(c); * * It is also possible to use this API from another thread while the lock - * is acquired during the actual call to RM_Scan: + * is acquired during the actual call to VM_Scan: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModule_ThreadSafeContextLock(ctx); - * while(RedisModule_Scan(ctx, c, callback, privateData)){ - * RedisModule_ThreadSafeContextUnlock(ctx); + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * ValkeyModule_ThreadSafeContextLock(ctx); + * while(ValkeyModule_Scan(ctx, c, callback, privateData)){ + * ValkeyModule_ThreadSafeContextUnlock(ctx); * // do some background job - * RedisModule_ThreadSafeContextLock(ctx); + * ValkeyModule_ThreadSafeContextLock(ctx); * } - * RedisModule_ScanCursorDestroy(c); + * ValkeyModule_ScanCursorDestroy(c); * * The function will return 1 if there are more elements to scan and * 0 otherwise, possibly setting errno if the call failed. * - * It is also possible to restart an existing cursor using RM_ScanCursorRestart. + * It is also possible to restart an existing cursor using VM_ScanCursorRestart. * * IMPORTANT: This API is very similar to the Redis SCAN command from the * point of view of the guarantees it provides. This means that the API @@ -11065,7 +11066,7 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { * later when the iteration is complete. However this can cost a lot of * memory, so it may make sense to just operate on the current key when * possible during the iteration, given that this is safe. */ -int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) { +int VM_Scan(ValkeyModuleCtx *ctx, ValkeyModuleScanCursor *cursor, ValkeyModuleScanCB fn, void *privdata) { if (cursor->done) { errno = ENOENT; return 0; @@ -11081,11 +11082,11 @@ int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanC return ret; } -typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata); +typedef void (*ValkeyModuleScanKeyCB)(ValkeyModuleKey *key, ValkeyModuleString *field, ValkeyModuleString *value, void *privdata); typedef struct { - RedisModuleKey *key; + ValkeyModuleKey *key; void* user_data; - RedisModuleScanKeyCB fn; + ValkeyModuleScanKeyCB fn; } ScanKeyCBData; static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { @@ -11113,42 +11114,42 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { * * Callback for scan implementation. * - * void scan_callback(RedisModuleKey *key, RedisModuleString* field, RedisModuleString* value, void *privdata); + * void scan_callback(ValkeyModuleKey *key, ValkeyModuleString* field, ValkeyModuleString* value, void *privdata); * * - key - the redis key context provided to for the scan. * - field - field name, owned by the caller and need to be retained if used * after this function. * - value - value string or NULL for set type, owned by the caller and need to * be retained if used after this function. - * - privdata - the user data provided to RedisModule_ScanKey. + * - privdata - the user data provided to ValkeyModule_ScanKey. * * The way it should be used: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModuleKey *key = RedisModule_OpenKey(...) - * while(RedisModule_ScanKey(key, c, callback, privateData)); - * RedisModule_CloseKey(key); - * RedisModule_ScanCursorDestroy(c); + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * ValkeyModuleKey *key = ValkeyModule_OpenKey(...) + * while(ValkeyModule_ScanKey(key, c, callback, privateData)); + * ValkeyModule_CloseKey(key); + * ValkeyModule_ScanCursorDestroy(c); * * It is also possible to use this API from another thread while the lock is acquired during - * the actual call to RM_ScanKey, and re-opening the key each time: - * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModule_ThreadSafeContextLock(ctx); - * RedisModuleKey *key = RedisModule_OpenKey(...) - * while(RedisModule_ScanKey(ctx, c, callback, privateData)){ - * RedisModule_CloseKey(key); - * RedisModule_ThreadSafeContextUnlock(ctx); + * the actual call to VM_ScanKey, and re-opening the key each time: + * + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * ValkeyModule_ThreadSafeContextLock(ctx); + * ValkeyModuleKey *key = ValkeyModule_OpenKey(...) + * while(ValkeyModule_ScanKey(ctx, c, callback, privateData)){ + * ValkeyModule_CloseKey(key); + * ValkeyModule_ThreadSafeContextUnlock(ctx); * // do some background job - * RedisModule_ThreadSafeContextLock(ctx); - * RedisModuleKey *key = RedisModule_OpenKey(...) + * ValkeyModule_ThreadSafeContextLock(ctx); + * ValkeyModuleKey *key = ValkeyModule_OpenKey(...) * } - * RedisModule_CloseKey(key); - * RedisModule_ScanCursorDestroy(c); + * ValkeyModule_CloseKey(key); + * ValkeyModule_ScanCursorDestroy(c); * * The function will return 1 if there are more elements to scan and 0 otherwise, * possibly setting errno if the call failed. - * It is also possible to restart an existing cursor using RM_ScanCursorRestart. + * It is also possible to restart an existing cursor using VM_ScanCursorRestart. * * NOTE: Certain operations are unsafe while iterating the object. For instance * while the API guarantees to return at least one time all the elements that @@ -11157,7 +11158,7 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { * you play with the elements, the more duplicates you may get. In general * deleting the current element of the data structure is safe, while removing * the key you are iterating is not safe. */ -int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleScanKeyCB fn, void *privdata) { +int VM_ScanKey(ValkeyModuleKey *key, ValkeyModuleScanCursor *cursor, ValkeyModuleScanKeyCB fn, void *privdata) { if (key == NULL || key->value == NULL) { errno = EINVAL; return 0; @@ -11238,14 +11239,14 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc * main process where you can do some processing in the background without * affecting / freezing the traffic and no need for threads and GIL locking. * Note that Redis allows for only one concurrent fork. - * When the child wants to exit, it should call RedisModule_ExitFromChild. - * If the parent wants to kill the child it should call RedisModule_KillForkChild + * When the child wants to exit, it should call ValkeyModule_ExitFromChild. + * If the parent wants to kill the child it should call ValkeyModule_KillForkChild * The done handler callback will be executed on the parent process when the * child existed (but not when killed) * Return: -1 on failure, on success the parent process will get a positive PID * of the child, and the child process will get 0. */ -int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { +int VM_Fork(ValkeyModuleForkDoneHandler cb, void *user_data) { pid_t childpid; if ((childpid = serverFork(CHILD_TYPE_MODULE)) == 0) { @@ -11266,17 +11267,17 @@ int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { * so that it can report progress and COW memory to the parent which will be * reported in INFO. * The `progress` argument should between 0 and 1, or -1 when not available. */ -void RM_SendChildHeartbeat(double progress) { +void VM_SendChildHeartbeat(double progress) { sendChildInfoGeneric(CHILD_INFO_TYPE_CURRENT_INFO, 0, progress, "Module fork"); } /* Call from the child process when you want to terminate it. * retcode will be provided to the done handler executed on the parent process. */ -int RM_ExitFromChild(int retcode) { +int VM_ExitFromChild(int retcode) { sendChildCowInfo(CHILD_INFO_TYPE_MODULE_COW_SIZE, "Module fork"); exitFromChild(retcode); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Kill the active module forked child, if there is one active and the @@ -11302,13 +11303,13 @@ int TerminateModuleForkChild(int child_pid, int wait) { } /* Can be used to kill the forked child process from the parent process. - * child_pid would be the return value of RedisModule_Fork. */ -int RM_KillForkChild(int child_pid) { + * child_pid would be the return value of ValkeyModule_Fork. */ +int VM_KillForkChild(int child_pid) { /* Kill module child, wait for child exit. */ if (TerminateModuleForkChild(child_pid,1) == C_OK) - return REDISMODULE_OK; + return VALKEYMODULE_OK; else - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } void ModuleForkDoneHandler(int exitcode, int bysignal) { @@ -11328,29 +11329,29 @@ void ModuleForkDoneHandler(int exitcode, int bysignal) { * ## Server hooks implementation * -------------------------------------------------------------------------- */ -/* This must be synced with REDISMODULE_EVENT_* +/* This must be synced with VALKEYMODULE_EVENT_* * We use -1 (MAX_UINT64) to denote that this event doesn't have * a data structure associated with it. We use MAX_UINT64 on purpose, - * in order to pass the check in RedisModule_SubscribeToServerEvent. */ + * in order to pass the check in ValkeyModule_SubscribeToServerEvent. */ static uint64_t moduleEventVersions[] = { - REDISMODULE_REPLICATIONINFO_VERSION, /* REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED */ - -1, /* REDISMODULE_EVENT_PERSISTENCE */ - REDISMODULE_FLUSHINFO_VERSION, /* REDISMODULE_EVENT_FLUSHDB */ - -1, /* REDISMODULE_EVENT_LOADING */ - REDISMODULE_CLIENTINFO_VERSION, /* REDISMODULE_EVENT_CLIENT_CHANGE */ - -1, /* REDISMODULE_EVENT_SHUTDOWN */ - -1, /* REDISMODULE_EVENT_REPLICA_CHANGE */ - -1, /* REDISMODULE_EVENT_MASTER_LINK_CHANGE */ - REDISMODULE_CRON_LOOP_VERSION, /* REDISMODULE_EVENT_CRON_LOOP */ - REDISMODULE_MODULE_CHANGE_VERSION, /* REDISMODULE_EVENT_MODULE_CHANGE */ - REDISMODULE_LOADING_PROGRESS_VERSION, /* REDISMODULE_EVENT_LOADING_PROGRESS */ - REDISMODULE_SWAPDBINFO_VERSION, /* REDISMODULE_EVENT_SWAPDB */ - -1, /* REDISMODULE_EVENT_REPL_BACKUP */ - -1, /* REDISMODULE_EVENT_FORK_CHILD */ - -1, /* REDISMODULE_EVENT_REPL_ASYNC_LOAD */ - -1, /* REDISMODULE_EVENT_EVENTLOOP */ - -1, /* REDISMODULE_EVENT_CONFIG */ - REDISMODULE_KEYINFO_VERSION, /* REDISMODULE_EVENT_KEY */ + VALKEYMODULE_REPLICATIONINFO_VERSION, /* VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED */ + -1, /* VALKEYMODULE_EVENT_PERSISTENCE */ + VALKEYMODULE_FLUSHINFO_VERSION, /* VALKEYMODULE_EVENT_FLUSHDB */ + -1, /* VALKEYMODULE_EVENT_LOADING */ + VALKEYMODULE_CLIENTINFO_VERSION, /* VALKEYMODULE_EVENT_CLIENT_CHANGE */ + -1, /* VALKEYMODULE_EVENT_SHUTDOWN */ + -1, /* VALKEYMODULE_EVENT_REPLICA_CHANGE */ + -1, /* VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE */ + VALKEYMODULE_CRON_LOOP_VERSION, /* VALKEYMODULE_EVENT_CRON_LOOP */ + VALKEYMODULE_MODULE_CHANGE_VERSION, /* VALKEYMODULE_EVENT_MODULE_CHANGE */ + VALKEYMODULE_LOADING_PROGRESS_VERSION, /* VALKEYMODULE_EVENT_LOADING_PROGRESS */ + VALKEYMODULE_SWAPDBINFO_VERSION, /* VALKEYMODULE_EVENT_SWAPDB */ + -1, /* VALKEYMODULE_EVENT_REPL_BACKUP */ + -1, /* VALKEYMODULE_EVENT_FORK_CHILD */ + -1, /* VALKEYMODULE_EVENT_REPL_ASYNC_LOAD */ + -1, /* VALKEYMODULE_EVENT_EVENTLOOP */ + -1, /* VALKEYMODULE_EVENT_CONFIG */ + VALKEYMODULE_KEYINFO_VERSION, /* VALKEYMODULE_EVENT_KEY */ }; /* Register to be notified, via a callback, when the specified server event @@ -11365,8 +11366,8 @@ static uint64_t moduleEventVersions[] = { * * The callback must be of this type: * - * int (*RedisModuleEventCallback)(RedisModuleCtx *ctx, - * RedisModuleEvent eid, + * int (*ValkeyModuleEventCallback)(ValkeyModuleCtx *ctx, + * ValkeyModuleEvent eid, * uint64_t subevent, * void *data); * @@ -11382,7 +11383,7 @@ static uint64_t moduleEventVersions[] = { * * Here is a list of events you can use as 'eid' and related sub events: * - * * RedisModuleEvent_ReplicationRoleChanged: + * * ValkeyModuleEvent_ReplicationRoleChanged: * * This event is called when the instance switches from master * to replica or the other way around, however the event is @@ -11391,11 +11392,11 @@ static uint64_t moduleEventVersions[] = { * * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_MASTER` - * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA` + * * `VALKEYMODULE_SUBEVENT_REPLROLECHANGED_NOW_PRIMARY` + * * `VALKEYMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA` * * The 'data' field can be casted by the callback to a - * `RedisModuleReplicationInfo` structure with the following fields: + * `ValkeyModuleReplicationInfo` structure with the following fields: * * int master; // true if master, false if replica * char *masterhost; // master instance hostname for NOW_REPLICA @@ -11405,17 +11406,17 @@ static uint64_t moduleEventVersions[] = { * uint64_t repl1_offset; // Main replication offset * uint64_t repl2_offset; // Offset of replid2 validity * - * * RedisModuleEvent_Persistence + * * ValkeyModuleEvent_Persistence * * This event is called when RDB saving or AOF rewriting starts * and ends. The following sub events are available: * - * * `REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_ENDED` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_FAILED` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED` * * The above events are triggered not just when the user calls the * relevant commands like BGSAVE, but also when a saving operation @@ -11428,16 +11429,16 @@ static uint64_t moduleEventVersions[] = { * clients and commands. Also note that the AOF_START sub event may end * up saving RDB content in case of an AOF with rdb-preamble. * - * * RedisModuleEvent_FlushDB + * * ValkeyModuleEvent_FlushDB * * The FLUSHALL, FLUSHDB or an internal flush (for instance * because of replication, after the replica synchronization) * happened. The following sub events are available: * - * * `REDISMODULE_SUBEVENT_FLUSHDB_START` - * * `REDISMODULE_SUBEVENT_FLUSHDB_END` + * * `VALKEYMODULE_SUBEVENT_FLUSHDB_START` + * * `VALKEYMODULE_SUBEVENT_FLUSHDB_END` * - * The data pointer can be casted to a RedisModuleFlushInfo + * The data pointer can be casted to a ValkeyModuleFlushInfo * structure with the following fields: * * int32_t async; // True if the flush is done in a thread. @@ -11452,51 +11453,51 @@ static uint64_t moduleEventVersions[] = { * allowing the callback to call DBSIZE or other operation on the * yet-to-free keyspace. * - * * RedisModuleEvent_Loading + * * ValkeyModuleEvent_Loading * * Called on loading operations: at startup when the server is * started, but also after a first synchronization when the * replica is loading the RDB file from the master. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_LOADING_RDB_START` - * * `REDISMODULE_SUBEVENT_LOADING_AOF_START` - * * `REDISMODULE_SUBEVENT_LOADING_REPL_START` - * * `REDISMODULE_SUBEVENT_LOADING_ENDED` - * * `REDISMODULE_SUBEVENT_LOADING_FAILED` + * * `VALKEYMODULE_SUBEVENT_LOADING_RDB_START` + * * `VALKEYMODULE_SUBEVENT_LOADING_AOF_START` + * * `VALKEYMODULE_SUBEVENT_LOADING_REPL_START` + * * `VALKEYMODULE_SUBEVENT_LOADING_ENDED` + * * `VALKEYMODULE_SUBEVENT_LOADING_FAILED` * * Note that AOF loading may start with an RDB data in case of * rdb-preamble, in which case you'll only receive an AOF_START event. * - * * RedisModuleEvent_ClientChange + * * ValkeyModuleEvent_ClientChange * * Called when a client connects or disconnects. - * The data pointer can be casted to a RedisModuleClientInfo - * structure, documented in RedisModule_GetClientInfoById(). + * The data pointer can be casted to a ValkeyModuleClientInfo + * structure, documented in ValkeyModule_GetClientInfoById(). * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED` - * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED` + * * `VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED` + * * `VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED` * - * * RedisModuleEvent_Shutdown + * * ValkeyModuleEvent_Shutdown * * The server is shutting down. No subevents are available. * - * * RedisModuleEvent_ReplicaChange + * * ValkeyModuleEvent_ReplicaChange * * This event is called when the instance (that can be both a * master or a replica) get a new online replica, or lose a * replica since it gets disconnected. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE` - * * `REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE` + * * `VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE` + * * `VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE` * * No additional information is available so far: future versions * of Redis will have an API in order to enumerate the replicas * connected and their state. * - * * RedisModuleEvent_CronLoop + * * ValkeyModuleEvent_CronLoop * * This event is called every time Redis calls the serverCron() * function in order to do certain bookkeeping. Modules that are @@ -11505,12 +11506,12 @@ static uint64_t moduleEventVersions[] = { * this changes depending on the "hz" configuration. * No sub events are available. * - * The data pointer can be casted to a RedisModuleCronLoop + * The data pointer can be casted to a ValkeyModuleCronLoop * structure with the following fields: * * int32_t hz; // Approximate number of events per second. * - * * RedisModuleEvent_MasterLinkChange + * * ValkeyModuleEvent_MasterLinkChange * * This is called for replicas in order to notify when the * replication link becomes functional (up) with our master, @@ -11519,55 +11520,55 @@ static uint64_t moduleEventVersions[] = { * replication is happening correctly. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_MASTER_LINK_UP` - * * `REDISMODULE_SUBEVENT_MASTER_LINK_DOWN` + * * `VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP` + * * `VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN` * - * * RedisModuleEvent_ModuleChange + * * ValkeyModuleEvent_ModuleChange * * This event is called when a new module is loaded or one is unloaded. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_MODULE_LOADED` - * * `REDISMODULE_SUBEVENT_MODULE_UNLOADED` + * * `VALKEYMODULE_SUBEVENT_MODULE_LOADED` + * * `VALKEYMODULE_SUBEVENT_MODULE_UNLOADED` * - * The data pointer can be casted to a RedisModuleModuleChange + * The data pointer can be casted to a ValkeyModuleModuleChange * structure with the following fields: * * const char* module_name; // Name of module loaded or unloaded. * int32_t module_version; // Module version. * - * * RedisModuleEvent_LoadingProgress + * * ValkeyModuleEvent_LoadingProgress * * This event is called repeatedly called while an RDB or AOF file * is being loaded. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB` - * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF` + * * `VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB` + * * `VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF` * - * The data pointer can be casted to a RedisModuleLoadingProgress + * The data pointer can be casted to a ValkeyModuleLoadingProgress * structure with the following fields: * * int32_t hz; // Approximate number of events per second. * int32_t progress; // Approximate progress between 0 and 1024, * // or -1 if unknown. * - * * RedisModuleEvent_SwapDB + * * ValkeyModuleEvent_SwapDB * * This event is called when a SWAPDB command has been successfully * Executed. * For this event call currently there is no subevents available. * - * The data pointer can be casted to a RedisModuleSwapDbInfo + * The data pointer can be casted to a ValkeyModuleSwapDbInfo * structure with the following fields: * * int32_t dbnum_first; // Swap Db first dbnum * int32_t dbnum_second; // Swap Db second dbnum * - * * RedisModuleEvent_ReplBackup + * * ValkeyModuleEvent_ReplBackup * * WARNING: Replication Backup events are deprecated since Redis 7.0 and are never fired. - * See RedisModuleEvent_ReplAsyncLoad for understanding how Async Replication Loading events + * See ValkeyModuleEvent_ReplAsyncLoad for understanding how Async Replication Loading events * are now triggered when repl-diskless-load is set to swapdb. * * Called when repl-diskless-load config is set to swapdb, @@ -11577,85 +11578,85 @@ static uint64_t moduleEventVersions[] = { * notification to backup / restore / discard its globals. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE` - * * `REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE` - * * `REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD` + * * `VALKEYMODULE_SUBEVENT_REPL_BACKUP_CREATE` + * * `VALKEYMODULE_SUBEVENT_REPL_BACKUP_RESTORE` + * * `VALKEYMODULE_SUBEVENT_REPL_BACKUP_DISCARD` * - * * RedisModuleEvent_ReplAsyncLoad + * * ValkeyModuleEvent_ReplAsyncLoad * * Called when repl-diskless-load config is set to swapdb and a replication with a master of same * data set history (matching replication ID) occurs. * In which case redis serves current data set while loading new database in memory from socket. * Modules must have declared they support this mechanism in order to activate it, through - * REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD flag. + * VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD flag. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED` - * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED` - * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED` + * * `VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED` + * * `VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED` + * * `VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED` * - * * RedisModuleEvent_ForkChild + * * ValkeyModuleEvent_ForkChild * * Called when a fork child (AOFRW, RDBSAVE, module fork...) is born/dies * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_FORK_CHILD_BORN` - * * `REDISMODULE_SUBEVENT_FORK_CHILD_DIED` + * * `VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN` + * * `VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED` * - * * RedisModuleEvent_EventLoop + * * ValkeyModuleEvent_EventLoop * * Called on each event loop iteration, once just before the event loop goes * to sleep or just after it wakes up. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP` - * * `REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP` + * * `VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP` + * * `VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP` * - * * RedisModule_Event_Config + * * ValkeyModule_Event_Config * * Called when a configuration event happens * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_CONFIG_CHANGE` + * * `VALKEYMODULE_SUBEVENT_CONFIG_CHANGE` * - * The data pointer can be casted to a RedisModuleConfigChange + * The data pointer can be casted to a ValkeyModuleConfigChange * structure with the following fields: * * const char **config_names; // An array of C string pointers containing the * // name of each modified configuration item * uint32_t num_changes; // The number of elements in the config_names array * - * * RedisModule_Event_Key + * * ValkeyModule_Event_Key * * Called when a key is removed from the keyspace. We can't modify any key in * the event. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_KEY_DELETED` - * * `REDISMODULE_SUBEVENT_KEY_EXPIRED` - * * `REDISMODULE_SUBEVENT_KEY_EVICTED` - * * `REDISMODULE_SUBEVENT_KEY_OVERWRITTEN` + * * `VALKEYMODULE_SUBEVENT_KEY_DELETED` + * * `VALKEYMODULE_SUBEVENT_KEY_EXPIRED` + * * `VALKEYMODULE_SUBEVENT_KEY_EVICTED` + * * `VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN` * - * The data pointer can be casted to a RedisModuleKeyInfo + * The data pointer can be casted to a ValkeyModuleKeyInfo * structure with the following fields: * - * RedisModuleKey *key; // Key name + * ValkeyModuleKey *key; // Key name * - * The function returns REDISMODULE_OK if the module was successfully subscribed + * The function returns VALKEYMODULE_OK if the module was successfully subscribed * for the specified event. If the API is called from a wrong context or unsupported event - * is given then REDISMODULE_ERR is returned. */ -int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, RedisModuleEventCallback callback) { - RedisModuleEventListener *el; + * is given then VALKEYMODULE_ERR is returned. */ +int VM_SubscribeToServerEvent(ValkeyModuleCtx *ctx, ValkeyModuleEvent event, ValkeyModuleEventCallback callback) { + ValkeyModuleEventListener *el; /* Protect in case of calls from contexts without a module reference. */ - if (ctx->module == NULL) return REDISMODULE_ERR; - if (event.id >= _REDISMODULE_EVENT_NEXT) return REDISMODULE_ERR; - if (event.dataver > moduleEventVersions[event.id]) return REDISMODULE_ERR; /* Module compiled with a newer redismodule.h than we support */ + if (ctx->module == NULL) return VALKEYMODULE_ERR; + if (event.id >= _VALKEYMODULE_EVENT_NEXT) return VALKEYMODULE_ERR; + if (event.dataver > moduleEventVersions[event.id]) return VALKEYMODULE_ERR; /* Module compiled with a newer valkeymodule.h than we support */ /* Search an event matching this module and event ID. */ listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(ValkeyModule_EventListeners,&li); while((ln = listNext(&li))) { el = ln->value; if (el->module == ctx->module && el->event.id == event.id) @@ -11665,12 +11666,12 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis /* Modify or remove the event listener if we already had one. */ if (ln) { if (callback == NULL) { - listDelNode(RedisModule_EventListeners,ln); + listDelNode(ValkeyModule_EventListeners,ln); zfree(el); } else { el->callback = callback; /* Update the callback with the new one. */ } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* No event found, we need to add a new one. */ @@ -11678,50 +11679,50 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis el->module = ctx->module; el->event = event; el->callback = callback; - listAddNodeTail(RedisModule_EventListeners,el); - return REDISMODULE_OK; + listAddNodeTail(ValkeyModule_EventListeners,el); + return VALKEYMODULE_OK; } /** * For a given server event and subevent, return zero if the * subevent is not supported and non-zero otherwise. */ -int RM_IsSubEventSupported(RedisModuleEvent event, int64_t subevent) { +int VM_IsSubEventSupported(ValkeyModuleEvent event, int64_t subevent) { switch (event.id) { - case REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED: - return subevent < _REDISMODULE_EVENT_REPLROLECHANGED_NEXT; - case REDISMODULE_EVENT_PERSISTENCE: - return subevent < _REDISMODULE_SUBEVENT_PERSISTENCE_NEXT; - case REDISMODULE_EVENT_FLUSHDB: - return subevent < _REDISMODULE_SUBEVENT_FLUSHDB_NEXT; - case REDISMODULE_EVENT_LOADING: - return subevent < _REDISMODULE_SUBEVENT_LOADING_NEXT; - case REDISMODULE_EVENT_CLIENT_CHANGE: - return subevent < _REDISMODULE_SUBEVENT_CLIENT_CHANGE_NEXT; - case REDISMODULE_EVENT_SHUTDOWN: - return subevent < _REDISMODULE_SUBEVENT_SHUTDOWN_NEXT; - case REDISMODULE_EVENT_REPLICA_CHANGE: - return subevent < _REDISMODULE_EVENT_REPLROLECHANGED_NEXT; - case REDISMODULE_EVENT_MASTER_LINK_CHANGE: - return subevent < _REDISMODULE_SUBEVENT_MASTER_NEXT; - case REDISMODULE_EVENT_CRON_LOOP: - return subevent < _REDISMODULE_SUBEVENT_CRON_LOOP_NEXT; - case REDISMODULE_EVENT_MODULE_CHANGE: - return subevent < _REDISMODULE_SUBEVENT_MODULE_NEXT; - case REDISMODULE_EVENT_LOADING_PROGRESS: - return subevent < _REDISMODULE_SUBEVENT_LOADING_PROGRESS_NEXT; - case REDISMODULE_EVENT_SWAPDB: - return subevent < _REDISMODULE_SUBEVENT_SWAPDB_NEXT; - case REDISMODULE_EVENT_REPL_ASYNC_LOAD: - return subevent < _REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT; - case REDISMODULE_EVENT_FORK_CHILD: - return subevent < _REDISMODULE_SUBEVENT_FORK_CHILD_NEXT; - case REDISMODULE_EVENT_EVENTLOOP: - return subevent < _REDISMODULE_SUBEVENT_EVENTLOOP_NEXT; - case REDISMODULE_EVENT_CONFIG: - return subevent < _REDISMODULE_SUBEVENT_CONFIG_NEXT; - case REDISMODULE_EVENT_KEY: - return subevent < _REDISMODULE_SUBEVENT_KEY_NEXT; + case VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED: + return subevent < _VALKEYMODULE_EVENT_REPLROLECHANGED_NEXT; + case VALKEYMODULE_EVENT_PERSISTENCE: + return subevent < _VALKEYMODULE_SUBEVENT_PERSISTENCE_NEXT; + case VALKEYMODULE_EVENT_FLUSHDB: + return subevent < _VALKEYMODULE_SUBEVENT_FLUSHDB_NEXT; + case VALKEYMODULE_EVENT_LOADING: + return subevent < _VALKEYMODULE_SUBEVENT_LOADING_NEXT; + case VALKEYMODULE_EVENT_CLIENT_CHANGE: + return subevent < _VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_NEXT; + case VALKEYMODULE_EVENT_SHUTDOWN: + return subevent < _VALKEYMODULE_SUBEVENT_SHUTDOWN_NEXT; + case VALKEYMODULE_EVENT_REPLICA_CHANGE: + return subevent < _VALKEYMODULE_EVENT_REPLROLECHANGED_NEXT; + case VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE: + return subevent < _VALKEYMODULE_SUBEVENT_PRIMARY_NEXT; + case VALKEYMODULE_EVENT_CRON_LOOP: + return subevent < _VALKEYMODULE_SUBEVENT_CRON_LOOP_NEXT; + case VALKEYMODULE_EVENT_MODULE_CHANGE: + return subevent < _VALKEYMODULE_SUBEVENT_MODULE_NEXT; + case VALKEYMODULE_EVENT_LOADING_PROGRESS: + return subevent < _VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_NEXT; + case VALKEYMODULE_EVENT_SWAPDB: + return subevent < _VALKEYMODULE_SUBEVENT_SWAPDB_NEXT; + case VALKEYMODULE_EVENT_REPL_ASYNC_LOAD: + return subevent < _VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT; + case VALKEYMODULE_EVENT_FORK_CHILD: + return subevent < _VALKEYMODULE_SUBEVENT_FORK_CHILD_NEXT; + case VALKEYMODULE_EVENT_EVENTLOOP: + return subevent < _VALKEYMODULE_SUBEVENT_EVENTLOOP_NEXT; + case VALKEYMODULE_EVENT_CONFIG: + return subevent < _VALKEYMODULE_SUBEVENT_CONFIG_NEXT; + case VALKEYMODULE_EVENT_KEY: + return subevent < _VALKEYMODULE_SUBEVENT_KEY_NEXT; default: break; } @@ -11730,7 +11731,7 @@ int RM_IsSubEventSupported(RedisModuleEvent event, int64_t subevent) { typedef struct KeyInfo { int32_t dbnum; - RedisModuleString *key; + ValkeyModuleString *key; robj *value; int mode; } KeyInfo; @@ -11746,65 +11747,65 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { /* Fast path to return ASAP if there is nothing to do, avoiding to * setup the iterator and so forth: we want this call to be extremely * cheap if there are no registered modules. */ - if (listLength(RedisModule_EventListeners) == 0) return; + if (listLength(ValkeyModule_EventListeners) == 0) return; listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(ValkeyModule_EventListeners,&li); while((ln = listNext(&li))) { - RedisModuleEventListener *el = ln->value; + ValkeyModuleEventListener *el = ln->value; if (el->event.id == eid) { - RedisModuleCtx ctx; - if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { + ValkeyModuleCtx ctx; + if (eid == VALKEYMODULE_EVENT_CLIENT_CHANGE) { /* In the case of client changes, we're pushing the real client * so the event handler can mutate it if needed. For example, * to change its authentication state in a way that does not * depend on specific commands executed later. */ - moduleCreateContext(&ctx,el->module,REDISMODULE_CTX_NONE); + moduleCreateContext(&ctx,el->module,VALKEYMODULE_CTX_NONE); ctx.client = (client *) data; } else { - moduleCreateContext(&ctx,el->module,REDISMODULE_CTX_TEMP_CLIENT); + moduleCreateContext(&ctx,el->module,VALKEYMODULE_CTX_TEMP_CLIENT); } void *moduledata = NULL; - RedisModuleClientInfoV1 civ1; - RedisModuleReplicationInfoV1 riv1; - RedisModuleModuleChangeV1 mcv1; - RedisModuleKey key; - RedisModuleKeyInfoV1 ki = {REDISMODULE_KEYINFO_VERSION, &key}; + ValkeyModuleClientInfoV1 civ1; + ValkeyModuleReplicationInfoV1 riv1; + ValkeyModuleModuleChangeV1 mcv1; + ValkeyModuleKey key; + ValkeyModuleKeyInfoV1 ki = {VALKEYMODULE_KEYINFO_VERSION, &key}; /* Event specific context and data pointer setup. */ - if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { - serverAssert(modulePopulateClientInfoStructure(&civ1,data, el->event.dataver) == REDISMODULE_OK); + if (eid == VALKEYMODULE_EVENT_CLIENT_CHANGE) { + serverAssert(modulePopulateClientInfoStructure(&civ1,data, el->event.dataver) == VALKEYMODULE_OK); moduledata = &civ1; - } else if (eid == REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED) { - serverAssert(modulePopulateReplicationInfoStructure(&riv1,el->event.dataver) == REDISMODULE_OK); + } else if (eid == VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED) { + serverAssert(modulePopulateReplicationInfoStructure(&riv1,el->event.dataver) == VALKEYMODULE_OK); moduledata = &riv1; - } else if (eid == REDISMODULE_EVENT_FLUSHDB) { + } else if (eid == VALKEYMODULE_EVENT_FLUSHDB) { moduledata = data; - RedisModuleFlushInfoV1 *fi = data; + ValkeyModuleFlushInfoV1 *fi = data; if (fi->dbnum != -1) selectDb(ctx.client, fi->dbnum); - } else if (eid == REDISMODULE_EVENT_MODULE_CHANGE) { - RedisModule *m = data; + } else if (eid == VALKEYMODULE_EVENT_MODULE_CHANGE) { + ValkeyModule *m = data; if (m == el->module) { moduleFreeContext(&ctx); continue; } - mcv1.version = REDISMODULE_MODULE_CHANGE_VERSION; + mcv1.version = VALKEYMODULE_MODULE_CHANGE_VERSION; mcv1.module_name = m->name; mcv1.module_version = m->ver; moduledata = &mcv1; - } else if (eid == REDISMODULE_EVENT_LOADING_PROGRESS) { + } else if (eid == VALKEYMODULE_EVENT_LOADING_PROGRESS) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_CRON_LOOP) { + } else if (eid == VALKEYMODULE_EVENT_CRON_LOOP) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_SWAPDB) { + } else if (eid == VALKEYMODULE_EVENT_SWAPDB) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_CONFIG) { + } else if (eid == VALKEYMODULE_EVENT_CONFIG) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_KEY) { + } else if (eid == VALKEYMODULE_EVENT_KEY) { KeyInfo *info = data; selectDb(ctx.client, info->dbnum); moduleInitKey(&key, &ctx, info->key, info->value, info->mode); @@ -11815,7 +11816,7 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { el->callback(&ctx,el->event,subid,moduledata); el->module->in_hook--; - if (eid == REDISMODULE_EVENT_KEY) { + if (eid == VALKEYMODULE_EVENT_KEY) { moduleCloseKey(&key); } @@ -11826,16 +11827,16 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { /* Remove all the listeners for this module: this is used before unloading * a module. */ -void moduleUnsubscribeAllServerEvents(RedisModule *module) { - RedisModuleEventListener *el; +void moduleUnsubscribeAllServerEvents(ValkeyModule *module) { + ValkeyModuleEventListener *el; listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(ValkeyModule_EventListeners,&li); while((ln = listNext(&li))) { el = ln->value; if (el->module == module) { - listDelNode(RedisModule_EventListeners,ln); + listDelNode(ValkeyModule_EventListeners,ln); zfree(el); } } @@ -11849,13 +11850,13 @@ void processModuleLoadingProgressEvent(int is_aof) { int progress = -1; if (server.loading_total_bytes) progress = (server.loading_loaded_bytes<<10) / server.loading_total_bytes; - RedisModuleLoadingProgressV1 fi = {REDISMODULE_LOADING_PROGRESS_VERSION, + ValkeyModuleLoadingProgressV1 fi = {VALKEYMODULE_LOADING_PROGRESS_VERSION, server.hz, progress}; - moduleFireServerEvent(REDISMODULE_EVENT_LOADING_PROGRESS, + moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING_PROGRESS, is_aof? - REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF: - REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB, + VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF: + VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB, &fi); /* decide when the next event should fire. */ next_event = now + 1000000 / server.hz; @@ -11866,23 +11867,23 @@ void processModuleLoadingProgressEvent(int is_aof) { * will be called to tell the module which key is about to be released. */ void moduleNotifyKeyUnlink(robj *key, robj *val, int dbid, int flags) { server.lazy_expire_disabled++; - int subevent = REDISMODULE_SUBEVENT_KEY_DELETED; + int subevent = VALKEYMODULE_SUBEVENT_KEY_DELETED; if (flags & DB_FLAG_KEY_EXPIRED) { - subevent = REDISMODULE_SUBEVENT_KEY_EXPIRED; + subevent = VALKEYMODULE_SUBEVENT_KEY_EXPIRED; } else if (flags & DB_FLAG_KEY_EVICTED) { - subevent = REDISMODULE_SUBEVENT_KEY_EVICTED; + subevent = VALKEYMODULE_SUBEVENT_KEY_EVICTED; } else if (flags & DB_FLAG_KEY_OVERWRITE) { - subevent = REDISMODULE_SUBEVENT_KEY_OVERWRITTEN; + subevent = VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN; } - KeyInfo info = {dbid, key, val, REDISMODULE_READ}; - moduleFireServerEvent(REDISMODULE_EVENT_KEY, subevent, &info); + KeyInfo info = {dbid, key, val, VALKEYMODULE_READ}; + moduleFireServerEvent(VALKEYMODULE_EVENT_KEY, subevent, &info); if (val->type == OBJ_MODULE) { moduleValue *mv = val->ptr; moduleType *mt = mv->type; /* We prefer to use the enhanced version. */ if (mt->unlink2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + ValkeyModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; mt->unlink2(&ctx,mv->value); } else if (mt->unlink != NULL) { mt->unlink(key,mv->value); @@ -11900,7 +11901,7 @@ size_t moduleGetFreeEffort(robj *key, robj *val, int dbid) { size_t effort = 1; /* We prefer to use the enhanced version. */ if (mt->free_effort2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + ValkeyModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; effort = mt->free_effort2(&ctx,mv->value); } else if (mt->free_effort != NULL) { effort = mt->free_effort(key,mv->value); @@ -11917,7 +11918,7 @@ size_t moduleGetMemUsage(robj *key, robj *val, size_t sample_size, int dbid) { size_t size = 0; /* We prefer to use the enhanced version. */ if (mt->mem_usage2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + ValkeyModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; size = mt->mem_usage2(&ctx, mv->value, sample_size); } else if (mt->mem_usage != NULL) { size = mt->mem_usage(mv->value); @@ -11956,8 +11957,11 @@ int moduleRegisterApi(const char *funcname, void *funcptr) { return dictAdd(server.moduleapi, (char*)funcname, funcptr); } +/* Register Module APIs under both RedisModule_ and ValkeyModule_ namespaces + * so that legacy Redis module binaries can continue to function */ #define REGISTER_API(name) \ - moduleRegisterApi("RedisModule_" #name, (void *)(unsigned long)RM_ ## name) + moduleRegisterApi("ValkeyModule_" #name, (void *)(unsigned long)VM_ ## name);\ + moduleRegisterApi("RedisModule_" #name, (void *)(unsigned long)VM_ ## name);\ /* Global initialization at Redis startup. */ void moduleRegisterCoreAPI(void); @@ -12013,10 +12017,10 @@ void moduleInitModulesSystem(void) { Timers = raxNew(); /* Setup the event listeners data structures. */ - RedisModule_EventListeners = listCreate(); + ValkeyModule_EventListeners = listCreate(); /* Making sure moduleEventVersions is synced with the number of events. */ - serverAssert(sizeof(moduleEventVersions)/sizeof(moduleEventVersions[0]) == _REDISMODULE_EVENT_NEXT); + serverAssert(sizeof(moduleEventVersions)/sizeof(moduleEventVersions[0]) == _VALKEYMODULE_EVENT_NEXT); /* Our thread-safe contexts GIL must start with already locked: * it is just unlocked when it's safe. */ @@ -12061,7 +12065,7 @@ void moduleLoadQueueEntryFree(struct moduleLoadQueueEntry *loadmod) { } /* Remove Module Configs from standardConfig array in config.c */ -void moduleRemoveConfigs(RedisModule *module) { +void moduleRemoveConfigs(ValkeyModule *module) { listIter li; listNode *ln; listRewind(module->module_configs, &li); @@ -12075,7 +12079,7 @@ void moduleRemoveConfigs(RedisModule *module) { } /* Remove ACL categories added by the module when it fails to load. */ -void moduleRemoveCateogires(RedisModule *module) { +void moduleRemoveCateogires(ValkeyModule *module) { if (module->num_acl_categories_added) { ACLCleanupCategoriesOnFailure(module->num_acl_categories_added); } @@ -12121,7 +12125,7 @@ void moduleLoadFromQueue(void) { } } -void moduleFreeModuleStructure(struct RedisModule *module) { +void moduleFreeModuleStructure(struct ValkeyModule *module) { listRelease(module->types); listRelease(module->filters); listRelease(module->usedby); @@ -12154,11 +12158,11 @@ void moduleFreeArgs(struct serverCommandArg *args, int num_args) { * Note that caller needs to handle the deletion of the command table dict, * and after that needs to free the command->fullname and the command itself. */ -int moduleFreeCommand(struct RedisModule *module, struct serverCommand *cmd) { - if (cmd->proc != RedisModuleCommandDispatcher) +int moduleFreeCommand(struct ValkeyModule *module, struct serverCommand *cmd) { + if (cmd->proc != ValkeyModuleCommandDispatcher) return C_ERR; - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; if (cp->module != module) return C_ERR; @@ -12208,7 +12212,7 @@ int moduleFreeCommand(struct RedisModule *module, struct serverCommand *cmd) { return C_OK; } -void moduleUnregisterCommands(struct RedisModule *module) { +void moduleUnregisterCommands(struct ValkeyModule *module) { /* Unregister all the commands registered by this module. */ dictIterator *di = dictGetSafeIterator(server.commands); dictEntry *de; @@ -12228,16 +12232,16 @@ void moduleUnregisterCommands(struct RedisModule *module) { /* We parse argv to add sds "NAME VALUE" pairs to the server.module_configs_queue list of configs. * We also increment the module_argv pointer to just after ARGS if there are args, otherwise * we set it to NULL */ -int parseLoadexArguments(RedisModuleString ***module_argv, int *module_argc) { +int parseLoadexArguments(ValkeyModuleString ***module_argv, int *module_argc) { int args_specified = 0; - RedisModuleString **argv = *module_argv; + ValkeyModuleString **argv = *module_argv; int argc = *module_argc; for (int i = 0; i < argc; i++) { char *arg_val = argv[i]->ptr; if (!strcasecmp(arg_val, "CONFIG")) { if (i + 2 >= argc) { serverLog(LL_NOTICE, "CONFIG specified without name value pair"); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } sds name = sdsdup(argv[i + 1]->ptr); sds value = sdsdup(argv[i + 2]->ptr); @@ -12256,18 +12260,18 @@ int parseLoadexArguments(RedisModuleString ***module_argv, int *module_argc) { break; } else { serverLog(LL_NOTICE, "Syntax Error from arguments to loadex around %s.", arg_val); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } if (!args_specified) { *module_argv = NULL; *module_argc = 0; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Unregister module-related things, called when moduleLoad fails or moduleUnload. */ -void moduleUnregisterCleanup(RedisModule *module) { +void moduleUnregisterCleanup(ValkeyModule *module) { moduleFreeAuthenticatedClients(module); moduleUnregisterCommands(module); moduleUnsubscribeNotifications(module); @@ -12299,17 +12303,28 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa serverLog(LL_WARNING, "Module %s failed to load: %s", path, dlerror()); return C_ERR; } - onload = (int (*)(void *, void **, int))(unsigned long) dlsym(handle,"RedisModule_OnLoad"); + + const char *onLoadNames[] = {"ValkeyModule_OnLoad", "RedisModule_OnLoad"}; + for (size_t i = 0; i < sizeof(onLoadNames) / sizeof(onLoadNames[0]); i++) { + onload = (int (*)(void *, void **, int))(unsigned long) dlsym(handle, onLoadNames[i]); + if (onload != NULL) { + if (i != 0) { + serverLog(LL_NOTICE, "Legacy Redis Module %s found", path); + } + break; + } + } + if (onload == NULL) { dlclose(handle); serverLog(LL_WARNING, - "Module %s does not export RedisModule_OnLoad() " + "Module %s does not export ValkeyModule_OnLoad() or RedisModule_OnLoad() " "symbol. Module not loaded.",path); return C_ERR; } - RedisModuleCtx ctx; - moduleCreateContext(&ctx, NULL, REDISMODULE_CTX_TEMP_CLIENT); /* We pass NULL since we don't have a module yet. */ - if (onload((void*)&ctx,module_argv,module_argc) == REDISMODULE_ERR) { + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, NULL, VALKEYMODULE_CTX_TEMP_CLIENT); /* We pass NULL since we don't have a module yet. */ + if (onload((void*)&ctx,module_argv,module_argc) == VALKEYMODULE_ERR) { serverLog(LL_WARNING, "Module %s initialization failed. Module not loaded",path); if (ctx.module) { @@ -12361,8 +12376,8 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa } /* Fire the loaded modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MODULE_CHANGE, - REDISMODULE_SUBEVENT_MODULE_LOADED, + moduleFireServerEvent(VALKEYMODULE_EVENT_MODULE_CHANGE, + VALKEYMODULE_SUBEVENT_MODULE_LOADED, ctx.module); moduleFreeContext(&ctx); @@ -12373,7 +12388,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa * C_OK is returned, otherwise C_ERR is returned and errmsg is set * with an appropriate message. */ int moduleUnload(sds name, const char **errmsg) { - struct RedisModule *module = dictFetchValue(modules,name); + struct ValkeyModule *module = dictFetchValue(modules,name); if (module == NULL) { *errmsg = "no such module with that name"; @@ -12397,16 +12412,26 @@ int moduleUnload(sds name, const char **errmsg) { } /* Give module a chance to clean up. */ - int (*onunload)(void *); - onunload = (int (*)(void *))(unsigned long) dlsym(module->handle, "RedisModule_OnUnload"); + const char *onUnloadNames[] = {"ValkeyModule_OnUnload", "RedisModule_OnUnload"}; + int (*onunload)(void *) = NULL; + for (size_t i = 0; i < sizeof(onUnloadNames) / sizeof(onUnloadNames[0]); i++) { + onunload = (int (*)(void *))(unsigned long)dlsym(module->handle, onUnloadNames[i]); + if (onunload) { + if (i != 0) { + serverLog(LL_NOTICE, "Legacy Redis Module %s found", name); + } + break; + } + } + if (onunload) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, module, REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, module, VALKEYMODULE_CTX_TEMP_CLIENT); int unload_status = onunload((void*)&ctx); moduleFreeContext(&ctx); - if (unload_status == REDISMODULE_ERR) { - serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); + if (unload_status == VALKEYMODULE_ERR) { + serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); errno = ECANCELED; return C_ERR; } @@ -12423,8 +12448,8 @@ int moduleUnload(sds name, const char **errmsg) { } /* Fire the unloaded modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MODULE_CHANGE, - REDISMODULE_SUBEVENT_MODULE_UNLOADED, + moduleFireServerEvent(VALKEYMODULE_EVENT_MODULE_CHANGE, + VALKEYMODULE_SUBEVENT_MODULE_UNLOADED, module); /* Remove from list of modules. */ @@ -12460,7 +12485,7 @@ void addReplyLoadedModules(client *c) { addReplyArrayLen(c,dictSize(modules)); while ((de = dictNext(di)) != NULL) { sds name = dictGetKey(de); - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); sds path = module->loadmod->path; addReplyMapLen(c,4); addReplyBulkCString(c,"name"); @@ -12486,7 +12511,7 @@ sds genModulesInfoStringRenderModulesList(list *l) { listRewind(l,&li); sds output = sdsnew("["); while((ln = listNext(&li))) { - RedisModule *module = ln->value; + ValkeyModule *module = ln->value; output = sdscat(output,module->name); if (ln != listLast(l)) output = sdscat(output,"|"); @@ -12496,13 +12521,13 @@ sds genModulesInfoStringRenderModulesList(list *l) { } /* Helper for genModulesInfoString(): render module options as an SDS string. */ -sds genModulesInfoStringRenderModuleOptions(struct RedisModule *module) { +sds genModulesInfoStringRenderModuleOptions(struct ValkeyModule *module) { sds output = sdsnew("["); - if (module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS) + if (module->options & VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS) output = sdscat(output,"handle-io-errors|"); - if (module->options & REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD) + if (module->options & VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD) output = sdscat(output,"handle-repl-async-load|"); - if (module->options & REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) + if (module->options & VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) output = sdscat(output,"no-implicit-signal-modified|"); output = sdstrim(output,"|"); output = sdscat(output,"]"); @@ -12514,6 +12539,7 @@ sds genModulesInfoStringRenderModuleOptions(struct RedisModule *module) { * output. * * After the call, the passed sds info string is no longer valid and all the + * * references must be substituted with the new pointer returned by the call. */ sds genModulesInfoString(sds info) { dictIterator *di = dictGetIterator(modules); @@ -12521,7 +12547,7 @@ sds genModulesInfoString(sds info) { while ((de = dictNext(di)) != NULL) { sds name = dictGetKey(de); - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); sds usedby = genModulesInfoStringRenderModulesList(module->usedby); sds using = genModulesInfoStringRenderModulesList(module->using); @@ -12544,40 +12570,40 @@ sds genModulesInfoString(sds info) { * -------------------------------------------------------------------------- */ /* Check if the configuration name is already registered */ -int isModuleConfigNameRegistered(RedisModule *module, const char *name) { +int isModuleConfigNameRegistered(ValkeyModule *module, const char *name) { listNode *match = listSearchKey(module->module_configs, (void *) name); return match != NULL; } -/* Assert that the flags passed into the RM_RegisterConfig Suite are valid */ +/* Assert that the flags passed into the VM_RegisterConfig Suite are valid */ int moduleVerifyConfigFlags(unsigned int flags, configType type) { - if ((flags & ~(REDISMODULE_CONFIG_DEFAULT - | REDISMODULE_CONFIG_IMMUTABLE - | REDISMODULE_CONFIG_SENSITIVE - | REDISMODULE_CONFIG_HIDDEN - | REDISMODULE_CONFIG_PROTECTED - | REDISMODULE_CONFIG_DENY_LOADING - | REDISMODULE_CONFIG_BITFLAGS - | REDISMODULE_CONFIG_MEMORY))) { + if ((flags & ~(VALKEYMODULE_CONFIG_DEFAULT + | VALKEYMODULE_CONFIG_IMMUTABLE + | VALKEYMODULE_CONFIG_SENSITIVE + | VALKEYMODULE_CONFIG_HIDDEN + | VALKEYMODULE_CONFIG_PROTECTED + | VALKEYMODULE_CONFIG_DENY_LOADING + | VALKEYMODULE_CONFIG_BITFLAGS + | VALKEYMODULE_CONFIG_MEMORY))) { serverLogRaw(LL_WARNING, "Invalid flag(s) for configuration"); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (type != NUMERIC_CONFIG && flags & REDISMODULE_CONFIG_MEMORY) { + if (type != NUMERIC_CONFIG && flags & VALKEYMODULE_CONFIG_MEMORY) { serverLogRaw(LL_WARNING, "Numeric flag provided for non-numeric configuration."); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (type != ENUM_CONFIG && flags & REDISMODULE_CONFIG_BITFLAGS) { + if (type != ENUM_CONFIG && flags & VALKEYMODULE_CONFIG_BITFLAGS) { serverLogRaw(LL_WARNING, "Enum flag provided for non-enum configuration."); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Verify a module resource or name has only alphanumeric characters, underscores * or dashes. */ int moduleVerifyResourceName(const char *name) { if (name[0] == '\0') { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } for (size_t i = 0; name[i] != '\0'; i++) { @@ -12590,16 +12616,16 @@ int moduleVerifyResourceName(const char *name) { continue; } serverLog(LL_WARNING, "Invalid character %c in Module resource name %s.", curr_char, name); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is a series of set functions for each type that act as dispatchers for * config.c to call module set callbacks. */ #define CONFIG_ERR_SIZE 256 static char configerr[CONFIG_ERR_SIZE]; -static void propagateErrorString(RedisModuleString *err_in, const char **err) { +static void propagateErrorString(ValkeyModuleString *err_in, const char **err) { if (err_in) { redis_strlcpy(configerr, err_in->ptr, CONFIG_ERR_SIZE); decrRefCount(err_in); @@ -12608,33 +12634,33 @@ static void propagateErrorString(RedisModuleString *err_in, const char **err) { } int setModuleBoolConfig(ModuleConfig *config, int val, const char **err) { - RedisModuleString *error = NULL; + ValkeyModuleString *error = NULL; int return_code = config->set_fn.set_bool(config->name, val, config->privdata, &error); propagateErrorString(error, err); - return return_code == REDISMODULE_OK ? 1 : 0; + return return_code == VALKEYMODULE_OK ? 1 : 0; } int setModuleStringConfig(ModuleConfig *config, sds strval, const char **err) { - RedisModuleString *error = NULL; - RedisModuleString *new = createStringObject(strval, sdslen(strval)); + ValkeyModuleString *error = NULL; + ValkeyModuleString *new = createStringObject(strval, sdslen(strval)); int return_code = config->set_fn.set_string(config->name, new, config->privdata, &error); propagateErrorString(error, err); decrRefCount(new); - return return_code == REDISMODULE_OK ? 1 : 0; + return return_code == VALKEYMODULE_OK ? 1 : 0; } int setModuleEnumConfig(ModuleConfig *config, int val, const char **err) { - RedisModuleString *error = NULL; + ValkeyModuleString *error = NULL; int return_code = config->set_fn.set_enum(config->name, val, config->privdata, &error); propagateErrorString(error, err); - return return_code == REDISMODULE_OK ? 1 : 0; + return return_code == VALKEYMODULE_OK ? 1 : 0; } int setModuleNumericConfig(ModuleConfig *config, long long val, const char **err) { - RedisModuleString *error = NULL; + ValkeyModuleString *error = NULL; int return_code = config->set_fn.set_numeric(config->name, val, config->privdata, &error); propagateErrorString(error, err); - return return_code == REDISMODULE_OK ? 1 : 0; + return return_code == VALKEYMODULE_OK ? 1 : 0; } /* This is a series of get functions for each type that act as dispatchers for @@ -12644,7 +12670,7 @@ int getModuleBoolConfig(ModuleConfig *module_config) { } sds getModuleStringConfig(ModuleConfig *module_config) { - RedisModuleString *val = module_config->get_fn.get_string(module_config->name, module_config->privdata); + ValkeyModuleString *val = module_config->get_fn.get_string(module_config->name, module_config->privdata); return val ? sdsdup(val->ptr) : NULL; } @@ -12658,7 +12684,7 @@ long long getModuleNumericConfig(ModuleConfig *module_config) { /* This function takes a module and a list of configs stored as sds NAME VALUE pairs. * It attempts to call set on each of these configs. */ -int loadModuleConfigs(RedisModule *module) { +int loadModuleConfigs(ValkeyModule *module) { listIter li; listNode *ln; const char *err = NULL; @@ -12672,21 +12698,21 @@ int loadModuleConfigs(RedisModule *module) { serverLog(LL_WARNING, "Issue during loading of configuration %s : %s", (sds) dictGetKey(config_argument), err); sdsfree(config_name); dictEmpty(server.module_configs_queue, NULL); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } else { if (!performModuleConfigSetDefaultFromName(config_name, &err)) { serverLog(LL_WARNING, "Issue attempting to set default value of configuration %s : %s", module_config->name, err); sdsfree(config_name); dictEmpty(server.module_configs_queue, NULL); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } dictDelete(server.module_configs_queue, config_name); sdsfree(config_name); } module->configs_initialized = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Add module_config to the list if the apply and privdata do not match one already in it. */ @@ -12711,13 +12737,13 @@ int moduleConfigApplyConfig(list *module_configs, const char **err, const char * listIter li; listNode *ln; ModuleConfig *module_config; - RedisModuleString *error = NULL; - RedisModuleCtx ctx; + ValkeyModuleString *error = NULL; + ValkeyModuleCtx ctx; listRewind(module_configs, &li); while ((ln = listNext(&li))) { module_config = listNodeValue(ln); - moduleCreateContext(&ctx, module_config->module, REDISMODULE_CTX_NONE); + moduleCreateContext(&ctx, module_config->module, VALKEYMODULE_CTX_NONE); if (module_config->apply_fn(&ctx, module_config->privdata, &error)) { if (err_arg_name) *err_arg_name = module_config->name; propagateErrorString(error, err); @@ -12734,7 +12760,7 @@ int moduleConfigApplyConfig(list *module_configs, const char **err, const char * * -------------------------------------------------------------------------- */ /* Create a module config object. */ -ModuleConfig *createModuleConfig(const char *name, RedisModuleConfigApplyFunc apply_fn, void *privdata, RedisModule *module) { +ModuleConfig *createModuleConfig(const char *name, ValkeyModuleConfigApplyFunc apply_fn, void *privdata, ValkeyModule *module) { ModuleConfig *new_config = zmalloc(sizeof(ModuleConfig)); new_config->name = sdsnew(name); new_config->apply_fn = apply_fn; @@ -12743,42 +12769,42 @@ ModuleConfig *createModuleConfig(const char *name, RedisModuleConfigApplyFunc ap return new_config; } -int moduleConfigValidityCheck(RedisModule *module, const char *name, unsigned int flags, configType type) { +int moduleConfigValidityCheck(ValkeyModule *module, const char *name, unsigned int flags, configType type) { if (!module->onload) { errno = EBUSY; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (moduleVerifyConfigFlags(flags, type) || moduleVerifyResourceName(name)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (isModuleConfigNameRegistered(module, name)) { serverLog(LL_WARNING, "Configuration by the name: %s already registered", name); errno = EALREADY; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } unsigned int maskModuleConfigFlags(unsigned int flags) { unsigned int new_flags = 0; - if (flags & REDISMODULE_CONFIG_DEFAULT) new_flags |= MODIFIABLE_CONFIG; - if (flags & REDISMODULE_CONFIG_IMMUTABLE) new_flags |= IMMUTABLE_CONFIG; - if (flags & REDISMODULE_CONFIG_HIDDEN) new_flags |= HIDDEN_CONFIG; - if (flags & REDISMODULE_CONFIG_PROTECTED) new_flags |= PROTECTED_CONFIG; - if (flags & REDISMODULE_CONFIG_DENY_LOADING) new_flags |= DENY_LOADING_CONFIG; + if (flags & VALKEYMODULE_CONFIG_DEFAULT) new_flags |= MODIFIABLE_CONFIG; + if (flags & VALKEYMODULE_CONFIG_IMMUTABLE) new_flags |= IMMUTABLE_CONFIG; + if (flags & VALKEYMODULE_CONFIG_HIDDEN) new_flags |= HIDDEN_CONFIG; + if (flags & VALKEYMODULE_CONFIG_PROTECTED) new_flags |= PROTECTED_CONFIG; + if (flags & VALKEYMODULE_CONFIG_DENY_LOADING) new_flags |= DENY_LOADING_CONFIG; return new_flags; } unsigned int maskModuleNumericConfigFlags(unsigned int flags) { unsigned int new_flags = 0; - if (flags & REDISMODULE_CONFIG_MEMORY) new_flags |= MEMORY_CONFIG; + if (flags & VALKEYMODULE_CONFIG_MEMORY) new_flags |= MEMORY_CONFIG; return new_flags; } unsigned int maskModuleEnumConfigFlags(unsigned int flags) { unsigned int new_flags = 0; - if (flags & REDISMODULE_CONFIG_BITFLAGS) new_flags |= MULTI_ARG_CONFIG; + if (flags & VALKEYMODULE_CONFIG_BITFLAGS) new_flags |= MULTI_ARG_CONFIG; return new_flags; } @@ -12805,23 +12831,23 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * * Numeric: 64 bit signed integer, which also supports min and max values. * * Bool: Yes or no value. * - * The `setfn` callback is expected to return REDISMODULE_OK when the value is successfully - * applied. It can also return REDISMODULE_ERR if the value can't be applied, and the - * *err pointer can be set with a RedisModuleString error message to provide to the client. - * This RedisModuleString will be freed by redis after returning from the set callback. + * The `setfn` callback is expected to return VALKEYMODULE_OK when the value is successfully + * applied. It can also return VALKEYMODULE_ERR if the value can't be applied, and the + * *err pointer can be set with a ValkeyModuleString error message to provide to the client. + * This ValkeyModuleString will be freed by redis after returning from the set callback. * * All configs are registered with a name, a type, a default value, private data that is made * available in the callbacks, as well as several flags that modify the behavior of the config. * The name must only contain alphanumeric characters or dashes. The supported flags are: * - * * REDISMODULE_CONFIG_DEFAULT: The default flags for a config. This creates a config that can be modified after startup. - * * REDISMODULE_CONFIG_IMMUTABLE: This config can only be provided loading time. - * * REDISMODULE_CONFIG_SENSITIVE: The value stored in this config is redacted from all logging. - * * REDISMODULE_CONFIG_HIDDEN: The name is hidden from `CONFIG GET` with pattern matching. - * * REDISMODULE_CONFIG_PROTECTED: This config will be only be modifiable based off the value of enable-protected-configs. - * * REDISMODULE_CONFIG_DENY_LOADING: This config is not modifiable while the server is loading data. - * * REDISMODULE_CONFIG_MEMORY: For numeric configs, this config will convert data unit notations into their byte equivalent. - * * REDISMODULE_CONFIG_BITFLAGS: For enum configs, this config will allow multiple entries to be combined as bit flags. + * * VALKEYMODULE_CONFIG_DEFAULT: The default flags for a config. This creates a config that can be modified after startup. + * * VALKEYMODULE_CONFIG_IMMUTABLE: This config can only be provided loading time. + * * VALKEYMODULE_CONFIG_SENSITIVE: The value stored in this config is redacted from all logging. + * * VALKEYMODULE_CONFIG_HIDDEN: The name is hidden from `CONFIG GET` with pattern matching. + * * VALKEYMODULE_CONFIG_PROTECTED: This config will be only be modifiable based off the value of enable-protected-configs. + * * VALKEYMODULE_CONFIG_DENY_LOADING: This config is not modifiable while the server is loading data. + * * VALKEYMODULE_CONFIG_MEMORY: For numeric configs, this config will convert data unit notations into their byte equivalent. + * * VALKEYMODULE_CONFIG_BITFLAGS: For enum configs, this config will allow multiple entries to be combined as bit flags. * * Default values are used on startup to set the value if it is not provided via the config file * or command line. Default values are also used to compare to on a config rewrite. @@ -12833,34 +12859,34 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * * Example implementation: * - * RedisModuleString *strval; + * ValkeyModuleString *strval; * int adjustable = 1; - * RedisModuleString *getStringConfigCommand(const char *name, void *privdata) { + * ValkeyModuleString *getStringConfigCommand(const char *name, void *privdata) { * return strval; * } * - * int setStringConfigCommand(const char *name, RedisModuleString *new, void *privdata, RedisModuleString **err) { + * int setStringConfigCommand(const char *name, ValkeyModuleString *new, void *privdata, ValkeyModuleString **err) { * if (adjustable) { - * RedisModule_Free(strval); - * RedisModule_RetainString(NULL, new); + * ValkeyModule_Free(strval); + * ValkeyModule_RetainString(NULL, new); * strval = new; - * return REDISMODULE_OK; + * return VALKEYMODULE_OK; * } - * *err = RedisModule_CreateString(NULL, "Not adjustable.", 15); - * return REDISMODULE_ERR; + * *err = ValkeyModule_CreateString(NULL, "Not adjustable.", 15); + * return VALKEYMODULE_ERR; * } * ... - * RedisModule_RegisterStringConfig(ctx, "string", NULL, REDISMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL); + * ValkeyModule_RegisterStringConfig(ctx, "string", NULL, VALKEYMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL); * - * If the registration fails, REDISMODULE_ERR is returned and one of the following + * If the registration fails, VALKEYMODULE_ERR is returned and one of the following * errno is set: - * * EBUSY: Registering the Config outside of RedisModule_OnLoad. + * * EBUSY: Registering the Config outside of ValkeyModule_OnLoad. * * EINVAL: The provided flags are invalid for the registration or the name of the config contains invalid characters. * * EALREADY: The provided configuration name is already used. */ -int RM_RegisterStringConfig(RedisModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, RedisModuleConfigGetStringFunc getfn, RedisModuleConfigSetStringFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; +int VM_RegisterStringConfig(ValkeyModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, ValkeyModuleConfigGetStringFunc getfn, ValkeyModuleConfigSetStringFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, NUMERIC_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_string = getfn; @@ -12868,16 +12894,16 @@ int RM_RegisterStringConfig(RedisModuleCtx *ctx, const char *name, const char *d listAddNodeTail(module->module_configs, new_config); flags = maskModuleConfigFlags(flags); addModuleStringConfig(module->name, name, flags, new_config, default_val ? sdsnew(default_val) : NULL); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Create a bool config that server clients can interact with via the * `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See - * RedisModule_RegisterStringConfig for detailed information about configs. */ -int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedisModuleConfigGetBoolFunc getfn, RedisModuleConfigSetBoolFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; + * ValkeyModule_RegisterStringConfig for detailed information about configs. */ +int VM_RegisterBoolConfig(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, ValkeyModuleConfigGetBoolFunc getfn, ValkeyModuleConfigSetBoolFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, BOOL_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_bool = getfn; @@ -12885,7 +12911,7 @@ int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val listAddNodeTail(module->module_configs, new_config); flags = maskModuleConfigFlags(flags); addModuleBoolConfig(module->name, name, flags, new_config, default_val); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* @@ -12907,20 +12933,20 @@ int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val * * int setEnumConfigCommand(const char *name, int val, void *privdata, const char **err) { * enum_val = val; - * return REDISMODULE_OK; + * return VALKEYMODULE_OK; * } * ... - * RedisModule_RegisterEnumConfig(ctx, "enum", 0, REDISMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 3, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL); + * ValkeyModule_RegisterEnumConfig(ctx, "enum", 0, VALKEYMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 3, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL); * - * Note that you can use REDISMODULE_CONFIG_BITFLAGS so that multiple enum string + * Note that you can use VALKEYMODULE_CONFIG_BITFLAGS so that multiple enum string * can be combined into one integer as bit flags, in which case you may want to * sort your enums so that the preferred combinations are present first. * - * See RedisModule_RegisterStringConfig for detailed general information about configs. */ -int RM_RegisterEnumConfig(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, RedisModuleConfigGetEnumFunc getfn, RedisModuleConfigSetEnumFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; + * See ValkeyModule_RegisterStringConfig for detailed general information about configs. */ +int VM_RegisterEnumConfig(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, ValkeyModuleConfigGetEnumFunc getfn, ValkeyModuleConfigSetEnumFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, ENUM_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_enum = getfn; @@ -12935,17 +12961,17 @@ int RM_RegisterEnumConfig(RedisModuleCtx *ctx, const char *name, int default_val listAddNodeTail(module->module_configs, new_config); flags = maskModuleConfigFlags(flags) | maskModuleEnumConfigFlags(flags); addModuleEnumConfig(module->name, name, flags, new_config, default_val, enum_vals); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* * Create an integer config that server clients can interact with via the * `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See - * RedisModule_RegisterStringConfig for detailed information about configs. */ -int RM_RegisterNumericConfig(RedisModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedisModuleConfigGetNumericFunc getfn, RedisModuleConfigSetNumericFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; + * ValkeyModule_RegisterStringConfig for detailed information about configs. */ +int VM_RegisterNumericConfig(ValkeyModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, ValkeyModuleConfigGetNumericFunc getfn, ValkeyModuleConfigSetNumericFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, NUMERIC_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_numeric = getfn; @@ -12954,54 +12980,54 @@ int RM_RegisterNumericConfig(RedisModuleCtx *ctx, const char *name, long long de unsigned int numeric_flags = maskModuleNumericConfigFlags(flags); flags = maskModuleConfigFlags(flags); addModuleNumericConfig(module->name, name, flags, new_config, default_val, numeric_flags, min, max); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Applies all pending configurations on the module load. This should be called - * after all of the configurations have been registered for the module inside of RedisModule_OnLoad. - * This will return REDISMODULE_ERR if it is called outside RedisModule_OnLoad. + * after all of the configurations have been registered for the module inside of ValkeyModule_OnLoad. + * This will return VALKEYMODULE_ERR if it is called outside ValkeyModule_OnLoad. * This API needs to be called when configurations are provided in either `MODULE LOADEX` * or provided as startup arguments. */ -int RM_LoadConfigs(RedisModuleCtx *ctx) { +int VM_LoadConfigs(ValkeyModuleCtx *ctx) { if (!ctx || !ctx->module || !ctx->module->onload) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - RedisModule *module = ctx->module; + ValkeyModule *module = ctx->module; /* Load configs from conf file or arguments from loadex */ - if (loadModuleConfigs(module)) return REDISMODULE_ERR; - return REDISMODULE_OK; + if (loadModuleConfigs(module)) return VALKEYMODULE_ERR; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- * ## RDB load/save API * -------------------------------------------------------------------------- */ -#define REDISMODULE_RDB_STREAM_FILE 1 +#define VALKEYMODULE_RDB_STREAM_FILE 1 -typedef struct RedisModuleRdbStream { +typedef struct ValkeyModuleRdbStream { int type; union { char *filename; } data; -} RedisModuleRdbStream; +} ValkeyModuleRdbStream; /* Create a stream object to save/load RDB to/from a file. * - * This function returns a pointer to RedisModuleRdbStream which is owned - * by the caller. It requires a call to RM_RdbStreamFree() to free + * This function returns a pointer to ValkeyModuleRdbStream which is owned + * by the caller. It requires a call to VM_RdbStreamFree() to free * the object. */ -RedisModuleRdbStream *RM_RdbStreamCreateFromFile(const char *filename) { - RedisModuleRdbStream *stream = zmalloc(sizeof(*stream)); - stream->type = REDISMODULE_RDB_STREAM_FILE; +ValkeyModuleRdbStream *VM_RdbStreamCreateFromFile(const char *filename) { + ValkeyModuleRdbStream *stream = zmalloc(sizeof(*stream)); + stream->type = VALKEYMODULE_RDB_STREAM_FILE; stream->data.filename = zstrdup(filename); return stream; } /* Release an RDB stream object. */ -void RM_RdbStreamFree(RedisModuleRdbStream *stream) { +void VM_RdbStreamFree(ValkeyModuleRdbStream *stream) { switch (stream->type) { - case REDISMODULE_RDB_STREAM_FILE: + case VALKEYMODULE_RDB_STREAM_FILE: zfree(stream->data.filename); break; default: @@ -13016,27 +13042,27 @@ void RM_RdbStreamFree(RedisModuleRdbStream *stream) { * * `flags` must be zero. This parameter is for future use. * - * On success REDISMODULE_OK is returned, otherwise REDISMODULE_ERR is returned + * On success VALKEYMODULE_OK is returned, otherwise VALKEYMODULE_ERR is returned * and errno is set accordingly. * * Example: * - * RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb"); - * RedisModule_RdbLoad(ctx, s, 0); - * RedisModule_RdbStreamFree(s); + * ValkeyModuleRdbStream *s = ValkeyModule_RdbStreamCreateFromFile("exp.rdb"); + * ValkeyModule_RdbLoad(ctx, s, 0); + * ValkeyModule_RdbStreamFree(s); */ -int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { +int VM_RdbLoad(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) { UNUSED(ctx); if (!stream || flags != 0) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Not allowed on replicas. */ if (server.masterhost != NULL) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Drop replicas if exist. */ @@ -13052,12 +13078,12 @@ int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { emptyData(-1,EMPTYDB_NO_FLAGS,NULL); /* rdbLoad() can go back to the networking and process network events. If - * RM_RdbLoad() is called inside a command callback, we don't want to + * VM_RdbLoad() is called inside a command callback, we don't want to * process the current client. Otherwise, we may free the client or try to * process next message while we are already in the command callback. */ if (server.current_client) protectClient(server.current_client); - serverAssert(stream->type == REDISMODULE_RDB_STREAM_FILE); + serverAssert(stream->type == VALKEYMODULE_RDB_STREAM_FILE); int ret = rdbLoad(stream->data.filename,NULL,RDBFLAGS_NONE); if (server.current_client) unprotectClient(server.current_client); @@ -13065,42 +13091,42 @@ int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { if (ret != RDB_OK) { errno = (ret == RDB_NOT_EXIST) ? ENOENT : EIO; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Save dataset to the RDB stream. * * `flags` must be zero. This parameter is for future use. * - * On success REDISMODULE_OK is returned, otherwise REDISMODULE_ERR is returned + * On success VALKEYMODULE_OK is returned, otherwise VALKEYMODULE_ERR is returned * and errno is set accordingly. * * Example: * - * RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb"); - * RedisModule_RdbSave(ctx, s, 0); - * RedisModule_RdbStreamFree(s); + * ValkeyModuleRdbStream *s = ValkeyModule_RdbStreamCreateFromFile("exp.rdb"); + * ValkeyModule_RdbSave(ctx, s, 0); + * ValkeyModule_RdbStreamFree(s); */ -int RM_RdbSave(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { +int VM_RdbSave(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) { UNUSED(ctx); if (!stream || flags != 0) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - serverAssert(stream->type == REDISMODULE_RDB_STREAM_FILE); + serverAssert(stream->type == VALKEYMODULE_RDB_STREAM_FILE); if (rdbSaveToFile(stream->data.filename) != C_OK) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Redis MODULE command. @@ -13150,7 +13176,7 @@ NULL } /* If this is a loadex command we want to populate server.module_configs_queue with * sds NAME VALUE pairs. We also want to increment argv to just after ARGS, if supplied. */ - if (parseLoadexArguments((RedisModuleString ***) &argv, &argc) == REDISMODULE_OK && + if (parseLoadexArguments((ValkeyModuleString ***) &argv, &argc) == VALKEYMODULE_OK && moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK) addReply(c,shared.ok); else { @@ -13187,52 +13213,52 @@ size_t moduleCount(void) { /* Set the key last access time for LRU based eviction. not relevant if the * servers's maxmemory policy is LFU based. Value is idle time in milliseconds. - * returns REDISMODULE_OK if the LRU was updated, REDISMODULE_ERR otherwise. */ -int RM_SetLRU(RedisModuleKey *key, mstime_t lru_idle) { + * returns VALKEYMODULE_OK if the LRU was updated, VALKEYMODULE_ERR otherwise. */ +int VM_SetLRU(ValkeyModuleKey *key, mstime_t lru_idle) { if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (objectSetLRUOrLFU(key->value, -1, lru_idle, lru_idle>=0 ? LRU_CLOCK() : 0, 1)) - return REDISMODULE_OK; - return REDISMODULE_ERR; + return VALKEYMODULE_OK; + return VALKEYMODULE_ERR; } /* Gets the key last access time. * Value is idletime in milliseconds or -1 if the server's eviction policy is * LFU based. - * returns REDISMODULE_OK if when key is valid. */ -int RM_GetLRU(RedisModuleKey *key, mstime_t *lru_idle) { + * returns VALKEYMODULE_OK if when key is valid. */ +int VM_GetLRU(ValkeyModuleKey *key, mstime_t *lru_idle) { *lru_idle = -1; if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) - return REDISMODULE_OK; + return VALKEYMODULE_OK; *lru_idle = estimateObjectIdleTime(key->value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Set the key access frequency. only relevant if the server's maxmemory policy * is LFU based. * The frequency is a logarithmic counter that provides an indication of * the access frequencyonly (must be <= 255). - * returns REDISMODULE_OK if the LFU was updated, REDISMODULE_ERR otherwise. */ -int RM_SetLFU(RedisModuleKey *key, long long lfu_freq) { + * returns VALKEYMODULE_OK if the LFU was updated, VALKEYMODULE_ERR otherwise. */ +int VM_SetLFU(ValkeyModuleKey *key, long long lfu_freq) { if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (objectSetLRUOrLFU(key->value, lfu_freq, -1, 0, 1)) - return REDISMODULE_OK; - return REDISMODULE_ERR; + return VALKEYMODULE_OK; + return VALKEYMODULE_ERR; } /* Gets the key access frequency or -1 if the server's eviction policy is not * LFU based. - * returns REDISMODULE_OK if when key is valid. */ -int RM_GetLFU(RedisModuleKey *key, long long *lfu_freq) { + * returns VALKEYMODULE_OK if when key is valid. */ +int VM_GetLFU(ValkeyModuleKey *key, long long *lfu_freq) { *lfu_freq = -1; if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) *lfu_freq = LFUDecrAndReturn(key->value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -13245,15 +13271,15 @@ int RM_GetLFU(RedisModuleKey *key, long long *lfu_freq) { * by the redis server version in use. * Example: * - * int supportedFlags = RM_GetModuleOptionsAll(); - * if (supportedFlags & REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS) { - * // REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is supported + * int supportedFlags = VM_GetModuleOptionsAll(); + * if (supportedFlags & VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS) { + * // VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is supported * } else{ - * // REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is not supported + * // VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is not supported * } */ -int RM_GetModuleOptionsAll(void) { - return _REDISMODULE_OPTIONS_FLAGS_NEXT - 1; +int VM_GetModuleOptionsAll(void) { + return _VALKEYMODULE_OPTIONS_FLAGS_NEXT - 1; } /** @@ -13262,15 +13288,15 @@ int RM_GetModuleOptionsAll(void) { * by the redis server version in use. * Example: * - * int supportedFlags = RM_GetContextFlagsAll(); - * if (supportedFlags & REDISMODULE_CTX_FLAGS_MULTI) { - * // REDISMODULE_CTX_FLAGS_MULTI is supported + * int supportedFlags = VM_GetContextFlagsAll(); + * if (supportedFlags & VALKEYMODULE_CTX_FLAGS_MULTI) { + * // VALKEYMODULE_CTX_FLAGS_MULTI is supported * } else{ - * // REDISMODULE_CTX_FLAGS_MULTI is not supported + * // VALKEYMODULE_CTX_FLAGS_MULTI is not supported * } */ -int RM_GetContextFlagsAll(void) { - return _REDISMODULE_CTX_FLAGS_NEXT - 1; +int VM_GetContextFlagsAll(void) { + return _VALKEYMODULE_CTX_FLAGS_NEXT - 1; } /** @@ -13279,32 +13305,32 @@ int RM_GetContextFlagsAll(void) { * by the redis server version in use. * Example: * - * int supportedFlags = RM_GetKeyspaceNotificationFlagsAll(); - * if (supportedFlags & REDISMODULE_NOTIFY_LOADED) { - * // REDISMODULE_NOTIFY_LOADED is supported + * int supportedFlags = VM_GetKeyspaceNotificationFlagsAll(); + * if (supportedFlags & VALKEYMODULE_NOTIFY_LOADED) { + * // VALKEYMODULE_NOTIFY_LOADED is supported * } else{ - * // REDISMODULE_NOTIFY_LOADED is not supported + * // VALKEYMODULE_NOTIFY_LOADED is not supported * } */ -int RM_GetKeyspaceNotificationFlagsAll(void) { - return _REDISMODULE_NOTIFY_NEXT - 1; +int VM_GetKeyspaceNotificationFlagsAll(void) { + return _VALKEYMODULE_NOTIFY_NEXT - 1; } /** * Return the redis version in format of 0x00MMmmpp. * Example for 6.0.7 the return value will be 0x00060007. */ -int RM_GetServerVersion(void) { +int VM_GetServerVersion(void) { return SERVER_VERSION_NUM; } /** - * Return the current redis-server runtime value of REDISMODULE_TYPE_METHOD_VERSION. - * You can use that when calling RM_CreateDataType to know which fields of - * RedisModuleTypeMethods are gonna be supported and which will be ignored. + * Return the current redis-server runtime value of VALKEYMODULE_TYPE_METHOD_VERSION. + * You can use that when calling VM_CreateDataType to know which fields of + * ValkeyModuleTypeMethods are gonna be supported and which will be ignored. */ -int RM_GetTypeMethodVersion(void) { - return REDISMODULE_TYPE_METHOD_VERSION; +int VM_GetTypeMethodVersion(void) { + return VALKEYMODULE_TYPE_METHOD_VERSION; } /* Replace the value assigned to a module type. @@ -13312,10 +13338,10 @@ int RM_GetTypeMethodVersion(void) { * The key must be open for writing, have an existing value, and have a moduleType * that matches the one specified by the caller. * - * Unlike RM_ModuleTypeSetValue() which will free the old value, this function + * Unlike VM_ModuleTypeSetValue() which will free the old value, this function * simply swaps the old value with the new value. * - * The function returns REDISMODULE_OK on success, REDISMODULE_ERR on errors + * The function returns VALKEYMODULE_OK on success, VALKEYMODULE_ERR on errors * such as: * * 1. Key is not opened for writing. @@ -13324,21 +13350,21 @@ int RM_GetTypeMethodVersion(void) { * * If old_value is non-NULL, the old value is returned by reference. */ -int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_value, void **old_value) { - if (!(key->mode & REDISMODULE_WRITE) || key->iter) - return REDISMODULE_ERR; +int VM_ModuleTypeReplaceValue(ValkeyModuleKey *key, moduleType *mt, void *new_value, void **old_value) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->iter) + return VALKEYMODULE_ERR; if (!key->value || key->value->type != OBJ_MODULE) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; moduleValue *mv = key->value->ptr; if (mv->type != mt) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (old_value) *old_value = mv->value; mv->value = new_value; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* For a specified command, parse its arguments and return an array that @@ -13346,7 +13372,7 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val * essentially a more efficient way to do `COMMAND GETKEYS`. * * The out_flags argument is optional, and can be set to NULL. - * When provided it is filled with REDISMODULE_CMD_KEY_ flags in matching + * When provided it is filled with VALKEYMODULE_CMD_KEY_ flags in matching * indexes with the key indexes of the returned array. * * A NULL return value indicates the specified command has no keys, or @@ -13358,10 +13384,10 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val * * NOTE: The returned array is not a Redis Module object so it does not * get automatically freed even when auto-memory is used. The caller - * must explicitly call RM_Free() to free it, same as the out_flags pointer if + * must explicitly call VM_Free() to free it, same as the out_flags pointer if * used. */ -int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) { +int *VM_GetCommandKeysWithFlags(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys, int **out_flags) { UNUSED(ctx); struct serverCommand *cmd; int *res = NULL; @@ -13407,13 +13433,13 @@ int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, i return res; } -/* Identical to RM_GetCommandKeysWithFlags when flags are not needed. */ -int *RM_GetCommandKeys(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) { - return RM_GetCommandKeysWithFlags(ctx, argv, argc, num_keys, NULL); +/* Identical to VM_GetCommandKeysWithFlags when flags are not needed. */ +int *VM_GetCommandKeys(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys) { + return VM_GetCommandKeysWithFlags(ctx, argv, argc, num_keys, NULL); } /* Return the name of the command currently running */ -const char *RM_GetCurrentCommandName(RedisModuleCtx *ctx) { +const char *VM_GetCurrentCommandName(ValkeyModuleCtx *ctx) { if (!ctx || !ctx->client || !ctx->client->cmd) return NULL; @@ -13427,7 +13453,7 @@ const char *RM_GetCurrentCommandName(RedisModuleCtx *ctx) { /* The defrag context, used to manage state during calls to the data type * defrag callback. */ -struct RedisModuleDefragCtx { +struct ValkeyModuleDefragCtx { long long int endtime; unsigned long *cursor; struct serverObject *key; /* Optional name of key processed, NULL when unknown. */ @@ -13437,9 +13463,9 @@ struct RedisModuleDefragCtx { /* Register a defrag callback for global data, i.e. anything that the module * may allocate that is not tied to a specific data type. */ -int RM_RegisterDefragFunc(RedisModuleCtx *ctx, RedisModuleDefragFunc cb) { +int VM_RegisterDefragFunc(ValkeyModuleCtx *ctx, ValkeyModuleDefragFunc cb) { ctx->module->defrag_cb = cb; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* When the data type defrag callback iterates complex structures, this @@ -13447,8 +13473,8 @@ int RM_RegisterDefragFunc(RedisModuleCtx *ctx, RedisModuleDefragFunc cb) { * indicates the callback may continue its work. A non-zero value (true) * indicates it should stop. * - * When stopped, the callback may use RM_DefragCursorSet() to store its - * position so it can later use RM_DefragCursorGet() to resume defragging. + * When stopped, the callback may use VM_DefragCursorSet() to store its + * position so it can later use VM_DefragCursorGet() to resume defragging. * * When stopped and more work is left to be done, the callback should * return 1. Otherwise, it should return 0. @@ -13456,13 +13482,13 @@ int RM_RegisterDefragFunc(RedisModuleCtx *ctx, RedisModuleDefragFunc cb) { * NOTE: Modules should consider the frequency in which this function is called, * so it generally makes sense to do small batches of work in between calls. */ -int RM_DefragShouldStop(RedisModuleDefragCtx *ctx) { +int VM_DefragShouldStop(ValkeyModuleDefragCtx *ctx) { return (ctx->endtime != 0 && ctx->endtime < ustime()); } /* Store an arbitrary cursor value for future re-use. * - * This should only be called if RM_DefragShouldStop() has returned a non-zero + * This should only be called if VM_DefragShouldStop() has returned a non-zero * value and the defrag callback is about to exit without fully iterating its * data type. * @@ -13473,7 +13499,7 @@ int RM_DefragShouldStop(RedisModuleDefragCtx *ctx) { * * Smaller keys, keys that do not implement `free_effort` or the global * defrag callback are not called in late-defrag mode. In those cases, a - * call to this function will return REDISMODULE_ERR. + * call to this function will return VALKEYMODULE_ERR. * * The cursor may be used by the module to represent some progress into the * module's data type. Modules may also store additional cursor-related @@ -13482,29 +13508,29 @@ int RM_DefragShouldStop(RedisModuleDefragCtx *ctx) { * a guarantee that concurrent defragmentation of multiple keys will * not be performed. */ -int RM_DefragCursorSet(RedisModuleDefragCtx *ctx, unsigned long cursor) { +int VM_DefragCursorSet(ValkeyModuleDefragCtx *ctx, unsigned long cursor) { if (!ctx->cursor) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; *ctx->cursor = cursor; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Fetch a cursor value that has been previously stored using RM_DefragCursorSet(). +/* Fetch a cursor value that has been previously stored using VM_DefragCursorSet(). * - * If not called for a late defrag operation, REDISMODULE_ERR will be returned and - * the cursor should be ignored. See RM_DefragCursorSet() for more details on + * If not called for a late defrag operation, VALKEYMODULE_ERR will be returned and + * the cursor should be ignored. See VM_DefragCursorSet() for more details on * defrag cursors. */ -int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) { +int VM_DefragCursorGet(ValkeyModuleDefragCtx *ctx, unsigned long *cursor) { if (!ctx->cursor) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; *cursor = *ctx->cursor; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Defrag a memory allocation previously allocated by RM_Alloc, RM_Calloc, etc. +/* Defrag a memory allocation previously allocated by VM_Alloc, VM_Calloc, etc. * The defragmentation process involves allocating a new memory block and copying * the contents to it, like realloc(). * @@ -13515,22 +13541,22 @@ int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) { * of the old one and update any reference to the old pointer, which must not * be used again. */ -void *RM_DefragAlloc(RedisModuleDefragCtx *ctx, void *ptr) { +void *VM_DefragAlloc(ValkeyModuleDefragCtx *ctx, void *ptr) { UNUSED(ctx); return activeDefragAlloc(ptr); } -/* Defrag a RedisModuleString previously allocated by RM_Alloc, RM_Calloc, etc. - * See RM_DefragAlloc() for more information on how the defragmentation process +/* Defrag a ValkeyModuleString previously allocated by VM_Alloc, VM_Calloc, etc. + * See VM_DefragAlloc() for more information on how the defragmentation process * works. * * NOTE: It is only possible to defrag strings that have a single reference. - * Typically this means strings retained with RM_RetainString or RM_HoldString + * Typically this means strings retained with VM_RetainString or VM_HoldString * may not be defragmentable. One exception is command argvs which, if retained * by the module, will end up with a single reference (because the reference * on the Redis side is dropped as soon as the command callback returns). */ -RedisModuleString *RM_DefragRedisModuleString(RedisModuleDefragCtx *ctx, RedisModuleString *str) { +ValkeyModuleString *VM_DefragModuleString(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) { UNUSED(ctx); return activeDefragStringOb(str); } @@ -13545,7 +13571,7 @@ int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long en moduleValue *mv = value->ptr; moduleType *mt = mv->type; - RedisModuleDefragCtx defrag_ctx = { endtime, cursor, key, dbid}; + ValkeyModuleDefragCtx defrag_ctx = { endtime, cursor, key, dbid}; /* Invoke callback. Note that the callback may be missing if the key has been * replaced with a different type since our last visit. @@ -13594,7 +13620,7 @@ int moduleDefragValue(robj *key, robj *value, int dbid) { return 0; /* Defrag later */ } - RedisModuleDefragCtx defrag_ctx = { 0, NULL, key, dbid }; + ValkeyModuleDefragCtx defrag_ctx = { 0, NULL, key, dbid }; mt->defrag(&defrag_ctx, key, &mv->value); return 1; } @@ -13605,10 +13631,10 @@ void moduleDefragGlobals(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); if (!module->defrag_cb) continue; - RedisModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; + ValkeyModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; module->defrag_cb(&defrag_ctx); } dictReleaseIterator(di); @@ -13617,14 +13643,14 @@ void moduleDefragGlobals(void) { /* Returns the name of the key currently being processed. * There is no guarantee that the key name is always available, so this may return NULL. */ -const RedisModuleString *RM_GetKeyNameFromDefragCtx(RedisModuleDefragCtx *ctx) { +const ValkeyModuleString *VM_GetKeyNameFromDefragCtx(ValkeyModuleDefragCtx *ctx) { return ctx->key; } /* Returns the database id of the key currently being processed. * There is no guarantee that this info is always available, so this may return -1. */ -int RM_GetDbIdFromDefragCtx(RedisModuleDefragCtx *ctx) { +int VM_GetDbIdFromDefragCtx(ValkeyModuleDefragCtx *ctx) { return ctx->dbid; } @@ -13972,7 +13998,7 @@ void moduleRegisterCoreAPI(void) { REGISTER_API(GetTypeMethodVersion); REGISTER_API(RegisterDefragFunc); REGISTER_API(DefragAlloc); - REGISTER_API(DefragRedisModuleString); + REGISTER_API(DefragModuleString); REGISTER_API(DefragShouldStop); REGISTER_API(DefragCursorSet); REGISTER_API(DefragCursorGet); diff --git a/src/modules/Makefile b/src/modules/Makefile index b9ef5786d1..ba8c3dc169 100644 --- a/src/modules/Makefile +++ b/src/modules/Makefile @@ -25,42 +25,42 @@ all: helloworld.so hellotype.so helloblock.so hellocluster.so hellotimer.so hell .c.xo: $(CC) -I. $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@ -helloworld.xo: ../redismodule.h +helloworld.xo: ../valkeymodule.h helloworld.so: helloworld.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellotype.xo: ../redismodule.h +hellotype.xo: ../valkeymodule.h hellotype.so: hellotype.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -helloblock.xo: ../redismodule.h +helloblock.xo: ../valkeymodule.h helloblock.so: helloblock.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lpthread -lc -hellocluster.xo: ../redismodule.h +hellocluster.xo: ../valkeymodule.h hellocluster.so: hellocluster.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellotimer.xo: ../redismodule.h +hellotimer.xo: ../valkeymodule.h hellotimer.so: hellotimer.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellodict.xo: ../redismodule.h +hellodict.xo: ../valkeymodule.h hellodict.so: hellodict.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellohook.xo: ../redismodule.h +hellohook.xo: ../valkeymodule.h hellohook.so: hellohook.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -helloacl.xo: ../redismodule.h +helloacl.xo: ../valkeymodule.h helloacl.so: helloacl.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc diff --git a/src/modules/helloacl.c b/src/modules/helloacl.c index 53f3a440c7..a7660afea3 100644 --- a/src/modules/helloacl.c +++ b/src/modules/helloacl.c @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include @@ -42,8 +42,8 @@ static uint64_t global_auth_client_id = 0; /* HELLOACL.REVOKE * Synchronously revoke access from a user. */ int RevokeCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); if (global_auth_client_id) { RedisModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id); @@ -56,8 +56,8 @@ int RevokeCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in /* HELLOACL.RESET * Synchronously delete and re-create a module user. */ int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_FreeModuleUser(global); global = RedisModule_CreateModuleUser("global"); @@ -71,16 +71,16 @@ int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int /* Callback handler for user changes, use this to notify a module of * changes to users authenticated by the module */ void HelloACL_UserChanged(uint64_t client_id, void *privdata) { - REDISMODULE_NOT_USED(privdata); - REDISMODULE_NOT_USED(client_id); + VALKEYMODULE_NOT_USED(privdata); + VALKEYMODULE_NOT_USED(client_id); global_auth_client_id = 0; } /* HELLOACL.AUTHGLOBAL * Synchronously assigns a module user to the current context. */ int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); if (global_auth_client_id) { return RedisModule_ReplyWithError(ctx, "Global user currently used"); @@ -95,15 +95,15 @@ int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv /* Reply callback for auth command HELLOACL.AUTHASYNC */ int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); size_t length; RedisModuleString *user_string = RedisModule_GetBlockedClientPrivateData(ctx); const char *name = RedisModule_StringPtrLen(user_string, &length); if (RedisModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) == - REDISMODULE_ERR) { + VALKEYMODULE_ERR) { return RedisModule_ReplyWithError(ctx, "Invalid Username or password"); } return RedisModule_ReplyWithSimpleString(ctx, "OK"); @@ -111,14 +111,14 @@ int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Timeout callback for auth command HELLOACL.AUTHASYNC */ int HelloACL_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); return RedisModule_ReplyWithSimpleString(ctx, "Request timedout"); } /* Private data frees data for HELLOACL.AUTHASYNC command. */ void HelloACL_FreeData(RedisModuleCtx *ctx, void *privdata) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); RedisModule_FreeString(NULL, privdata); } @@ -151,33 +151,33 @@ int AuthAsyncCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, return RedisModule_ReplyWithError(ctx, "-ERR Can't start thread"); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"helloacl",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"helloacl",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.reset", - ResetCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + ResetCommand_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.revoke", - RevokeCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + RevokeCommand_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.authglobal", - AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.authasync", - AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; global = RedisModule_CreateModuleUser("global"); RedisModule_SetModuleUserACL(global, "allcommands"); @@ -186,5 +186,5 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) global_auth_client_id = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/helloblock.c b/src/modules/helloblock.c index dc3d74975f..8c036bead5 100644 --- a/src/modules/helloblock.c +++ b/src/modules/helloblock.c @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -39,22 +39,22 @@ /* Reply callback for blocking command HELLO.BLOCK */ int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); int *myint = RedisModule_GetBlockedClientPrivateData(ctx); return RedisModule_ReplyWithLongLong(ctx,*myint); } /* Timeout callback for blocking command HELLO.BLOCK */ int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); return RedisModule_ReplyWithSimpleString(ctx,"Request timedout"); } /* Private data freeing callback for HELLO.BLOCK command. */ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); RedisModule_Free(privdata); } @@ -98,11 +98,11 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a long long delay; long long timeout; - if (RedisModule_StringToLongLong(argv[1],&delay) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[1],&delay) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); } - if (RedisModule_StringToLongLong(argv[2],&timeout) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[2],&timeout) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); } @@ -125,7 +125,7 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a RedisModule_AbortBlock(bc); return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread"); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* The thread entry point that actually executes the blocking part @@ -141,7 +141,7 @@ void *HelloKeys_ThreadMain(void *arg) { long long cursor = 0; size_t replylen = 0; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); do { RedisModule_ThreadSafeContextLock(ctx); RedisModuleCallReply *reply = RedisModule_Call(ctx, @@ -178,7 +178,7 @@ void *HelloKeys_ThreadMain(void *arg) { * that were in the database from the start to the end are guaranteed to be * there. */ int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argv); if (argc != 1) return RedisModule_WrongArity(ctx); pthread_t tid; @@ -195,24 +195,24 @@ int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int ar RedisModule_AbortBlock(bc); return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread"); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"helloblock",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"helloblock",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.block", - HelloBlock_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloBlock_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.keys", - HelloKeys_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloKeys_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellocluster.c b/src/modules/hellocluster.c index bc145c2b22..7a70332ada 100644 --- a/src/modules/hellocluster.c +++ b/src/modules/hellocluster.c @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -41,8 +41,8 @@ /* HELLOCLUSTER.PINGALL */ int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PING,"Hey",3); return RedisModule_ReplyWithSimpleString(ctx, "OK"); @@ -50,8 +50,8 @@ int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i /* HELLOCLUSTER.LIST */ int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); size_t numnodes; char **ids = RedisModule_GetClusterNodesList(ctx,&numnodes); @@ -64,17 +64,17 @@ int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int int port; RedisModule_GetClusterNodeInfo(ctx,ids[j],NULL,NULL,&port,NULL); RedisModule_ReplyWithArray(ctx,2); - RedisModule_ReplyWithStringBuffer(ctx,ids[j],REDISMODULE_NODE_ID_LEN); + RedisModule_ReplyWithStringBuffer(ctx,ids[j],VALKEYMODULE_NODE_ID_LEN); RedisModule_ReplyWithLongLong(ctx,port); } RedisModule_FreeClusterNodesList(ids); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Callback for message MSGTYPE_PING */ void PingReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) { RedisModule_Log(ctx,"notice","PING (type %d) RECEIVED from %.*s: '%.*s'", - type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload); + type,VALKEYMODULE_NODE_ID_LEN,sender_id,(int)len, payload); RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PONG,"Ohi!",4); RedisModuleCallReply *reply = RedisModule_Call(ctx, "INCR", "c", "pings_received"); RedisModule_FreeCallReply(reply); @@ -83,25 +83,25 @@ void PingReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, cons /* Callback for message MSGTYPE_PONG. */ void PongReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) { RedisModule_Log(ctx,"notice","PONG (type %d) RECEIVED from %.*s: '%.*s'", - type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload); + type,VALKEYMODULE_NODE_ID_LEN,sender_id,(int)len, payload); } /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellocluster",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellocluster",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellocluster.pingall", - PingallCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + PingallCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellocluster.list", - ListCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + ListCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; /* Disable Redis Cluster sharding and redirections. This way every node * will be able to access every possible key, regardless of the hash slot. @@ -109,10 +109,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) * variable. Normally you do that in order for the distributed system * you create as a module to have total freedom in the keyspace * manipulation. */ - RedisModule_SetClusterFlags(ctx,REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION); + RedisModule_SetClusterFlags(ctx,VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION); /* Register our handlers for different message types. */ RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PING,PingReceiver); RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PONG,PongReceiver); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellodict.c b/src/modules/hellodict.c index 12b6e91d25..6a6420b7d3 100644 --- a/src/modules/hellodict.c +++ b/src/modules/hellodict.c @@ -33,7 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -76,7 +76,7 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Parse the count argument. */ long long count; - if (RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); } @@ -88,10 +88,10 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { char *key; size_t keylen; long long replylen = 0; /* Keep track of the emitted array len. */ - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); while((key = RedisModule_DictNextC(iter,&keylen,NULL)) != NULL) { if (replylen >= count) break; - if (RedisModule_DictCompare(iter,"<=",argv[2]) == REDISMODULE_ERR) + if (RedisModule_DictCompare(iter,"<=",argv[2]) == VALKEYMODULE_ERR) break; RedisModule_ReplyWithStringBuffer(ctx,key,keylen); replylen++; @@ -100,32 +100,32 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Cleanup. */ RedisModule_DictIteratorStop(iter); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellodict",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellodict",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellodict.set", - cmd_SET,"write deny-oom",1,1,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + cmd_SET,"write deny-oom",1,1,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellodict.get", - cmd_GET,"readonly",1,1,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + cmd_GET,"readonly",1,1,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellodict.keyrange", - cmd_KEYRANGE,"readonly",1,1,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + cmd_KEYRANGE,"readonly",1,1,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; /* Create our global dictionary. Here we'll set our keys and values. */ Keyspace = RedisModule_CreateDict(NULL); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellohook.c b/src/modules/hellohook.c index 2859a8b26a..4b675891a2 100644 --- a/src/modules/hellohook.c +++ b/src/modules/hellohook.c @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -39,23 +39,23 @@ /* Client state change callback. */ void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) { - REDISMODULE_NOT_USED(ctx); - REDISMODULE_NOT_USED(e); + VALKEYMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(e); RedisModuleClientInfo *ci = data; printf("Client %s event for client #%llu %s:%d\n", - (sub == REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ? + (sub == VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ? "connection" : "disconnection", (unsigned long long)ci->id,ci->addr,ci->port); } void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) { - REDISMODULE_NOT_USED(ctx); - REDISMODULE_NOT_USED(e); + VALKEYMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(e); RedisModuleFlushInfo *fi = data; - if (sub == REDISMODULE_SUBEVENT_FLUSHDB_START) { + if (sub == VALKEYMODULE_SUBEVENT_FLUSHDB_START) { if (fi->dbnum != -1) { RedisModuleCallReply *reply; reply = RedisModule_Call(ctx,"DBSIZE",""); @@ -78,15 +78,15 @@ void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellohook",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellohook",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_ClientChange, clientChangeCallback); RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_FlushDB, flushdbCallback); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellotimer.c b/src/modules/hellotimer.c index 67e1e67143..d0ea4e14a9 100644 --- a/src/modules/hellotimer.c +++ b/src/modules/hellotimer.c @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -38,22 +38,22 @@ /* Timer callback. */ void timerHandler(RedisModuleCtx *ctx, void *data) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); printf("Fired %s!\n", (char *)data); RedisModule_Free(data); } /* HELLOTIMER.TIMER*/ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); for (int j = 0; j < 10; j++) { int delay = rand() % 5000; char *buf = RedisModule_Alloc(256); snprintf(buf,256,"After %d", delay); RedisModuleTimerID tid = RedisModule_CreateTimer(ctx,delay,timerHandler,buf); - REDISMODULE_NOT_USED(tid); + VALKEYMODULE_NOT_USED(tid); } return RedisModule_ReplyWithSimpleString(ctx, "OK"); } @@ -61,15 +61,15 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellotimer",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellotimer",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotimer.timer", - TimerCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + TimerCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellotype.c b/src/modules/hellotype.c index 1dc53d24c1..31ca35f6f5 100644 --- a/src/modules/hellotype.c +++ b/src/modules/hellotype.c @@ -35,7 +35,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -105,22 +105,22 @@ int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 3) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long value; - if ((RedisModule_StringToLongLong(argv[2],&value) != REDISMODULE_OK)) { + if ((RedisModule_StringToLongLong(argv[2],&value) != VALKEYMODULE_OK)) { return RedisModule_ReplyWithError(ctx,"ERR invalid value: must be a signed 64 bit integer"); } /* Create an empty value object if the key is currently empty. */ struct HelloTypeObject *hto; - if (type == REDISMODULE_KEYTYPE_EMPTY) { + if (type == VALKEYMODULE_KEYTYPE_EMPTY) { hto = createHelloTypeObject(); RedisModule_ModuleTypeSetValue(key,HelloType,hto); } else { @@ -133,7 +133,7 @@ int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_ReplyWithLongLong(ctx,hto->len); RedisModule_ReplicateVerbatim(ctx); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLOTYPE.RANGE key first count */ @@ -142,17 +142,17 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i if (argc != 4) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long first, count; - if (RedisModule_StringToLongLong(argv[2],&first) != REDISMODULE_OK || - RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK || + if (RedisModule_StringToLongLong(argv[2],&first) != VALKEYMODULE_OK || + RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK || first < 0 || count < 0) { return RedisModule_ReplyWithError(ctx, @@ -161,7 +161,7 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key); struct HelloTypeNode *node = hto ? hto->head : NULL; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); long long arraylen = 0; while(node && count--) { RedisModule_ReplyWithLongLong(ctx,node->value); @@ -169,7 +169,7 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i node = node->next; } RedisModule_ReplySetArrayLength(ctx,arraylen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLOTYPE.LEN key */ @@ -178,17 +178,17 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int if (argc != 2) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key); RedisModule_ReplyWithLongLong(ctx,hto ? hto->len : 0); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* ====================== Example of a blocking command ==================== */ @@ -197,17 +197,17 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int * called when the key we blocked for is ready: we need to check if we * can really serve the client, and reply OK or ERR accordingly. */ int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModuleString *keyname = RedisModule_GetBlockedClientReadyKey(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,REDISMODULE_READ); + RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,VALKEYMODULE_READ); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_MODULE || + if (type != VALKEYMODULE_KEYTYPE_MODULE || RedisModule_ModuleTypeGetType(key) != HelloType) { RedisModule_CloseKey(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* In case the key is able to serve our blocked client, let's directly @@ -218,14 +218,14 @@ int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Timeout callback for blocking command HELLOTYPE.BRANGE */ int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); return RedisModule_ReplyWithSimpleString(ctx,"Request timedout"); } /* Private data freeing callback for HELLOTYPE.BRANGE command. */ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); RedisModule_Free(privdata); } @@ -236,31 +236,31 @@ int HelloTypeBRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 5) return RedisModule_WrongArity(ctx); RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } /* Parse the timeout before even trying to serve the client synchronously, * so that we always fail ASAP on syntax errors. */ long long timeout; - if (RedisModule_StringToLongLong(argv[4],&timeout) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[4],&timeout) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx, "ERR invalid timeout parameter"); } /* Can we serve the reply synchronously? */ - if (type != REDISMODULE_KEYTYPE_EMPTY) { + if (type != VALKEYMODULE_KEYTYPE_EMPTY) { return HelloTypeRange_RedisCommand(ctx,argv,argc-1); } /* Otherwise let's block on the key. */ void *privdata = RedisModule_Alloc(100); RedisModule_BlockClientOnKeys(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout,argv+1,1,privdata); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* ========================== "hellotype" type methods ======================= */ @@ -323,14 +323,14 @@ void HelloTypeDigest(RedisModuleDigest *md, void *value) { /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellotype",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellotype",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; RedisModuleTypeMethods tm = { - .version = REDISMODULE_TYPE_METHOD_VERSION, + .version = VALKEYMODULE_TYPE_METHOD_VERSION, .rdb_load = HelloTypeRdbLoad, .rdb_save = HelloTypeRdbSave, .aof_rewrite = HelloTypeAofRewrite, @@ -340,23 +340,23 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) }; HelloType = RedisModule_CreateDataType(ctx,"hellotype",0,&tm); - if (HelloType == NULL) return REDISMODULE_ERR; + if (HelloType == NULL) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.insert", - HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.range", - HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.len", - HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeLen_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.brange", - HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeBRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index e517963101..658bcb3926 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -34,7 +34,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -46,10 +46,10 @@ * fetch the currently selected DB, the other in order to send the client * an integer reply as response. */ int HelloSimple_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_ReplyWithLongLong(ctx,RedisModule_GetSelectedDb(ctx)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.PUSH.NATIVE re-implements RPUSH, and shows the low level modules API @@ -63,13 +63,13 @@ int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 3) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); - RedisModule_ListPush(key,REDISMODULE_LIST_TAIL,argv[2]); + RedisModule_ListPush(key,VALKEYMODULE_LIST_TAIL,argv[2]); size_t newlen = RedisModule_ValueLength(key); RedisModule_CloseKey(key); RedisModule_ReplyWithLongLong(ctx,newlen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.PUSH.CALL implements RPUSH using an higher level approach, calling @@ -87,7 +87,7 @@ int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in long long len = RedisModule_CallReplyInteger(reply); RedisModule_FreeCallReply(reply); RedisModule_ReplyWithLongLong(ctx,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.PUSH.CALL2 @@ -102,7 +102,7 @@ int HelloPushCall2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); RedisModule_ReplyWithCallReply(ctx,reply); RedisModule_FreeCallReply(reply); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LIST.SUM.LEN returns the total length of all the items inside @@ -124,7 +124,7 @@ int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, } RedisModule_FreeCallReply(reply); RedisModule_ReplyWithLongLong(ctx,strlen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LIST.SPLICE srclist dstlist count @@ -135,23 +135,23 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 4) return RedisModule_WrongArity(ctx); RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); /* Src and dst key must be empty or lists. */ - if ((RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) || - (RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY)) + if ((RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_EMPTY) || + (RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_EMPTY)) { RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long count; - if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + if ((RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) || (count < 0)) { RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); @@ -161,9 +161,9 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, while(count-- > 0) { RedisModuleString *ele; - ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL); + ele = RedisModule_ListPop(srckey,VALKEYMODULE_LIST_TAIL); if (ele == NULL) break; - RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); + RedisModule_ListPush(dstkey,VALKEYMODULE_LIST_HEAD,ele); RedisModule_FreeString(ctx,ele); } @@ -171,7 +171,7 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); RedisModule_ReplyWithLongLong(ctx,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Like the HELLO.LIST.SPLICE above, but uses automatic memory management @@ -182,21 +182,21 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar RedisModule_AutoMemory(ctx); RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); /* Src and dst key must be empty or lists. */ - if ((RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) || - (RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY)) + if ((RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_EMPTY) || + (RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_EMPTY)) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long count; - if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + if ((RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) || (count < 0)) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); @@ -205,14 +205,14 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar while(count-- > 0) { RedisModuleString *ele; - ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL); + ele = RedisModule_ListPop(srckey,VALKEYMODULE_LIST_TAIL); if (ele == NULL) break; - RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); + RedisModule_ListPush(dstkey,VALKEYMODULE_LIST_HEAD,ele); } size_t len = RedisModule_ValueLength(srckey); RedisModule_ReplyWithLongLong(ctx,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.RAND.ARRAY @@ -221,7 +221,7 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (argc != 2) return RedisModule_WrongArity(ctx); long long count; - if (RedisModule_StringToLongLong(argv[1],&count) != REDISMODULE_OK || + if (RedisModule_StringToLongLong(argv[1],&count) != VALKEYMODULE_OK || count < 0) return RedisModule_ReplyWithError(ctx,"ERR invalid count"); @@ -230,7 +230,7 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i * the elements of the array. */ RedisModule_ReplyWithArray(ctx,count); while(count--) RedisModule_ReplyWithLongLong(ctx,rand()); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is a simple command to test replication. Because of the "!" modified @@ -239,8 +239,8 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i * comments the function implementation). */ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_AutoMemory(ctx); /* This will be replicated *after* the two INCR statements, since @@ -262,7 +262,7 @@ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a RedisModule_ReplyWithLongLong(ctx,0); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Another command to show replication. In this case, we call @@ -280,27 +280,27 @@ int HelloRepl2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST) - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_LIST) + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); size_t listlen = RedisModule_ValueLength(key); long long sum = 0; /* Rotate and increment. */ while(listlen--) { - RedisModuleString *ele = RedisModule_ListPop(key,REDISMODULE_LIST_TAIL); + RedisModuleString *ele = RedisModule_ListPop(key,VALKEYMODULE_LIST_TAIL); long long val; - if (RedisModule_StringToLongLong(ele,&val) != REDISMODULE_OK) val = 0; + if (RedisModule_StringToLongLong(ele,&val) != VALKEYMODULE_OK) val = 0; val++; sum += val; RedisModuleString *newele = RedisModule_CreateStringFromLongLong(ctx,val); - RedisModule_ListPush(key,REDISMODULE_LIST_HEAD,newele); + RedisModule_ListPush(key,VALKEYMODULE_LIST_HEAD,newele); } RedisModule_ReplyWithLongLong(ctx,sum); RedisModule_ReplicateVerbatim(ctx); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is an example of strings DMA access. Given a key containing a string @@ -315,19 +315,19 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 2) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int keytype = RedisModule_KeyType(key); - if (keytype != REDISMODULE_KEYTYPE_STRING && - keytype != REDISMODULE_KEYTYPE_EMPTY) + if (keytype != VALKEYMODULE_KEYTYPE_STRING && + keytype != VALKEYMODULE_KEYTYPE_EMPTY) { RedisModule_CloseKey(key); - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } - if (keytype == REDISMODULE_KEYTYPE_STRING) { + if (keytype == VALKEYMODULE_KEYTYPE_STRING) { size_t len, j; - char *s = RedisModule_StringDMA(key,&len,REDISMODULE_WRITE); + char *s = RedisModule_StringDMA(key,&len,VALKEYMODULE_WRITE); for (j = 0; j < len; j++) { if (isupper(s[j])) { s[j] = tolower(s[j]); @@ -340,7 +340,7 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_CloseKey(key); RedisModule_ReplyWithSimpleString(ctx,"OK"); RedisModule_ReplicateVerbatim(ctx); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.MORE.EXPIRE key milliseconds. @@ -353,13 +353,13 @@ int HelloMoreExpire_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, mstime_t addms, expire; - if (RedisModule_StringToLongLong(argv[2],&addms) != REDISMODULE_OK) + if (RedisModule_StringToLongLong(argv[2],&addms) != VALKEYMODULE_OK) return RedisModule_ReplyWithError(ctx,"ERR invalid expire time"); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); expire = RedisModule_GetExpire(key); - if (expire != REDISMODULE_NO_EXPIRE) { + if (expire != VALKEYMODULE_NO_EXPIRE) { expire += addms; RedisModule_SetExpire(key,expire); } @@ -376,16 +376,16 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i double score_start, score_end; if (argc != 4) return RedisModule_WrongArity(ctx); - if (RedisModule_StringToDouble(argv[2],&score_start) != REDISMODULE_OK || - RedisModule_StringToDouble(argv[3],&score_end) != REDISMODULE_OK) + if (RedisModule_StringToDouble(argv[2],&score_start) != VALKEYMODULE_OK || + RedisModule_StringToDouble(argv[3],&score_end) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid range"); } RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); + if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_ZSET) { + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } double scoresum_a = 0; @@ -417,7 +417,7 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i RedisModule_ReplyWithArray(ctx,2); RedisModule_ReplyWithDouble(ctx,scoresum_a); RedisModule_ReplyWithDouble(ctx,scoresum_b); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LEXRANGE key min_lex max_lex min_age max_age @@ -433,17 +433,17 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in if (argc != 6) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); + if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_ZSET) { + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } - if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDISMODULE_OK) { + if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"invalid range"); } int arraylen = 0; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); while(!RedisModule_ZsetRangeEndReached(key)) { double score; RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(key,&score); @@ -455,7 +455,7 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in RedisModule_ZsetRangeStop(key); RedisModule_ReplySetArrayLength(ctx,arraylen); RedisModule_CloseKey(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.HCOPY key srcfield dstfield @@ -470,22 +470,22 @@ int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a if (argc != 4) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_HASH && - type != REDISMODULE_KEYTYPE_EMPTY) + if (type != VALKEYMODULE_KEYTYPE_HASH && + type != VALKEYMODULE_KEYTYPE_EMPTY) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } /* Get the old field value. */ RedisModuleString *oldval; - RedisModule_HashGet(key,REDISMODULE_HASH_NONE,argv[2],&oldval,NULL); + RedisModule_HashGet(key,VALKEYMODULE_HASH_NONE,argv[2],&oldval,NULL); if (oldval) { - RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[3],oldval,NULL); + RedisModule_HashSet(key,VALKEYMODULE_HASH_NONE,argv[3],oldval,NULL); } RedisModule_ReplyWithLongLong(ctx,oldval != NULL); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LEFTPAD str len ch @@ -512,7 +512,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int if (argc != 4) return RedisModule_WrongArity(ctx); - if ((RedisModule_StringToLongLong(argv[2],&padlen) != REDISMODULE_OK) || + if ((RedisModule_StringToLongLong(argv[2],&padlen) != VALKEYMODULE_OK) || (padlen< 0)) { return RedisModule_ReplyWithError(ctx,"ERR invalid padding length"); } @@ -537,14 +537,14 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int memcpy(buf+padlen,str,strlen); RedisModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { - if (RedisModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"helloworld",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; /* Log the list of parameters passing loading the module. */ for (int j = 0; j < argc; j++) { @@ -553,69 +553,69 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) } if (RedisModule_CreateCommand(ctx,"hello.simple", - HelloSimple_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloSimple_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.push.native", - HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.push.call", - HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.push.call2", - HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.list.sum.len", - HelloListSumLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloListSumLen_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.list.splice", - HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.list.splice.auto", HelloListSpliceAuto_RedisCommand, - "write deny-oom",1,2,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + "write deny-oom",1,2,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.rand.array", - HelloRandArray_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloRandArray_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.repl1", - HelloRepl1_RedisCommand,"write",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloRepl1_RedisCommand,"write",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.repl2", - HelloRepl2_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloRepl2_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.toggle.case", - HelloToggleCase_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloToggleCase_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.more.expire", - HelloMoreExpire_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloMoreExpire_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.zsumrange", - HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloZsumRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.lexrange", - HelloLexRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloLexRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.hcopy", - HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.leftpad", - HelloLeftPad_RedisCommand,"",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloLeftPad_RedisCommand,"",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/networking.c b/src/networking.c index 0adbfeb452..e8998dc1ad 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1309,8 +1309,8 @@ void clientAcceptHandler(connection *conn) { } server.stat_numconnections++; - moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE, - REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_CLIENT_CHANGE, + VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED, c); } @@ -1574,8 +1574,8 @@ void freeClient(client *c) { /* For connected clients, call the disconnection event of modules hooks. */ if (c->conn) { - moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE, - REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_CLIENT_CHANGE, + VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED, c); } @@ -1695,8 +1695,8 @@ void freeClient(client *c) { refreshGoodSlavesCount(); /* Fire the replica change modules event. */ if (c->replstate == SLAVE_STATE_ONLINE) - moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, - REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, + VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE, NULL); } diff --git a/src/rdb.c b/src/rdb.c index 052d780d02..1c922d31bb 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1079,7 +1079,7 @@ ssize_t rdbSaveObject(rio *rdb, robj *o, robj *key, int dbid) { } } else if (o->type == OBJ_MODULE) { /* Save a module-specific value. */ - RedisModuleIO io; + ValkeyModuleIO io; moduleValue *mv = o->ptr; moduleType *mt = mv->type; @@ -1217,7 +1217,7 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) { /* Save a module-specific aux value. */ - RedisModuleIO io; + ValkeyModuleIO io; int retval = 0; moduleInitIOContext(io,mt,rdb,NULL,-1); @@ -1397,7 +1397,7 @@ int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) { snprintf(magic,sizeof(magic),"REDIS%04d",RDB_VERSION); if (rdbWriteRaw(rdb,magic,9) == -1) goto werr; if (rdbSaveInfoAuxFields(rdb,rdbflags,rsi) == -1) goto werr; - if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, REDISMODULE_AUX_BEFORE_RDB) == -1) goto werr; + if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, VALKEYMODULE_AUX_BEFORE_RDB) == -1) goto werr; /* save functions */ if (!(req & SLAVE_REQ_RDB_EXCLUDE_FUNCTIONS) && rdbSaveFunctions(rdb) == -1) goto werr; @@ -1409,7 +1409,7 @@ int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) { } } - if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, REDISMODULE_AUX_AFTER_RDB) == -1) goto werr; + if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, VALKEYMODULE_AUX_AFTER_RDB) == -1) goto werr; /* EOF opcode */ if (rdbSaveType(rdb,RDB_OPCODE_EOF) == -1) goto werr; @@ -2814,7 +2814,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) { rdbReportCorruptRDB("The RDB file contains module data I can't load: no matching module type '%s'", name); return NULL; } - RedisModuleIO io; + ValkeyModuleIO io; robj keyobj; initStaticStringObject(keyobj,key); moduleInitIOContext(io,mt,rdb,&keyobj,dbid); @@ -2881,12 +2881,12 @@ void startLoading(size_t size, int rdbflags, int async) { /* Fire the loading modules start event. */ int subevent; if (rdbflags & RDBFLAGS_AOF_PREAMBLE) - subevent = REDISMODULE_SUBEVENT_LOADING_AOF_START; + subevent = VALKEYMODULE_SUBEVENT_LOADING_AOF_START; else if(rdbflags & RDBFLAGS_REPLICATION) - subevent = REDISMODULE_SUBEVENT_LOADING_REPL_START; + subevent = VALKEYMODULE_SUBEVENT_LOADING_REPL_START; else - subevent = REDISMODULE_SUBEVENT_LOADING_RDB_START; - moduleFireServerEvent(REDISMODULE_EVENT_LOADING,subevent,NULL); + subevent = VALKEYMODULE_SUBEVENT_LOADING_RDB_START; + moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING,subevent,NULL); } /* Mark that we are loading in the global state and setup the fields @@ -2924,10 +2924,10 @@ void stopLoading(int success) { rdbFileBeingLoaded = NULL; /* Fire the loading modules end event. */ - moduleFireServerEvent(REDISMODULE_EVENT_LOADING, + moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING, success? - REDISMODULE_SUBEVENT_LOADING_ENDED: - REDISMODULE_SUBEVENT_LOADING_FAILED, + VALKEYMODULE_SUBEVENT_LOADING_ENDED: + VALKEYMODULE_SUBEVENT_LOADING_FAILED, NULL); } @@ -2935,22 +2935,22 @@ void startSaving(int rdbflags) { /* Fire the persistence modules start event. */ int subevent; if (rdbflags & RDBFLAGS_AOF_PREAMBLE && getpid() != server.pid) - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START; + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START; else if (rdbflags & RDBFLAGS_AOF_PREAMBLE) - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START; + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START; else if (getpid()!=server.pid) - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START; + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START; else - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START; - moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE,subevent,NULL); + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START; + moduleFireServerEvent(VALKEYMODULE_EVENT_PERSISTENCE,subevent,NULL); } void stopSaving(int success) { /* Fire the persistence modules end event. */ - moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE, + moduleFireServerEvent(VALKEYMODULE_EVENT_PERSISTENCE, success? - REDISMODULE_SUBEVENT_PERSISTENCE_ENDED: - REDISMODULE_SUBEVENT_PERSISTENCE_FAILED, + VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED: + VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED, NULL); } @@ -3224,7 +3224,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin exit(1); } - RedisModuleIO io; + ValkeyModuleIO io; moduleInitIOContext(io,mt,rdb,NULL,-1); /* Call the rdb_load method of the module providing the 10 bit * encoding version in the lower 10 bits of the module ID. */ @@ -3233,7 +3233,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin moduleFreeContext(io.ctx); zfree(io.ctx); } - if (rc != REDISMODULE_OK || io.error) { + if (rc != VALKEYMODULE_OK || io.error) { moduleTypeNameByID(name,moduleid); serverLog(LL_WARNING,"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.", name); goto eoferr; diff --git a/src/redismodule.h b/src/redismodule.h index 8b5d2beb65..f9ecaf5868 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -1,1695 +1,723 @@ -#ifndef REDISMODULE_H -#define REDISMODULE_H - -#include -#include -#include -#include - - -typedef struct RedisModuleString RedisModuleString; -typedef struct RedisModuleKey RedisModuleKey; - -/* -------------- Defines NOT common between core and modules ------------- */ - -#if defined REDISMODULE_CORE -/* Things only defined for the modules core (server), not exported to modules - * that include this file. */ - -#define RedisModuleString robj - -#endif /* defined REDISMODULE_CORE */ - -#if !defined REDISMODULE_CORE && !defined REDISMODULE_CORE_MODULE -/* Things defined for modules, but not for core-modules. */ - -typedef long long mstime_t; -typedef long long ustime_t; - -#endif /* !defined REDISMODULE_CORE && !defined REDISMODULE_CORE_MODULE */ - -/* ---------------- Defines common between core and modules --------------- */ - -/* Error status return values. */ -#define REDISMODULE_OK 0 -#define REDISMODULE_ERR 1 - -/* Module Based Authentication status return values. */ -#define REDISMODULE_AUTH_HANDLED 0 -#define REDISMODULE_AUTH_NOT_HANDLED 1 - -/* API versions. */ -#define REDISMODULE_APIVER_1 1 - -/* Version of the RedisModuleTypeMethods structure. Once the RedisModuleTypeMethods - * structure is changed, this version number needs to be changed synchronistically. */ -#define REDISMODULE_TYPE_METHOD_VERSION 5 - -/* API flags and constants */ -#define REDISMODULE_READ (1<<0) -#define REDISMODULE_WRITE (1<<1) - -/* RedisModule_OpenKey extra flags for the 'mode' argument. - * Avoid touching the LRU/LFU of the key when opened. */ -#define REDISMODULE_OPEN_KEY_NOTOUCH (1<<16) -/* Don't trigger keyspace event on key misses. */ -#define REDISMODULE_OPEN_KEY_NONOTIFY (1<<17) -/* Don't update keyspace hits/misses counters. */ -#define REDISMODULE_OPEN_KEY_NOSTATS (1<<18) -/* Avoid deleting lazy expired keys. */ -#define REDISMODULE_OPEN_KEY_NOEXPIRE (1<<19) -/* Avoid any effects from fetching the key */ -#define REDISMODULE_OPEN_KEY_NOEFFECTS (1<<20) -/* Mask of all REDISMODULE_OPEN_KEY_* values. Any new mode should be added to this list. - * Should not be used directly by the module, use RM_GetOpenKeyModesAll instead. - * Located here so when we will add new modes we will not forget to update it. */ -#define _REDISMODULE_OPEN_KEY_ALL REDISMODULE_READ | REDISMODULE_WRITE | REDISMODULE_OPEN_KEY_NOTOUCH | REDISMODULE_OPEN_KEY_NONOTIFY | REDISMODULE_OPEN_KEY_NOSTATS | REDISMODULE_OPEN_KEY_NOEXPIRE | REDISMODULE_OPEN_KEY_NOEFFECTS - -/* List push and pop */ -#define REDISMODULE_LIST_HEAD 0 -#define REDISMODULE_LIST_TAIL 1 - -/* Key types. */ -#define REDISMODULE_KEYTYPE_EMPTY 0 -#define REDISMODULE_KEYTYPE_STRING 1 -#define REDISMODULE_KEYTYPE_LIST 2 -#define REDISMODULE_KEYTYPE_HASH 3 -#define REDISMODULE_KEYTYPE_SET 4 -#define REDISMODULE_KEYTYPE_ZSET 5 -#define REDISMODULE_KEYTYPE_MODULE 6 -#define REDISMODULE_KEYTYPE_STREAM 7 - -/* Reply types. */ -#define REDISMODULE_REPLY_UNKNOWN -1 -#define REDISMODULE_REPLY_STRING 0 -#define REDISMODULE_REPLY_ERROR 1 -#define REDISMODULE_REPLY_INTEGER 2 -#define REDISMODULE_REPLY_ARRAY 3 -#define REDISMODULE_REPLY_NULL 4 -#define REDISMODULE_REPLY_MAP 5 -#define REDISMODULE_REPLY_SET 6 -#define REDISMODULE_REPLY_BOOL 7 -#define REDISMODULE_REPLY_DOUBLE 8 -#define REDISMODULE_REPLY_BIG_NUMBER 9 -#define REDISMODULE_REPLY_VERBATIM_STRING 10 -#define REDISMODULE_REPLY_ATTRIBUTE 11 -#define REDISMODULE_REPLY_PROMISE 12 - -/* Postponed array length. */ -#define REDISMODULE_POSTPONED_ARRAY_LEN -1 /* Deprecated, please use REDISMODULE_POSTPONED_LEN */ -#define REDISMODULE_POSTPONED_LEN -1 - -/* Expire */ -#define REDISMODULE_NO_EXPIRE -1 - -/* Sorted set API flags. */ -#define REDISMODULE_ZADD_XX (1<<0) -#define REDISMODULE_ZADD_NX (1<<1) -#define REDISMODULE_ZADD_ADDED (1<<2) -#define REDISMODULE_ZADD_UPDATED (1<<3) -#define REDISMODULE_ZADD_NOP (1<<4) -#define REDISMODULE_ZADD_GT (1<<5) -#define REDISMODULE_ZADD_LT (1<<6) - -/* Hash API flags. */ -#define REDISMODULE_HASH_NONE 0 -#define REDISMODULE_HASH_NX (1<<0) -#define REDISMODULE_HASH_XX (1<<1) -#define REDISMODULE_HASH_CFIELDS (1<<2) -#define REDISMODULE_HASH_EXISTS (1<<3) -#define REDISMODULE_HASH_COUNT_ALL (1<<4) - -#define REDISMODULE_CONFIG_DEFAULT 0 /* This is the default for a module config. */ -#define REDISMODULE_CONFIG_IMMUTABLE (1ULL<<0) /* Can this value only be set at startup? */ -#define REDISMODULE_CONFIG_SENSITIVE (1ULL<<1) /* Does this value contain sensitive information */ -#define REDISMODULE_CONFIG_HIDDEN (1ULL<<4) /* This config is hidden in `config get ` (used for tests/debugging) */ -#define REDISMODULE_CONFIG_PROTECTED (1ULL<<5) /* Becomes immutable if enable-protected-configs is enabled. */ -#define REDISMODULE_CONFIG_DENY_LOADING (1ULL<<6) /* This config is forbidden during loading. */ - -#define REDISMODULE_CONFIG_MEMORY (1ULL<<7) /* Indicates if this value can be set as a memory value */ -#define REDISMODULE_CONFIG_BITFLAGS (1ULL<<8) /* Indicates if this value can be set as a multiple enum values */ - -/* StreamID type. */ -typedef struct RedisModuleStreamID { - uint64_t ms; - uint64_t seq; -} RedisModuleStreamID; - -/* StreamAdd() flags. */ -#define REDISMODULE_STREAM_ADD_AUTOID (1<<0) -/* StreamIteratorStart() flags. */ -#define REDISMODULE_STREAM_ITERATOR_EXCLUSIVE (1<<0) -#define REDISMODULE_STREAM_ITERATOR_REVERSE (1<<1) -/* StreamIteratorTrim*() flags. */ -#define REDISMODULE_STREAM_TRIM_APPROX (1<<0) - -/* Context Flags: Info about the current context returned by - * RM_GetContextFlags(). */ - -/* The command is running in the context of a Lua script */ -#define REDISMODULE_CTX_FLAGS_LUA (1<<0) -/* The command is running inside a Redis transaction */ -#define REDISMODULE_CTX_FLAGS_MULTI (1<<1) -/* The instance is a master */ -#define REDISMODULE_CTX_FLAGS_MASTER (1<<2) -/* The instance is a slave */ -#define REDISMODULE_CTX_FLAGS_SLAVE (1<<3) -/* The instance is read-only (usually meaning it's a slave as well) */ -#define REDISMODULE_CTX_FLAGS_READONLY (1<<4) -/* The instance is running in cluster mode */ -#define REDISMODULE_CTX_FLAGS_CLUSTER (1<<5) -/* The instance has AOF enabled */ -#define REDISMODULE_CTX_FLAGS_AOF (1<<6) -/* The instance has RDB enabled */ -#define REDISMODULE_CTX_FLAGS_RDB (1<<7) -/* The instance has Maxmemory set */ -#define REDISMODULE_CTX_FLAGS_MAXMEMORY (1<<8) -/* Maxmemory is set and has an eviction policy that may delete keys */ -#define REDISMODULE_CTX_FLAGS_EVICT (1<<9) -/* Redis is out of memory according to the maxmemory flag. */ -#define REDISMODULE_CTX_FLAGS_OOM (1<<10) -/* Less than 25% of memory available according to maxmemory. */ -#define REDISMODULE_CTX_FLAGS_OOM_WARNING (1<<11) -/* The command was sent over the replication link. */ -#define REDISMODULE_CTX_FLAGS_REPLICATED (1<<12) -/* Redis is currently loading either from AOF or RDB. */ -#define REDISMODULE_CTX_FLAGS_LOADING (1<<13) -/* The replica has no link with its master, note that - * there is the inverse flag as well: +/* + * RedisModule Compatibility Header - Snapshot for Redis 7.2.4 * - * REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE + * This header file facilitates backward compatibility for existing Redis modules + * by mapping legacy REDISMODULE_* prefixed macros and identifiers to their + * new equivalents prefixed with VALKEYMODULE_*. It acts as an adapter allowing + * modules written for the older REDISMODULE API to compile and function correctly + * with the newer VALKEYMODULE API without requiring source code changes. New modules + * should be developed using "valkeymodule.h" instead. * - * The two flags are exclusive, one or the other can be set. */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE (1<<14) -/* The replica is trying to connect with the master. - * (REPL_STATE_CONNECT and REPL_STATE_CONNECTING states) */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING (1<<15) -/* THe replica is receiving an RDB file from its master. */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING (1<<16) -/* The replica is online, receiving updates from its master. */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE (1<<17) -/* There is currently some background process active. */ -#define REDISMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18) -/* The next EXEC will fail due to dirty CAS (touched keys). */ -#define REDISMODULE_CTX_FLAGS_MULTI_DIRTY (1<<19) -/* Redis is currently running inside background child process. */ -#define REDISMODULE_CTX_FLAGS_IS_CHILD (1<<20) -/* The current client does not allow blocking, either called from - * within multi, lua, or from another module using RM_Call */ -#define REDISMODULE_CTX_FLAGS_DENY_BLOCKING (1<<21) -/* The current client uses RESP3 protocol */ -#define REDISMODULE_CTX_FLAGS_RESP3 (1<<22) -/* Redis is currently async loading database for diskless replication. */ -#define REDISMODULE_CTX_FLAGS_ASYNC_LOADING (1<<23) -/* Redis is starting. */ -#define REDISMODULE_CTX_FLAGS_SERVER_STARTUP (1<<24) - -/* Next context flag, must be updated when adding new flags above! -This flag should not be used directly by the module. - * Use RedisModule_GetContextFlagsAll instead. */ -#define _REDISMODULE_CTX_FLAGS_NEXT (1<<25) - -/* Keyspace changes notification classes. Every class is associated with a - * character for configuration purposes. - * NOTE: These have to be in sync with NOTIFY_* in server.h */ -#define REDISMODULE_NOTIFY_KEYSPACE (1<<0) /* K */ -#define REDISMODULE_NOTIFY_KEYEVENT (1<<1) /* E */ -#define REDISMODULE_NOTIFY_GENERIC (1<<2) /* g */ -#define REDISMODULE_NOTIFY_STRING (1<<3) /* $ */ -#define REDISMODULE_NOTIFY_LIST (1<<4) /* l */ -#define REDISMODULE_NOTIFY_SET (1<<5) /* s */ -#define REDISMODULE_NOTIFY_HASH (1<<6) /* h */ -#define REDISMODULE_NOTIFY_ZSET (1<<7) /* z */ -#define REDISMODULE_NOTIFY_EXPIRED (1<<8) /* x */ -#define REDISMODULE_NOTIFY_EVICTED (1<<9) /* e */ -#define REDISMODULE_NOTIFY_STREAM (1<<10) /* t */ -#define REDISMODULE_NOTIFY_KEY_MISS (1<<11) /* m (Note: This one is excluded from REDISMODULE_NOTIFY_ALL on purpose) */ -#define REDISMODULE_NOTIFY_LOADED (1<<12) /* module only key space notification, indicate a key loaded from rdb */ -#define REDISMODULE_NOTIFY_MODULE (1<<13) /* d, module key space notification */ -#define REDISMODULE_NOTIFY_NEW (1<<14) /* n, new key notification */ - -/* Next notification flag, must be updated when adding new flags above! -This flag should not be used directly by the module. - * Use RedisModule_GetKeyspaceNotificationFlagsAll instead. */ -#define _REDISMODULE_NOTIFY_NEXT (1<<15) - -#define REDISMODULE_NOTIFY_ALL (REDISMODULE_NOTIFY_GENERIC | REDISMODULE_NOTIFY_STRING | REDISMODULE_NOTIFY_LIST | REDISMODULE_NOTIFY_SET | REDISMODULE_NOTIFY_HASH | REDISMODULE_NOTIFY_ZSET | REDISMODULE_NOTIFY_EXPIRED | REDISMODULE_NOTIFY_EVICTED | REDISMODULE_NOTIFY_STREAM | REDISMODULE_NOTIFY_MODULE) /* A */ - -/* A special pointer that we can use between the core and the module to signal - * field deletion, and that is impossible to be a valid pointer. */ -#define REDISMODULE_HASH_DELETE ((RedisModuleString*)(long)1) - -/* Error messages. */ -#define REDISMODULE_ERRORMSG_WRONGTYPE "WRONGTYPE Operation against a key holding the wrong kind of value" - -#define REDISMODULE_POSITIVE_INFINITE (1.0/0.0) -#define REDISMODULE_NEGATIVE_INFINITE (-1.0/0.0) - -/* Cluster API defines. */ -#define REDISMODULE_NODE_ID_LEN 40 -#define REDISMODULE_NODE_MYSELF (1<<0) -#define REDISMODULE_NODE_MASTER (1<<1) -#define REDISMODULE_NODE_SLAVE (1<<2) -#define REDISMODULE_NODE_PFAIL (1<<3) -#define REDISMODULE_NODE_FAIL (1<<4) -#define REDISMODULE_NODE_NOFAILOVER (1<<5) - -#define REDISMODULE_CLUSTER_FLAG_NONE 0 -#define REDISMODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1) -#define REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2) - -#define REDISMODULE_NOT_USED(V) ((void) V) - -/* Logging level strings */ -#define REDISMODULE_LOGLEVEL_DEBUG "debug" -#define REDISMODULE_LOGLEVEL_VERBOSE "verbose" -#define REDISMODULE_LOGLEVEL_NOTICE "notice" -#define REDISMODULE_LOGLEVEL_WARNING "warning" - -/* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */ -#define REDISMODULE_AUX_BEFORE_RDB (1<<0) -#define REDISMODULE_AUX_AFTER_RDB (1<<1) - -/* RM_Yield flags */ -#define REDISMODULE_YIELD_FLAG_NONE (1<<0) -#define REDISMODULE_YIELD_FLAG_CLIENTS (1<<1) - -/* RM_BlockClientOnKeysWithFlags flags */ -#define REDISMODULE_BLOCK_UNBLOCK_DEFAULT (0) -#define REDISMODULE_BLOCK_UNBLOCK_DELETED (1<<0) - -/* This type represents a timer handle, and is returned when a timer is - * registered and used in order to invalidate a timer. It's just a 64 bit - * number, because this is how each timer is represented inside the radix tree - * of timers that are going to expire, sorted by expire time. */ -typedef uint64_t RedisModuleTimerID; - -/* CommandFilter Flags */ - -/* Do filter RedisModule_Call() commands initiated by module itself. */ -#define REDISMODULE_CMDFILTER_NOSELF (1<<0) - -/* Declare that the module can handle errors with RedisModule_SetModuleOptions. */ -#define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0) - -/* When set, Redis will not call RedisModule_SignalModifiedKey(), implicitly in - * RedisModule_CloseKey, and the module needs to do that when manually when keys - * are modified from the user's perspective, to invalidate WATCH. */ -#define REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED (1<<1) - -/* Declare that the module can handle diskless async replication with RedisModule_SetModuleOptions. */ -#define REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD (1<<2) - -/* Declare that the module want to get nested key space notifications. - * If enabled, the module is responsible to break endless loop. */ -#define REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS (1<<3) - -/* Next option flag, must be updated when adding new module flags above! - * This flag should not be used directly by the module. - * Use RedisModule_GetModuleOptionsAll instead. */ -#define _REDISMODULE_OPTIONS_FLAGS_NEXT (1<<4) - -/* Definitions for RedisModule_SetCommandInfo. */ - -typedef enum { - REDISMODULE_ARG_TYPE_STRING, - REDISMODULE_ARG_TYPE_INTEGER, - REDISMODULE_ARG_TYPE_DOUBLE, - REDISMODULE_ARG_TYPE_KEY, /* A string, but represents a keyname */ - REDISMODULE_ARG_TYPE_PATTERN, - REDISMODULE_ARG_TYPE_UNIX_TIME, - REDISMODULE_ARG_TYPE_PURE_TOKEN, - REDISMODULE_ARG_TYPE_ONEOF, /* Must have sub-arguments */ - REDISMODULE_ARG_TYPE_BLOCK /* Must have sub-arguments */ -} RedisModuleCommandArgType; - -#define REDISMODULE_CMD_ARG_NONE (0) -#define REDISMODULE_CMD_ARG_OPTIONAL (1<<0) /* The argument is optional (like GET in SET command) */ -#define REDISMODULE_CMD_ARG_MULTIPLE (1<<1) /* The argument may repeat itself (like key in DEL) */ -#define REDISMODULE_CMD_ARG_MULTIPLE_TOKEN (1<<2) /* The argument may repeat itself, and so does its token (like `GET pattern` in SORT) */ -#define _REDISMODULE_CMD_ARG_NEXT (1<<3) - -typedef enum { - REDISMODULE_KSPEC_BS_INVALID = 0, /* Must be zero. An implicitly value of - * zero is provided when the field is - * absent in a struct literal. */ - REDISMODULE_KSPEC_BS_UNKNOWN, - REDISMODULE_KSPEC_BS_INDEX, - REDISMODULE_KSPEC_BS_KEYWORD -} RedisModuleKeySpecBeginSearchType; - -typedef enum { - REDISMODULE_KSPEC_FK_OMITTED = 0, /* Used when the field is absent in a - * struct literal. Don't use this value - * explicitly. */ - REDISMODULE_KSPEC_FK_UNKNOWN, - REDISMODULE_KSPEC_FK_RANGE, - REDISMODULE_KSPEC_FK_KEYNUM -} RedisModuleKeySpecFindKeysType; - -/* Key-spec flags. For details, see the documentation of - * RedisModule_SetCommandInfo and the key-spec flags in server.h. */ -#define REDISMODULE_CMD_KEY_RO (1ULL<<0) -#define REDISMODULE_CMD_KEY_RW (1ULL<<1) -#define REDISMODULE_CMD_KEY_OW (1ULL<<2) -#define REDISMODULE_CMD_KEY_RM (1ULL<<3) -#define REDISMODULE_CMD_KEY_ACCESS (1ULL<<4) -#define REDISMODULE_CMD_KEY_UPDATE (1ULL<<5) -#define REDISMODULE_CMD_KEY_INSERT (1ULL<<6) -#define REDISMODULE_CMD_KEY_DELETE (1ULL<<7) -#define REDISMODULE_CMD_KEY_NOT_KEY (1ULL<<8) -#define REDISMODULE_CMD_KEY_INCOMPLETE (1ULL<<9) -#define REDISMODULE_CMD_KEY_VARIABLE_FLAGS (1ULL<<10) - -/* Channel flags, for details see the documentation of - * RedisModule_ChannelAtPosWithFlags. */ -#define REDISMODULE_CMD_CHANNEL_PATTERN (1ULL<<0) -#define REDISMODULE_CMD_CHANNEL_PUBLISH (1ULL<<1) -#define REDISMODULE_CMD_CHANNEL_SUBSCRIBE (1ULL<<2) -#define REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE (1ULL<<3) - -typedef struct RedisModuleCommandArg { - const char *name; - RedisModuleCommandArgType type; - int key_spec_index; /* If type is KEY, this is a zero-based index of - * the key_spec in the command. For other types, - * you may specify -1. */ - const char *token; /* If type is PURE_TOKEN, this is the token. */ - const char *summary; - const char *since; - int flags; /* The REDISMODULE_CMD_ARG_* macros. */ - const char *deprecated_since; - struct RedisModuleCommandArg *subargs; - const char *display_text; -} RedisModuleCommandArg; - -typedef struct { - const char *since; - const char *changes; -} RedisModuleCommandHistoryEntry; - -typedef struct { - const char *notes; - uint64_t flags; /* REDISMODULE_CMD_KEY_* macros. */ - RedisModuleKeySpecBeginSearchType begin_search_type; - union { - struct { - /* The index from which we start the search for keys */ - int pos; - } index; - struct { - /* The keyword that indicates the beginning of key args */ - const char *keyword; - /* An index in argv from which to start searching. - * Can be negative, which means start search from the end, in reverse - * (Example: -2 means to start in reverse from the penultimate arg) */ - int startfrom; - } keyword; - } bs; - RedisModuleKeySpecFindKeysType find_keys_type; - union { - struct { - /* Index of the last key relative to the result of the begin search - * step. Can be negative, in which case it's not relative. -1 - * indicating till the last argument, -2 one before the last and so - * on. */ - int lastkey; - /* How many args should we skip after finding a key, in order to - * find the next one. */ - int keystep; - /* If lastkey is -1, we use limit to stop the search by a factor. 0 - * and 1 mean no limit. 2 means 1/2 of the remaining args, 3 means - * 1/3, and so on. */ - int limit; - } range; - struct { - /* Index of the argument containing the number of keys to come - * relative to the result of the begin search step */ - int keynumidx; - /* Index of the fist key. (Usually it's just after keynumidx, in - * which case it should be set to keynumidx + 1.) */ - int firstkey; - /* How many args should we skip after finding a key, in order to - * find the next one, relative to the result of the begin search - * step. */ - int keystep; - } keynum; - } fk; -} RedisModuleCommandKeySpec; - -typedef struct { - int version; - size_t sizeof_historyentry; - size_t sizeof_keyspec; - size_t sizeof_arg; -} RedisModuleCommandInfoVersion; - -static const RedisModuleCommandInfoVersion RedisModule_CurrentCommandInfoVersion = { - .version = 1, - .sizeof_historyentry = sizeof(RedisModuleCommandHistoryEntry), - .sizeof_keyspec = sizeof(RedisModuleCommandKeySpec), - .sizeof_arg = sizeof(RedisModuleCommandArg) -}; - -#define REDISMODULE_COMMAND_INFO_VERSION (&RedisModule_CurrentCommandInfoVersion) - -typedef struct { - /* Always set version to REDISMODULE_COMMAND_INFO_VERSION */ - const RedisModuleCommandInfoVersion *version; - /* Version 1 fields (added in Redis 7.0.0) */ - const char *summary; /* Summary of the command */ - const char *complexity; /* Complexity description */ - const char *since; /* Debut module version of the command */ - RedisModuleCommandHistoryEntry *history; /* History */ - /* A string of space-separated tips meant for clients/proxies regarding this - * command */ - const char *tips; - /* Number of arguments, it is possible to use -N to say >= N */ - int arity; - RedisModuleCommandKeySpec *key_specs; - RedisModuleCommandArg *args; -} RedisModuleCommandInfo; - -/* Eventloop definitions. */ -#define REDISMODULE_EVENTLOOP_READABLE 1 -#define REDISMODULE_EVENTLOOP_WRITABLE 2 -typedef void (*RedisModuleEventLoopFunc)(int fd, void *user_data, int mask); -typedef void (*RedisModuleEventLoopOneShotFunc)(void *user_data); - -/* Server events definitions. - * Those flags should not be used directly by the module, instead - * the module should use RedisModuleEvent_* variables. - * Note: This must be synced with moduleEventVersions */ -#define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED 0 -#define REDISMODULE_EVENT_PERSISTENCE 1 -#define REDISMODULE_EVENT_FLUSHDB 2 -#define REDISMODULE_EVENT_LOADING 3 -#define REDISMODULE_EVENT_CLIENT_CHANGE 4 -#define REDISMODULE_EVENT_SHUTDOWN 5 -#define REDISMODULE_EVENT_REPLICA_CHANGE 6 -#define REDISMODULE_EVENT_MASTER_LINK_CHANGE 7 -#define REDISMODULE_EVENT_CRON_LOOP 8 -#define REDISMODULE_EVENT_MODULE_CHANGE 9 -#define REDISMODULE_EVENT_LOADING_PROGRESS 10 -#define REDISMODULE_EVENT_SWAPDB 11 -#define REDISMODULE_EVENT_REPL_BACKUP 12 /* Deprecated since Redis 7.0, not used anymore. */ -#define REDISMODULE_EVENT_FORK_CHILD 13 -#define REDISMODULE_EVENT_REPL_ASYNC_LOAD 14 -#define REDISMODULE_EVENT_EVENTLOOP 15 -#define REDISMODULE_EVENT_CONFIG 16 -#define REDISMODULE_EVENT_KEY 17 -#define _REDISMODULE_EVENT_NEXT 18 /* Next event flag, should be updated if a new event added. */ - -typedef struct RedisModuleEvent { - uint64_t id; /* REDISMODULE_EVENT_... defines. */ - uint64_t dataver; /* Version of the structure we pass as 'data'. */ -} RedisModuleEvent; - -struct RedisModuleCtx; -struct RedisModuleDefragCtx; -typedef void (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModuleEvent eid, uint64_t subevent, void *data); - -/* IMPORTANT: When adding a new version of one of below structures that contain - * event data (RedisModuleFlushInfoV1 for example) we have to avoid renaming the - * old RedisModuleEvent structure. - * For example, if we want to add RedisModuleFlushInfoV2, the RedisModuleEvent - * structures should be: - * RedisModuleEvent_FlushDB = { - * REDISMODULE_EVENT_FLUSHDB, - * 1 - * }, - * RedisModuleEvent_FlushDBV2 = { - * REDISMODULE_EVENT_FLUSHDB, - * 2 - * } - * and NOT: - * RedisModuleEvent_FlushDBV1 = { - * REDISMODULE_EVENT_FLUSHDB, - * 1 - * }, - * RedisModuleEvent_FlushDB = { - * REDISMODULE_EVENT_FLUSHDB, - * 2 - * } - * The reason for that is forward-compatibility: We want that module that - * compiled with a new redismodule.h to be able to work with a old server, - * unless the author explicitly decided to use the newer event type. - */ -static const RedisModuleEvent - RedisModuleEvent_ReplicationRoleChanged = { - REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, - 1 - }, - RedisModuleEvent_Persistence = { - REDISMODULE_EVENT_PERSISTENCE, - 1 - }, - RedisModuleEvent_FlushDB = { - REDISMODULE_EVENT_FLUSHDB, - 1 - }, - RedisModuleEvent_Loading = { - REDISMODULE_EVENT_LOADING, - 1 - }, - RedisModuleEvent_ClientChange = { - REDISMODULE_EVENT_CLIENT_CHANGE, - 1 - }, - RedisModuleEvent_Shutdown = { - REDISMODULE_EVENT_SHUTDOWN, - 1 - }, - RedisModuleEvent_ReplicaChange = { - REDISMODULE_EVENT_REPLICA_CHANGE, - 1 - }, - RedisModuleEvent_CronLoop = { - REDISMODULE_EVENT_CRON_LOOP, - 1 - }, - RedisModuleEvent_MasterLinkChange = { - REDISMODULE_EVENT_MASTER_LINK_CHANGE, - 1 - }, - RedisModuleEvent_ModuleChange = { - REDISMODULE_EVENT_MODULE_CHANGE, - 1 - }, - RedisModuleEvent_LoadingProgress = { - REDISMODULE_EVENT_LOADING_PROGRESS, - 1 - }, - RedisModuleEvent_SwapDB = { - REDISMODULE_EVENT_SWAPDB, - 1 - }, - /* Deprecated since Redis 7.0, not used anymore. */ - __attribute__ ((deprecated)) - RedisModuleEvent_ReplBackup = { - REDISMODULE_EVENT_REPL_BACKUP, - 1 - }, - RedisModuleEvent_ReplAsyncLoad = { - REDISMODULE_EVENT_REPL_ASYNC_LOAD, - 1 - }, - RedisModuleEvent_ForkChild = { - REDISMODULE_EVENT_FORK_CHILD, - 1 - }, - RedisModuleEvent_EventLoop = { - REDISMODULE_EVENT_EVENTLOOP, - 1 - }, - RedisModuleEvent_Config = { - REDISMODULE_EVENT_CONFIG, - 1 - }, - RedisModuleEvent_Key = { - REDISMODULE_EVENT_KEY, - 1 - }; - -/* Those are values that are used for the 'subevent' callback argument. */ -#define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START 0 -#define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START 1 -#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START 2 -#define REDISMODULE_SUBEVENT_PERSISTENCE_ENDED 3 -#define REDISMODULE_SUBEVENT_PERSISTENCE_FAILED 4 -#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START 5 -#define _REDISMODULE_SUBEVENT_PERSISTENCE_NEXT 6 - -#define REDISMODULE_SUBEVENT_LOADING_RDB_START 0 -#define REDISMODULE_SUBEVENT_LOADING_AOF_START 1 -#define REDISMODULE_SUBEVENT_LOADING_REPL_START 2 -#define REDISMODULE_SUBEVENT_LOADING_ENDED 3 -#define REDISMODULE_SUBEVENT_LOADING_FAILED 4 -#define _REDISMODULE_SUBEVENT_LOADING_NEXT 5 - -#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED 0 -#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED 1 -#define _REDISMODULE_SUBEVENT_CLIENT_CHANGE_NEXT 2 - -#define REDISMODULE_SUBEVENT_MASTER_LINK_UP 0 -#define REDISMODULE_SUBEVENT_MASTER_LINK_DOWN 1 -#define _REDISMODULE_SUBEVENT_MASTER_NEXT 2 - -#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE 0 -#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE 1 -#define _REDISMODULE_SUBEVENT_REPLICA_CHANGE_NEXT 2 - -#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER 0 -#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA 1 -#define _REDISMODULE_EVENT_REPLROLECHANGED_NEXT 2 - -#define REDISMODULE_SUBEVENT_FLUSHDB_START 0 -#define REDISMODULE_SUBEVENT_FLUSHDB_END 1 -#define _REDISMODULE_SUBEVENT_FLUSHDB_NEXT 2 - -#define REDISMODULE_SUBEVENT_MODULE_LOADED 0 -#define REDISMODULE_SUBEVENT_MODULE_UNLOADED 1 -#define _REDISMODULE_SUBEVENT_MODULE_NEXT 2 - -#define REDISMODULE_SUBEVENT_CONFIG_CHANGE 0 -#define _REDISMODULE_SUBEVENT_CONFIG_NEXT 1 - -#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB 0 -#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF 1 -#define _REDISMODULE_SUBEVENT_LOADING_PROGRESS_NEXT 2 - -/* Replication Backup events are deprecated since Redis 7.0 and are never fired. */ -#define REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE 0 -#define REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE 1 -#define REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD 2 -#define _REDISMODULE_SUBEVENT_REPL_BACKUP_NEXT 3 - -#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED 0 -#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED 1 -#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED 2 -#define _REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT 3 - -#define REDISMODULE_SUBEVENT_FORK_CHILD_BORN 0 -#define REDISMODULE_SUBEVENT_FORK_CHILD_DIED 1 -#define _REDISMODULE_SUBEVENT_FORK_CHILD_NEXT 2 - -#define REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP 0 -#define REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP 1 -#define _REDISMODULE_SUBEVENT_EVENTLOOP_NEXT 2 - -#define REDISMODULE_SUBEVENT_KEY_DELETED 0 -#define REDISMODULE_SUBEVENT_KEY_EXPIRED 1 -#define REDISMODULE_SUBEVENT_KEY_EVICTED 2 -#define REDISMODULE_SUBEVENT_KEY_OVERWRITTEN 3 -#define _REDISMODULE_SUBEVENT_KEY_NEXT 4 - -#define _REDISMODULE_SUBEVENT_SHUTDOWN_NEXT 0 -#define _REDISMODULE_SUBEVENT_CRON_LOOP_NEXT 0 -#define _REDISMODULE_SUBEVENT_SWAPDB_NEXT 0 - -/* RedisModuleClientInfo flags. */ -#define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0) -#define REDISMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1) -#define REDISMODULE_CLIENTINFO_FLAG_BLOCKED (1<<2) -#define REDISMODULE_CLIENTINFO_FLAG_TRACKING (1<<3) -#define REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET (1<<4) -#define REDISMODULE_CLIENTINFO_FLAG_MULTI (1<<5) - -/* Here we take all the structures that the module pass to the core - * and the other way around. Notably the list here contains the structures - * used by the hooks API RedisModule_RegisterToServerEvent(). + * Important Note: + * This file represents a snapshot of the Redis module interfaces as they existed + * in Redis 7.2.4. Compatibility with future Redis versions is not guaranteed. + * + * Usage: + * Include this header in Redis modules that originally depend on the older + * REDISMODULE_* definitions. This file should be included instead of + * directly including valkeymodule.h to ensure the legacy code recognizes + * the new Valkey module interfaces. * - * The structures always start with a 'version' field. This is useful - * when we want to pass a reference to the structure to the core APIs, - * for the APIs to fill the structure. In that case, the structure 'version' - * field is initialized before passing it to the core, so that the core is - * able to cast the pointer to the appropriate structure version. In this - * way we obtain ABI compatibility. + * Example: + * #include "redismodule.h" * - * Here we'll list all the structure versions in case they evolve over time, - * however using a define, we'll make sure to use the last version as the - * public name for the module to use. */ - -#define REDISMODULE_CLIENTINFO_VERSION 1 -typedef struct RedisModuleClientInfo { - uint64_t version; /* Version of this structure for ABI compat. */ - uint64_t flags; /* REDISMODULE_CLIENTINFO_FLAG_* */ - uint64_t id; /* Client ID. */ - char addr[46]; /* IPv4 or IPv6 address. */ - uint16_t port; /* TCP port. */ - uint16_t db; /* Selected DB. */ -} RedisModuleClientInfoV1; - -#define RedisModuleClientInfo RedisModuleClientInfoV1 - -#define REDISMODULE_CLIENTINFO_INITIALIZER_V1 { .version = 1 } - -#define REDISMODULE_REPLICATIONINFO_VERSION 1 -typedef struct RedisModuleReplicationInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - int master; /* true if master, false if replica */ - char *masterhost; /* master instance hostname for NOW_REPLICA */ - int masterport; /* master instance port for NOW_REPLICA */ - char *replid1; /* Main replication ID */ - char *replid2; /* Secondary replication ID */ - uint64_t repl1_offset; /* Main replication offset */ - uint64_t repl2_offset; /* Offset of replid2 validity */ -} RedisModuleReplicationInfoV1; - -#define RedisModuleReplicationInfo RedisModuleReplicationInfoV1 - -#define REDISMODULE_FLUSHINFO_VERSION 1 -typedef struct RedisModuleFlushInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - int32_t sync; /* Synchronous or threaded flush?. */ - int32_t dbnum; /* Flushed database number, -1 for ALL. */ -} RedisModuleFlushInfoV1; - -#define RedisModuleFlushInfo RedisModuleFlushInfoV1 - -#define REDISMODULE_MODULE_CHANGE_VERSION 1 -typedef struct RedisModuleModuleChange { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - const char* module_name;/* Name of module loaded or unloaded. */ - int32_t module_version; /* Module version. */ -} RedisModuleModuleChangeV1; - -#define RedisModuleModuleChange RedisModuleModuleChangeV1 - -#define REDISMODULE_CONFIGCHANGE_VERSION 1 -typedef struct RedisModuleConfigChange { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - uint32_t num_changes; /* how many redis config options were changed */ - const char **config_names; /* the config names that were changed */ -} RedisModuleConfigChangeV1; - -#define RedisModuleConfigChange RedisModuleConfigChangeV1 - -#define REDISMODULE_CRON_LOOP_VERSION 1 -typedef struct RedisModuleCronLoopInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - int32_t hz; /* Approximate number of events per second. */ -} RedisModuleCronLoopV1; - -#define RedisModuleCronLoop RedisModuleCronLoopV1 - -#define REDISMODULE_LOADING_PROGRESS_VERSION 1 -typedef struct RedisModuleLoadingProgressInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - int32_t hz; /* Approximate number of events per second. */ - int32_t progress; /* Approximate progress between 0 and 1024, or -1 - * if unknown. */ -} RedisModuleLoadingProgressV1; - -#define RedisModuleLoadingProgress RedisModuleLoadingProgressV1 - -#define REDISMODULE_SWAPDBINFO_VERSION 1 -typedef struct RedisModuleSwapDbInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - int32_t dbnum_first; /* Swap Db first dbnum */ - int32_t dbnum_second; /* Swap Db second dbnum */ -} RedisModuleSwapDbInfoV1; - -#define RedisModuleSwapDbInfo RedisModuleSwapDbInfoV1 - -#define REDISMODULE_KEYINFO_VERSION 1 -typedef struct RedisModuleKeyInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - RedisModuleKey *key; /* Opened key. */ -} RedisModuleKeyInfoV1; - -#define RedisModuleKeyInfo RedisModuleKeyInfoV1 - -typedef enum { - REDISMODULE_ACL_LOG_AUTH = 0, /* Authentication failure */ - REDISMODULE_ACL_LOG_CMD, /* Command authorization failure */ - REDISMODULE_ACL_LOG_KEY, /* Key authorization failure */ - REDISMODULE_ACL_LOG_CHANNEL /* Channel authorization failure */ -} RedisModuleACLLogEntryReason; - -/* Incomplete structures needed by both the core and modules. */ -typedef struct RedisModuleIO RedisModuleIO; -typedef struct RedisModuleDigest RedisModuleDigest; -typedef struct RedisModuleInfoCtx RedisModuleInfoCtx; -typedef struct RedisModuleDefragCtx RedisModuleDefragCtx; - -/* Function pointers needed by both the core and modules, these needs to be - * exposed since you can't cast a function pointer to (void *). */ -typedef void (*RedisModuleInfoFunc)(RedisModuleInfoCtx *ctx, int for_crash_report); -typedef void (*RedisModuleDefragFunc)(RedisModuleDefragCtx *ctx); -typedef void (*RedisModuleUserChangedFunc) (uint64_t client_id, void *privdata); - -/* ------------------------- End of common defines ------------------------ */ - -/* ----------- The rest of the defines are only for modules ----------------- */ -#if !defined REDISMODULE_CORE || defined REDISMODULE_CORE_MODULE -/* Things defined for modules and core-modules. */ - -/* Macro definitions specific to individual compilers */ -#ifndef REDISMODULE_ATTR_UNUSED -# ifdef __GNUC__ -# define REDISMODULE_ATTR_UNUSED __attribute__((unused)) -# else -# define REDISMODULE_ATTR_UNUSED -# endif -#endif - -#ifndef REDISMODULE_ATTR_PRINTF -# ifdef __GNUC__ -# define REDISMODULE_ATTR_PRINTF(idx,cnt) __attribute__((format(printf,idx,cnt))) -# else -# define REDISMODULE_ATTR_PRINTF(idx,cnt) -# endif -#endif - -#ifndef REDISMODULE_ATTR_COMMON -# if defined(__GNUC__) && !(defined(__clang__) && defined(__cplusplus)) -# define REDISMODULE_ATTR_COMMON __attribute__((__common__)) -# else -# define REDISMODULE_ATTR_COMMON -# endif -#endif - -/* Incomplete structures for compiler checks but opaque access. */ -typedef struct RedisModuleCtx RedisModuleCtx; -typedef struct RedisModuleCommand RedisModuleCommand; -typedef struct RedisModuleCallReply RedisModuleCallReply; -typedef struct RedisModuleType RedisModuleType; -typedef struct RedisModuleBlockedClient RedisModuleBlockedClient; -typedef struct RedisModuleClusterInfo RedisModuleClusterInfo; -typedef struct RedisModuleDict RedisModuleDict; -typedef struct RedisModuleDictIter RedisModuleDictIter; -typedef struct RedisModuleCommandFilterCtx RedisModuleCommandFilterCtx; -typedef struct RedisModuleCommandFilter RedisModuleCommandFilter; -typedef struct RedisModuleServerInfoData RedisModuleServerInfoData; -typedef struct RedisModuleScanCursor RedisModuleScanCursor; -typedef struct RedisModuleUser RedisModuleUser; -typedef struct RedisModuleKeyOptCtx RedisModuleKeyOptCtx; -typedef struct RedisModuleRdbStream RedisModuleRdbStream; - -typedef int (*RedisModuleCmdFunc)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc); -typedef void (*RedisModuleDisconnectFunc)(RedisModuleCtx *ctx, RedisModuleBlockedClient *bc); -typedef int (*RedisModuleNotificationFunc)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key); -typedef void (*RedisModulePostNotificationJobFunc) (RedisModuleCtx *ctx, void *pd); -typedef void *(*RedisModuleTypeLoadFunc)(RedisModuleIO *rdb, int encver); -typedef void (*RedisModuleTypeSaveFunc)(RedisModuleIO *rdb, void *value); -typedef int (*RedisModuleTypeAuxLoadFunc)(RedisModuleIO *rdb, int encver, int when); -typedef void (*RedisModuleTypeAuxSaveFunc)(RedisModuleIO *rdb, int when); -typedef void (*RedisModuleTypeRewriteFunc)(RedisModuleIO *aof, RedisModuleString *key, void *value); -typedef size_t (*RedisModuleTypeMemUsageFunc)(const void *value); -typedef size_t (*RedisModuleTypeMemUsageFunc2)(RedisModuleKeyOptCtx *ctx, const void *value, size_t sample_size); -typedef void (*RedisModuleTypeDigestFunc)(RedisModuleDigest *digest, void *value); -typedef void (*RedisModuleTypeFreeFunc)(void *value); -typedef size_t (*RedisModuleTypeFreeEffortFunc)(RedisModuleString *key, const void *value); -typedef size_t (*RedisModuleTypeFreeEffortFunc2)(RedisModuleKeyOptCtx *ctx, const void *value); -typedef void (*RedisModuleTypeUnlinkFunc)(RedisModuleString *key, const void *value); -typedef void (*RedisModuleTypeUnlinkFunc2)(RedisModuleKeyOptCtx *ctx, const void *value); -typedef void *(*RedisModuleTypeCopyFunc)(RedisModuleString *fromkey, RedisModuleString *tokey, const void *value); -typedef void *(*RedisModuleTypeCopyFunc2)(RedisModuleKeyOptCtx *ctx, const void *value); -typedef int (*RedisModuleTypeDefragFunc)(RedisModuleDefragCtx *ctx, RedisModuleString *key, void **value); -typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); -typedef void (*RedisModuleTimerProc)(RedisModuleCtx *ctx, void *data); -typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter); -typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); -typedef void (*RedisModuleScanCB)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata); -typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata); -typedef RedisModuleString * (*RedisModuleConfigGetStringFunc)(const char *name, void *privdata); -typedef long long (*RedisModuleConfigGetNumericFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetBoolFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetEnumFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigSetStringFunc)(const char *name, RedisModuleString *val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigApplyFunc)(RedisModuleCtx *ctx, void *privdata, RedisModuleString **err); -typedef void (*RedisModuleOnUnblocked)(RedisModuleCtx *ctx, RedisModuleCallReply *reply, void *private_data); -typedef int (*RedisModuleAuthCallback)(RedisModuleCtx *ctx, RedisModuleString *username, RedisModuleString *password, RedisModuleString **err); - -typedef struct RedisModuleTypeMethods { - uint64_t version; - RedisModuleTypeLoadFunc rdb_load; - RedisModuleTypeSaveFunc rdb_save; - RedisModuleTypeRewriteFunc aof_rewrite; - RedisModuleTypeMemUsageFunc mem_usage; - RedisModuleTypeDigestFunc digest; - RedisModuleTypeFreeFunc free; - RedisModuleTypeAuxLoadFunc aux_load; - RedisModuleTypeAuxSaveFunc aux_save; - int aux_save_triggers; - RedisModuleTypeFreeEffortFunc free_effort; - RedisModuleTypeUnlinkFunc unlink; - RedisModuleTypeCopyFunc copy; - RedisModuleTypeDefragFunc defrag; - RedisModuleTypeMemUsageFunc2 mem_usage2; - RedisModuleTypeFreeEffortFunc2 free_effort2; - RedisModuleTypeUnlinkFunc2 unlink2; - RedisModuleTypeCopyFunc2 copy2; - RedisModuleTypeAuxSaveFunc aux_save2; -} RedisModuleTypeMethods; - -#define REDISMODULE_GET_API(name) \ - RedisModule_GetApi("RedisModule_" #name, ((void **)&RedisModule_ ## name)) - -/* Default API declaration prefix (not 'extern' for backwards compatibility) */ -#ifndef REDISMODULE_API -#define REDISMODULE_API -#endif - -/* Default API declaration suffix (compiler attributes) */ -#ifndef REDISMODULE_ATTR -#define REDISMODULE_ATTR REDISMODULE_ATTR_COMMON -#endif - -REDISMODULE_API void * (*RedisModule_Alloc)(size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_TryAlloc)(size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_Realloc)(void *ptr, size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_TryRealloc)(void *ptr, size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_Free)(void *ptr) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_Calloc)(size_t nmemb, size_t size) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_TryCalloc)(size_t nmemb, size_t size) REDISMODULE_ATTR; -REDISMODULE_API char * (*RedisModule_Strdup)(const char *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetApi)(const char *, void *) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CreateCommand)(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCommand *(*RedisModule_GetCommand)(RedisModuleCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CreateSubcommand)(RedisModuleCommand *parent, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetCommandInfo)(RedisModuleCommand *command, const RedisModuleCommandInfo *info) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetCommandACLCategories)(RedisModuleCommand *command, const char *ctgrsflags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AddACLCategory)(RedisModuleCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetModuleAttribs)(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsModuleNameBusy)(const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_WrongArity)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithLongLong)(RedisModuleCtx *ctx, long long ll) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetSelectedDb)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SelectDb)(RedisModuleCtx *ctx, int newid) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_KeyExists)(RedisModuleCtx *ctx, RedisModuleString *keyname) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleKey * (*RedisModule_OpenKey)(RedisModuleCtx *ctx, RedisModuleString *keyname, int mode) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetOpenKeyModesAll)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_CloseKey)(RedisModuleKey *kp) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_KeyType)(RedisModuleKey *kp) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_ValueLength)(RedisModuleKey *kp) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListPush)(RedisModuleKey *kp, int where, RedisModuleString *ele) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ListPop)(RedisModuleKey *key, int where) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ListGet)(RedisModuleKey *key, long index) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListSet)(RedisModuleKey *key, long index, RedisModuleString *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListInsert)(RedisModuleKey *key, long index, RedisModuleString *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListDelete)(RedisModuleKey *key, long index) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_Call)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_CallReplyProto)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeCallReply)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyType)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_CallReplyInteger)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API double (*RedisModule_CallReplyDouble)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyBool)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API const char* (*RedisModule_CallReplyBigNumber)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API const char* (*RedisModule_CallReplyVerbatim)(RedisModuleCallReply *reply, size_t *len, const char **format) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplySetElement)(RedisModuleCallReply *reply, size_t idx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyMapElement)(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyAttributeElement)(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_CallReplyPromiseSetUnblockHandler)(RedisModuleCallReply *reply, RedisModuleOnUnblocked on_unblock, void *private_data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyPromiseAbort)(RedisModuleCallReply *reply, void **private_data) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplyAttribute)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_CallReplyLength)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplyArrayElement)(RedisModuleCallReply *reply, size_t idx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateString)(RedisModuleCtx *ctx, const char *ptr, size_t len) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromLongLong)(RedisModuleCtx *ctx, long long ll) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromULongLong)(RedisModuleCtx *ctx, unsigned long long ull) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromDouble)(RedisModuleCtx *ctx, double d) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromLongDouble)(RedisModuleCtx *ctx, long double ld, int humanfriendly) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromString)(RedisModuleCtx *ctx, const RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromStreamID)(RedisModuleCtx *ctx, const RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringPrintf)(RedisModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR_PRINTF(2,3) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_StringPtrLen)(const RedisModuleString *str, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithError)(RedisModuleCtx *ctx, const char *err) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithErrorFormat)(RedisModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithSimpleString)(RedisModuleCtx *ctx, const char *msg) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithMap)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithSet)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithAttribute)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithNullArray)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithEmptyArray)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetArrayLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetMapLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetSetLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetAttributeLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetPushLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithStringBuffer)(RedisModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithCString)(RedisModuleCtx *ctx, const char *buf) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithEmptyString)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithVerbatimString)(RedisModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithVerbatimStringType)(RedisModuleCtx *ctx, const char *buf, size_t len, const char *ext) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithNull)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithBool)(RedisModuleCtx *ctx, int b) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithLongDouble)(RedisModuleCtx *ctx, long double d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithDouble)(RedisModuleCtx *ctx, double d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithBigNumber)(RedisModuleCtx *ctx, const char *bignum, size_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithCallReply)(RedisModuleCtx *ctx, RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToLongLong)(const RedisModuleString *str, long long *ll) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToULongLong)(const RedisModuleString *str, unsigned long long *ull) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToDouble)(const RedisModuleString *str, double *d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToLongDouble)(const RedisModuleString *str, long double *d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToStreamID)(const RedisModuleString *str, RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_AutoMemory)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_Replicate)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplicateVerbatim)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_CallReplyStringPtr)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromCallReply)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DeleteKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_UnlinkKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringSet)(RedisModuleKey *key, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API char * (*RedisModule_StringDMA)(RedisModuleKey *key, size_t *len, int mode) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringTruncate)(RedisModuleKey *key, size_t newlen) REDISMODULE_ATTR; -REDISMODULE_API mstime_t (*RedisModule_GetExpire)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetExpire)(RedisModuleKey *key, mstime_t expire) REDISMODULE_ATTR; -REDISMODULE_API mstime_t (*RedisModule_GetAbsExpire)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetAbsExpire)(RedisModuleKey *key, mstime_t expire) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ResetDataset)(int restart_aof, int async) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_DbSize)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_RandomKey)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetAdd)(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetIncrby)(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr, double *newscore) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetScore)(RedisModuleKey *key, RedisModuleString *ele, double *score) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRem)(RedisModuleKey *key, RedisModuleString *ele, int *deleted) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ZsetRangeStop)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetFirstInScoreRange)(RedisModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetLastInScoreRange)(RedisModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetFirstInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetLastInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ZsetRangeCurrentElement)(RedisModuleKey *key, double *score) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRangeNext)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRangePrev)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRangeEndReached)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_HashSet)(RedisModuleKey *key, int flags, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_HashGet)(RedisModuleKey *key, int flags, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamAdd)(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisModuleString **argv, int64_t numfields) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamDelete)(RedisModuleKey *key, RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorStart)(RedisModuleKey *key, int flags, RedisModuleStreamID *startid, RedisModuleStreamID *endid) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorStop)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorNextID)(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorNextField)(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorDelete)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_StreamTrimByLength)(RedisModuleKey *key, int flags, long long length) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_StreamTrimByID)(RedisModuleKey *key, int flags, RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsKeysPositionRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_KeyAtPos)(RedisModuleCtx *ctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_KeyAtPosWithFlags)(RedisModuleCtx *ctx, int pos, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsChannelsPositionRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ChannelAtPosWithFlags)(RedisModuleCtx *ctx, int pos, int flags) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_GetClientId)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetClientUserNameById)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetClientInfoById)(void *ci, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetClientNameById)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetClientNameById)(uint64_t id, RedisModuleString *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_PublishMessage)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_PublishMessageShard)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetContextFlags)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AvoidReplicaTraffic)(void) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleType * (*RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ModuleTypeReplaceValue)(RedisModuleKey *key, RedisModuleType *mt, void *new_value, void **old_value) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleType * (*RedisModule_ModuleTypeGetType)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_ModuleTypeGetValue)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsIOError)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetModuleOptions)(RedisModuleCtx *ctx, int options) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SignalModifiedKey)(RedisModuleCtx *ctx, RedisModuleString *keyname) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveUnsigned)(RedisModuleIO *io, uint64_t value) REDISMODULE_ATTR; -REDISMODULE_API uint64_t (*RedisModule_LoadUnsigned)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveSigned)(RedisModuleIO *io, int64_t value) REDISMODULE_ATTR; -REDISMODULE_API int64_t (*RedisModule_LoadSigned)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_EmitAOF)(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveString)(RedisModuleIO *io, RedisModuleString *s) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveStringBuffer)(RedisModuleIO *io, const char *str, size_t len) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_LoadString)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API char * (*RedisModule_LoadStringBuffer)(RedisModuleIO *io, size_t *lenptr) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveDouble)(RedisModuleIO *io, double value) REDISMODULE_ATTR; -REDISMODULE_API double (*RedisModule_LoadDouble)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveFloat)(RedisModuleIO *io, float value) REDISMODULE_ATTR; -REDISMODULE_API float (*RedisModule_LoadFloat)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveLongDouble)(RedisModuleIO *io, long double value) REDISMODULE_ATTR; -REDISMODULE_API long double (*RedisModule_LoadLongDouble)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_LoadDataTypeFromString)(const RedisModuleString *str, const RedisModuleType *mt) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_LoadDataTypeFromStringEncver)(const RedisModuleString *str, const RedisModuleType *mt, int encver) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_SaveDataTypeToString)(RedisModuleCtx *ctx, void *data, const RedisModuleType *mt) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_Log)(RedisModuleCtx *ctx, const char *level, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4); -REDISMODULE_API void (*RedisModule_LogIOError)(RedisModuleIO *io, const char *levelstr, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4); -REDISMODULE_API void (*RedisModule__Assert)(const char *estr, const char *file, int line) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_LatencyAddSample)(const char *event, mstime_t latency) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringAppendBuffer)(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_TrimStringAllocation)(RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RetainString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_HoldString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringCompare)(const RedisModuleString *a, const RedisModuleString *b) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCtx * (*RedisModule_GetContextFromIO)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromIO)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromModuleKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromModuleKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromIO)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetToDbIdFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetToKeyNameFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API mstime_t (*RedisModule_Milliseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API uint64_t (*RedisModule_MonotonicMicroseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API ustime_t (*RedisModule_Microseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API ustime_t (*RedisModule_CachedMicroseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DigestAddStringBuffer)(RedisModuleDigest *md, const char *ele, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DigestAddLongLong)(RedisModuleDigest *md, long long ele) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DigestEndSequence)(RedisModuleDigest *md) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromDigest)(RedisModuleDigest *dig) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromDigest)(RedisModuleDigest *dig) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleDict * (*RedisModule_CreateDict)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeDict)(RedisModuleCtx *ctx, RedisModuleDict *d) REDISMODULE_ATTR; -REDISMODULE_API uint64_t (*RedisModule_DictSize)(RedisModuleDict *d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictSetC)(RedisModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictReplaceC)(RedisModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictSet)(RedisModuleDict *d, RedisModuleString *key, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictReplace)(RedisModuleDict *d, RedisModuleString *key, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictGetC)(RedisModuleDict *d, void *key, size_t keylen, int *nokey) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictGet)(RedisModuleDict *d, RedisModuleString *key, int *nokey) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictDelC)(RedisModuleDict *d, void *key, size_t keylen, void *oldval) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictDel)(RedisModuleDict *d, RedisModuleString *key, void *oldval) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleDictIter * (*RedisModule_DictIteratorStartC)(RedisModuleDict *d, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleDictIter * (*RedisModule_DictIteratorStart)(RedisModuleDict *d, const char *op, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DictIteratorStop)(RedisModuleDictIter *di) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictIteratorReseekC)(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictIteratorReseek)(RedisModuleDictIter *di, const char *op, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictNextC)(RedisModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictPrevC)(RedisModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_DictNext)(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_DictPrev)(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictCompareC)(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictCompare)(RedisModuleDictIter *di, const char *op, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterInfoFunc)(RedisModuleCtx *ctx, RedisModuleInfoFunc cb) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RegisterAuthCallback)(RedisModuleCtx *ctx, RedisModuleAuthCallback cb) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddSection)(RedisModuleInfoCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoBeginDictField)(RedisModuleInfoCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoEndDictField)(RedisModuleInfoCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldString)(RedisModuleInfoCtx *ctx, const char *field, RedisModuleString *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldCString)(RedisModuleInfoCtx *ctx, const char *field,const char *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldDouble)(RedisModuleInfoCtx *ctx, const char *field, double value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldLongLong)(RedisModuleInfoCtx *ctx, const char *field, long long value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldULongLong)(RedisModuleInfoCtx *ctx, const char *field, unsigned long long value) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleServerInfoData * (*RedisModule_GetServerInfo)(RedisModuleCtx *ctx, const char *section) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeServerInfo)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ServerInfoGetField)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_ServerInfoGetFieldC)(RedisModuleServerInfoData *data, const char* field) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_ServerInfoGetFieldSigned)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_ServerInfoGetFieldUnsigned)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; -REDISMODULE_API double (*RedisModule_ServerInfoGetFieldDouble)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SubscribeToServerEvent)(RedisModuleCtx *ctx, RedisModuleEvent event, RedisModuleEventCallback callback) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetLRU)(RedisModuleKey *key, mstime_t lru_idle) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetLRU)(RedisModuleKey *key, mstime_t *lru_idle) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetLFU)(RedisModuleKey *key, long long lfu_freq) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetLFU)(RedisModuleKey *key, long long *lfu_freq) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnKeys)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnKeysWithFlags)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata, int flags) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SignalKeyAsReady)(RedisModuleCtx *ctx, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetBlockedClientReadyKey)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleScanCursor * (*RedisModule_ScanCursorCreate)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ScanCursorRestart)(RedisModuleScanCursor *cursor) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ScanCursorDestroy)(RedisModuleScanCursor *cursor) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_Scan)(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ScanKey)(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleScanKeyCB fn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetContextFlagsAll)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetModuleOptionsAll)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetKeyspaceNotificationFlagsAll)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsSubEventSupported)(RedisModuleEvent event, uint64_t subevent) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetServerVersion)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetTypeMethodVersion)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_Yield)(RedisModuleCtx *ctx, int flags, const char *busy_reply) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClient)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_BlockClientGetPrivateData)(RedisModuleBlockedClient *blocked_client) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_BlockClientSetPrivateData)(RedisModuleBlockedClient *blocked_client, void *private_data) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnAuth)(RedisModuleCtx *ctx, RedisModuleAuthCallback reply_callback, void (*free_privdata)(RedisModuleCtx*,void*)) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_UnblockClient)(RedisModuleBlockedClient *bc, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsBlockedReplyRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsBlockedTimeoutRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_GetBlockedClientPrivateData)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_GetBlockedClientHandle)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AbortBlock)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_BlockedClientMeasureTimeStart)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_BlockedClientMeasureTimeEnd)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCtx * (*RedisModule_GetThreadSafeContext)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCtx * (*RedisModule_GetDetachedThreadSafeContext)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeThreadSafeContext)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ThreadSafeContextLock)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ThreadSafeContextTryLock)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ThreadSafeContextUnlock)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SubscribeToKeyspaceEvents)(RedisModuleCtx *ctx, int types, RedisModuleNotificationFunc cb) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AddPostNotificationJob)(RedisModuleCtx *ctx, RedisModulePostNotificationJobFunc callback, void *pd, void (*free_pd)(void*)) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_NotifyKeyspaceEvent)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetNotifyKeyspaceEvents)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_BlockedClientDisconnected)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RegisterClusterMessageReceiver)(RedisModuleCtx *ctx, uint8_t type, RedisModuleClusterMessageReceiver callback) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SendClusterMessage)(RedisModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetClusterNodeInfo)(RedisModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) REDISMODULE_ATTR; -REDISMODULE_API char ** (*RedisModule_GetClusterNodesList)(RedisModuleCtx *ctx, size_t *numnodes) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeClusterNodesList)(char **ids) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleTimerID (*RedisModule_CreateTimer)(RedisModuleCtx *ctx, mstime_t period, RedisModuleTimerProc callback, void *data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StopTimer)(RedisModuleCtx *ctx, RedisModuleTimerID id, void **data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetTimerInfo)(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remaining, void **data) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_GetMyClusterID)(void) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_GetClusterSize)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_GetRandomBytes)(unsigned char *dst, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_GetRandomHexChars)(char *dst, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetDisconnectCallback)(RedisModuleBlockedClient *bc, RedisModuleDisconnectFunc callback) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetClusterFlags)(RedisModuleCtx *ctx, uint64_t flags) REDISMODULE_ATTR; -REDISMODULE_API unsigned int (*RedisModule_ClusterKeySlot)(RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API const char *(*RedisModule_ClusterCanonicalKeyNameInSlot)(unsigned int slot) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ExportSharedAPI)(RedisModuleCtx *ctx, const char *apiname, void *func) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_GetSharedAPI)(RedisModuleCtx *ctx, const char *apiname) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCommandFilter * (*RedisModule_RegisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilterFunc cb, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_UnregisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgsCount)(RedisModuleCommandFilterCtx *fctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CommandFilterArgGet)(RedisModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgInsert)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgReplace)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgDelete)(RedisModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_CommandFilterGetClientId)(RedisModuleCommandFilterCtx *fctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_Fork)(RedisModuleForkDoneHandler cb, void *user_data) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SendChildHeartbeat)(double progress) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ExitFromChild)(int retcode) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_KillForkChild)(int child_pid) REDISMODULE_ATTR; -REDISMODULE_API float (*RedisModule_GetUsedMemoryRatio)(void) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocSize)(void* ptr) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocUsableSize)(void *ptr) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocSizeString)(RedisModuleString* str) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocSizeDict)(RedisModuleDict* dict) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleUser * (*RedisModule_CreateModuleUser)(const char *name) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeModuleUser)(RedisModuleUser *user) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetContextUser)(RedisModuleCtx *ctx, const RedisModuleUser *user) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetModuleUserACL)(RedisModuleUser *user, const char* acl) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetModuleUserACLString)(RedisModuleCtx * ctx, RedisModuleUser *user, const char* acl, RedisModuleString **error) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetModuleUserACLString)(RedisModuleUser *user) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetCurrentUserName)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleUser * (*RedisModule_GetModuleUserFromUserName)(RedisModuleString *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ACLCheckCommandPermissions)(RedisModuleUser *user, RedisModuleString **argv, int argc) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ACLCheckKeyPermissions)(RedisModuleUser *user, RedisModuleString *key, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ACLCheckChannelPermissions)(RedisModuleUser *user, RedisModuleString *ch, int literal) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ACLAddLogEntry)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleString *object, RedisModuleACLLogEntryReason reason) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ACLAddLogEntryByUserName)(RedisModuleCtx *ctx, RedisModuleString *user, RedisModuleString *object, RedisModuleACLLogEntryReason reason) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AuthenticateClientWithACLUser)(RedisModuleCtx *ctx, const char *name, size_t len, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AuthenticateClientWithUser)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DeauthenticateAndCloseClient)(RedisModuleCtx *ctx, uint64_t client_id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RedactClientCommandArgument)(RedisModuleCtx *ctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetClientCertificate)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API int *(*RedisModule_GetCommandKeys)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) REDISMODULE_ATTR; -REDISMODULE_API int *(*RedisModule_GetCommandKeysWithFlags)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) REDISMODULE_ATTR; -REDISMODULE_API const char *(*RedisModule_GetCurrentCommandName)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterDefragFunc)(RedisModuleCtx *ctx, RedisModuleDefragFunc func) REDISMODULE_ATTR; -REDISMODULE_API void *(*RedisModule_DefragAlloc)(RedisModuleDefragCtx *ctx, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString *(*RedisModule_DefragRedisModuleString)(RedisModuleDefragCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DefragShouldStop)(RedisModuleDefragCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DefragCursorSet)(RedisModuleDefragCtx *ctx, unsigned long cursor) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DefragCursorGet)(RedisModuleDefragCtx *ctx, unsigned long *cursor) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromDefragCtx)(RedisModuleDefragCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromDefragCtx)(RedisModuleDefragCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_EventLoopAdd)(int fd, int mask, RedisModuleEventLoopFunc func, void *user_data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_EventLoopDel)(int fd, int mask) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_EventLoopAddOneShot)(RedisModuleEventLoopOneShotFunc func, void *user_data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterBoolConfig)(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedisModuleConfigGetBoolFunc getfn, RedisModuleConfigSetBoolFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterNumericConfig)(RedisModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedisModuleConfigGetNumericFunc getfn, RedisModuleConfigSetNumericFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterStringConfig)(RedisModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, RedisModuleConfigGetStringFunc getfn, RedisModuleConfigSetStringFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterEnumConfig)(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, RedisModuleConfigGetEnumFunc getfn, RedisModuleConfigSetEnumFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_LoadConfigs)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleRdbStream *(*RedisModule_RdbStreamCreateFromFile)(const char *filename) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RdbStreamFree)(RedisModuleRdbStream *stream) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RdbLoad)(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RdbSave)(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) REDISMODULE_ATTR; - -#define RedisModule_IsAOFClient(id) ((id) == UINT64_MAX) - -/* This is included inline inside each Redis module. */ -static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR_UNUSED; -static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) { - void *getapifuncptr = ((void**)ctx)[0]; - RedisModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr; - REDISMODULE_GET_API(Alloc); - REDISMODULE_GET_API(TryAlloc); - REDISMODULE_GET_API(Calloc); - REDISMODULE_GET_API(TryCalloc); - REDISMODULE_GET_API(Free); - REDISMODULE_GET_API(Realloc); - REDISMODULE_GET_API(TryRealloc); - REDISMODULE_GET_API(Strdup); - REDISMODULE_GET_API(CreateCommand); - REDISMODULE_GET_API(GetCommand); - REDISMODULE_GET_API(CreateSubcommand); - REDISMODULE_GET_API(SetCommandInfo); - REDISMODULE_GET_API(SetCommandACLCategories); - REDISMODULE_GET_API(AddACLCategory); - REDISMODULE_GET_API(SetModuleAttribs); - REDISMODULE_GET_API(IsModuleNameBusy); - REDISMODULE_GET_API(WrongArity); - REDISMODULE_GET_API(ReplyWithLongLong); - REDISMODULE_GET_API(ReplyWithError); - REDISMODULE_GET_API(ReplyWithErrorFormat); - REDISMODULE_GET_API(ReplyWithSimpleString); - REDISMODULE_GET_API(ReplyWithArray); - REDISMODULE_GET_API(ReplyWithMap); - REDISMODULE_GET_API(ReplyWithSet); - REDISMODULE_GET_API(ReplyWithAttribute); - REDISMODULE_GET_API(ReplyWithNullArray); - REDISMODULE_GET_API(ReplyWithEmptyArray); - REDISMODULE_GET_API(ReplySetArrayLength); - REDISMODULE_GET_API(ReplySetMapLength); - REDISMODULE_GET_API(ReplySetSetLength); - REDISMODULE_GET_API(ReplySetAttributeLength); - REDISMODULE_GET_API(ReplySetPushLength); - REDISMODULE_GET_API(ReplyWithStringBuffer); - REDISMODULE_GET_API(ReplyWithCString); - REDISMODULE_GET_API(ReplyWithString); - REDISMODULE_GET_API(ReplyWithEmptyString); - REDISMODULE_GET_API(ReplyWithVerbatimString); - REDISMODULE_GET_API(ReplyWithVerbatimStringType); - REDISMODULE_GET_API(ReplyWithNull); - REDISMODULE_GET_API(ReplyWithBool); - REDISMODULE_GET_API(ReplyWithCallReply); - REDISMODULE_GET_API(ReplyWithDouble); - REDISMODULE_GET_API(ReplyWithBigNumber); - REDISMODULE_GET_API(ReplyWithLongDouble); - REDISMODULE_GET_API(GetSelectedDb); - REDISMODULE_GET_API(SelectDb); - REDISMODULE_GET_API(KeyExists); - REDISMODULE_GET_API(OpenKey); - REDISMODULE_GET_API(GetOpenKeyModesAll); - REDISMODULE_GET_API(CloseKey); - REDISMODULE_GET_API(KeyType); - REDISMODULE_GET_API(ValueLength); - REDISMODULE_GET_API(ListPush); - REDISMODULE_GET_API(ListPop); - REDISMODULE_GET_API(ListGet); - REDISMODULE_GET_API(ListSet); - REDISMODULE_GET_API(ListInsert); - REDISMODULE_GET_API(ListDelete); - REDISMODULE_GET_API(StringToLongLong); - REDISMODULE_GET_API(StringToULongLong); - REDISMODULE_GET_API(StringToDouble); - REDISMODULE_GET_API(StringToLongDouble); - REDISMODULE_GET_API(StringToStreamID); - REDISMODULE_GET_API(Call); - REDISMODULE_GET_API(CallReplyProto); - REDISMODULE_GET_API(FreeCallReply); - REDISMODULE_GET_API(CallReplyInteger); - REDISMODULE_GET_API(CallReplyDouble); - REDISMODULE_GET_API(CallReplyBool); - REDISMODULE_GET_API(CallReplyBigNumber); - REDISMODULE_GET_API(CallReplyVerbatim); - REDISMODULE_GET_API(CallReplySetElement); - REDISMODULE_GET_API(CallReplyMapElement); - REDISMODULE_GET_API(CallReplyAttributeElement); - REDISMODULE_GET_API(CallReplyPromiseSetUnblockHandler); - REDISMODULE_GET_API(CallReplyPromiseAbort); - REDISMODULE_GET_API(CallReplyAttribute); - REDISMODULE_GET_API(CallReplyType); - REDISMODULE_GET_API(CallReplyLength); - REDISMODULE_GET_API(CallReplyArrayElement); - REDISMODULE_GET_API(CallReplyStringPtr); - REDISMODULE_GET_API(CreateStringFromCallReply); - REDISMODULE_GET_API(CreateString); - REDISMODULE_GET_API(CreateStringFromLongLong); - REDISMODULE_GET_API(CreateStringFromULongLong); - REDISMODULE_GET_API(CreateStringFromDouble); - REDISMODULE_GET_API(CreateStringFromLongDouble); - REDISMODULE_GET_API(CreateStringFromString); - REDISMODULE_GET_API(CreateStringFromStreamID); - REDISMODULE_GET_API(CreateStringPrintf); - REDISMODULE_GET_API(FreeString); - REDISMODULE_GET_API(StringPtrLen); - REDISMODULE_GET_API(AutoMemory); - REDISMODULE_GET_API(Replicate); - REDISMODULE_GET_API(ReplicateVerbatim); - REDISMODULE_GET_API(DeleteKey); - REDISMODULE_GET_API(UnlinkKey); - REDISMODULE_GET_API(StringSet); - REDISMODULE_GET_API(StringDMA); - REDISMODULE_GET_API(StringTruncate); - REDISMODULE_GET_API(GetExpire); - REDISMODULE_GET_API(SetExpire); - REDISMODULE_GET_API(GetAbsExpire); - REDISMODULE_GET_API(SetAbsExpire); - REDISMODULE_GET_API(ResetDataset); - REDISMODULE_GET_API(DbSize); - REDISMODULE_GET_API(RandomKey); - REDISMODULE_GET_API(ZsetAdd); - REDISMODULE_GET_API(ZsetIncrby); - REDISMODULE_GET_API(ZsetScore); - REDISMODULE_GET_API(ZsetRem); - REDISMODULE_GET_API(ZsetRangeStop); - REDISMODULE_GET_API(ZsetFirstInScoreRange); - REDISMODULE_GET_API(ZsetLastInScoreRange); - REDISMODULE_GET_API(ZsetFirstInLexRange); - REDISMODULE_GET_API(ZsetLastInLexRange); - REDISMODULE_GET_API(ZsetRangeCurrentElement); - REDISMODULE_GET_API(ZsetRangeNext); - REDISMODULE_GET_API(ZsetRangePrev); - REDISMODULE_GET_API(ZsetRangeEndReached); - REDISMODULE_GET_API(HashSet); - REDISMODULE_GET_API(HashGet); - REDISMODULE_GET_API(StreamAdd); - REDISMODULE_GET_API(StreamDelete); - REDISMODULE_GET_API(StreamIteratorStart); - REDISMODULE_GET_API(StreamIteratorStop); - REDISMODULE_GET_API(StreamIteratorNextID); - REDISMODULE_GET_API(StreamIteratorNextField); - REDISMODULE_GET_API(StreamIteratorDelete); - REDISMODULE_GET_API(StreamTrimByLength); - REDISMODULE_GET_API(StreamTrimByID); - REDISMODULE_GET_API(IsKeysPositionRequest); - REDISMODULE_GET_API(KeyAtPos); - REDISMODULE_GET_API(KeyAtPosWithFlags); - REDISMODULE_GET_API(IsChannelsPositionRequest); - REDISMODULE_GET_API(ChannelAtPosWithFlags); - REDISMODULE_GET_API(GetClientId); - REDISMODULE_GET_API(GetClientUserNameById); - REDISMODULE_GET_API(GetContextFlags); - REDISMODULE_GET_API(AvoidReplicaTraffic); - REDISMODULE_GET_API(PoolAlloc); - REDISMODULE_GET_API(CreateDataType); - REDISMODULE_GET_API(ModuleTypeSetValue); - REDISMODULE_GET_API(ModuleTypeReplaceValue); - REDISMODULE_GET_API(ModuleTypeGetType); - REDISMODULE_GET_API(ModuleTypeGetValue); - REDISMODULE_GET_API(IsIOError); - REDISMODULE_GET_API(SetModuleOptions); - REDISMODULE_GET_API(SignalModifiedKey); - REDISMODULE_GET_API(SaveUnsigned); - REDISMODULE_GET_API(LoadUnsigned); - REDISMODULE_GET_API(SaveSigned); - REDISMODULE_GET_API(LoadSigned); - REDISMODULE_GET_API(SaveString); - REDISMODULE_GET_API(SaveStringBuffer); - REDISMODULE_GET_API(LoadString); - REDISMODULE_GET_API(LoadStringBuffer); - REDISMODULE_GET_API(SaveDouble); - REDISMODULE_GET_API(LoadDouble); - REDISMODULE_GET_API(SaveFloat); - REDISMODULE_GET_API(LoadFloat); - REDISMODULE_GET_API(SaveLongDouble); - REDISMODULE_GET_API(LoadLongDouble); - REDISMODULE_GET_API(SaveDataTypeToString); - REDISMODULE_GET_API(LoadDataTypeFromString); - REDISMODULE_GET_API(LoadDataTypeFromStringEncver); - REDISMODULE_GET_API(EmitAOF); - REDISMODULE_GET_API(Log); - REDISMODULE_GET_API(LogIOError); - REDISMODULE_GET_API(_Assert); - REDISMODULE_GET_API(LatencyAddSample); - REDISMODULE_GET_API(StringAppendBuffer); - REDISMODULE_GET_API(TrimStringAllocation); - REDISMODULE_GET_API(RetainString); - REDISMODULE_GET_API(HoldString); - REDISMODULE_GET_API(StringCompare); - REDISMODULE_GET_API(GetContextFromIO); - REDISMODULE_GET_API(GetKeyNameFromIO); - REDISMODULE_GET_API(GetKeyNameFromModuleKey); - REDISMODULE_GET_API(GetDbIdFromModuleKey); - REDISMODULE_GET_API(GetDbIdFromIO); - REDISMODULE_GET_API(GetKeyNameFromOptCtx); - REDISMODULE_GET_API(GetToKeyNameFromOptCtx); - REDISMODULE_GET_API(GetDbIdFromOptCtx); - REDISMODULE_GET_API(GetToDbIdFromOptCtx); - REDISMODULE_GET_API(Milliseconds); - REDISMODULE_GET_API(MonotonicMicroseconds); - REDISMODULE_GET_API(Microseconds); - REDISMODULE_GET_API(CachedMicroseconds); - REDISMODULE_GET_API(DigestAddStringBuffer); - REDISMODULE_GET_API(DigestAddLongLong); - REDISMODULE_GET_API(DigestEndSequence); - REDISMODULE_GET_API(GetKeyNameFromDigest); - REDISMODULE_GET_API(GetDbIdFromDigest); - REDISMODULE_GET_API(CreateDict); - REDISMODULE_GET_API(FreeDict); - REDISMODULE_GET_API(DictSize); - REDISMODULE_GET_API(DictSetC); - REDISMODULE_GET_API(DictReplaceC); - REDISMODULE_GET_API(DictSet); - REDISMODULE_GET_API(DictReplace); - REDISMODULE_GET_API(DictGetC); - REDISMODULE_GET_API(DictGet); - REDISMODULE_GET_API(DictDelC); - REDISMODULE_GET_API(DictDel); - REDISMODULE_GET_API(DictIteratorStartC); - REDISMODULE_GET_API(DictIteratorStart); - REDISMODULE_GET_API(DictIteratorStop); - REDISMODULE_GET_API(DictIteratorReseekC); - REDISMODULE_GET_API(DictIteratorReseek); - REDISMODULE_GET_API(DictNextC); - REDISMODULE_GET_API(DictPrevC); - REDISMODULE_GET_API(DictNext); - REDISMODULE_GET_API(DictPrev); - REDISMODULE_GET_API(DictCompare); - REDISMODULE_GET_API(DictCompareC); - REDISMODULE_GET_API(RegisterInfoFunc); - REDISMODULE_GET_API(RegisterAuthCallback); - REDISMODULE_GET_API(InfoAddSection); - REDISMODULE_GET_API(InfoBeginDictField); - REDISMODULE_GET_API(InfoEndDictField); - REDISMODULE_GET_API(InfoAddFieldString); - REDISMODULE_GET_API(InfoAddFieldCString); - REDISMODULE_GET_API(InfoAddFieldDouble); - REDISMODULE_GET_API(InfoAddFieldLongLong); - REDISMODULE_GET_API(InfoAddFieldULongLong); - REDISMODULE_GET_API(GetServerInfo); - REDISMODULE_GET_API(FreeServerInfo); - REDISMODULE_GET_API(ServerInfoGetField); - REDISMODULE_GET_API(ServerInfoGetFieldC); - REDISMODULE_GET_API(ServerInfoGetFieldSigned); - REDISMODULE_GET_API(ServerInfoGetFieldUnsigned); - REDISMODULE_GET_API(ServerInfoGetFieldDouble); - REDISMODULE_GET_API(GetClientInfoById); - REDISMODULE_GET_API(GetClientNameById); - REDISMODULE_GET_API(SetClientNameById); - REDISMODULE_GET_API(PublishMessage); - REDISMODULE_GET_API(PublishMessageShard); - REDISMODULE_GET_API(SubscribeToServerEvent); - REDISMODULE_GET_API(SetLRU); - REDISMODULE_GET_API(GetLRU); - REDISMODULE_GET_API(SetLFU); - REDISMODULE_GET_API(GetLFU); - REDISMODULE_GET_API(BlockClientOnKeys); - REDISMODULE_GET_API(BlockClientOnKeysWithFlags); - REDISMODULE_GET_API(SignalKeyAsReady); - REDISMODULE_GET_API(GetBlockedClientReadyKey); - REDISMODULE_GET_API(ScanCursorCreate); - REDISMODULE_GET_API(ScanCursorRestart); - REDISMODULE_GET_API(ScanCursorDestroy); - REDISMODULE_GET_API(Scan); - REDISMODULE_GET_API(ScanKey); - REDISMODULE_GET_API(GetContextFlagsAll); - REDISMODULE_GET_API(GetModuleOptionsAll); - REDISMODULE_GET_API(GetKeyspaceNotificationFlagsAll); - REDISMODULE_GET_API(IsSubEventSupported); - REDISMODULE_GET_API(GetServerVersion); - REDISMODULE_GET_API(GetTypeMethodVersion); - REDISMODULE_GET_API(Yield); - REDISMODULE_GET_API(GetThreadSafeContext); - REDISMODULE_GET_API(GetDetachedThreadSafeContext); - REDISMODULE_GET_API(FreeThreadSafeContext); - REDISMODULE_GET_API(ThreadSafeContextLock); - REDISMODULE_GET_API(ThreadSafeContextTryLock); - REDISMODULE_GET_API(ThreadSafeContextUnlock); - REDISMODULE_GET_API(BlockClient); - REDISMODULE_GET_API(BlockClientGetPrivateData); - REDISMODULE_GET_API(BlockClientSetPrivateData); - REDISMODULE_GET_API(BlockClientOnAuth); - REDISMODULE_GET_API(UnblockClient); - REDISMODULE_GET_API(IsBlockedReplyRequest); - REDISMODULE_GET_API(IsBlockedTimeoutRequest); - REDISMODULE_GET_API(GetBlockedClientPrivateData); - REDISMODULE_GET_API(GetBlockedClientHandle); - REDISMODULE_GET_API(AbortBlock); - REDISMODULE_GET_API(BlockedClientMeasureTimeStart); - REDISMODULE_GET_API(BlockedClientMeasureTimeEnd); - REDISMODULE_GET_API(SetDisconnectCallback); - REDISMODULE_GET_API(SubscribeToKeyspaceEvents); - REDISMODULE_GET_API(AddPostNotificationJob); - REDISMODULE_GET_API(NotifyKeyspaceEvent); - REDISMODULE_GET_API(GetNotifyKeyspaceEvents); - REDISMODULE_GET_API(BlockedClientDisconnected); - REDISMODULE_GET_API(RegisterClusterMessageReceiver); - REDISMODULE_GET_API(SendClusterMessage); - REDISMODULE_GET_API(GetClusterNodeInfo); - REDISMODULE_GET_API(GetClusterNodesList); - REDISMODULE_GET_API(FreeClusterNodesList); - REDISMODULE_GET_API(CreateTimer); - REDISMODULE_GET_API(StopTimer); - REDISMODULE_GET_API(GetTimerInfo); - REDISMODULE_GET_API(GetMyClusterID); - REDISMODULE_GET_API(GetClusterSize); - REDISMODULE_GET_API(GetRandomBytes); - REDISMODULE_GET_API(GetRandomHexChars); - REDISMODULE_GET_API(SetClusterFlags); - REDISMODULE_GET_API(ClusterKeySlot); - REDISMODULE_GET_API(ClusterCanonicalKeyNameInSlot); - REDISMODULE_GET_API(ExportSharedAPI); - REDISMODULE_GET_API(GetSharedAPI); - REDISMODULE_GET_API(RegisterCommandFilter); - REDISMODULE_GET_API(UnregisterCommandFilter); - REDISMODULE_GET_API(CommandFilterArgsCount); - REDISMODULE_GET_API(CommandFilterArgGet); - REDISMODULE_GET_API(CommandFilterArgInsert); - REDISMODULE_GET_API(CommandFilterArgReplace); - REDISMODULE_GET_API(CommandFilterArgDelete); - REDISMODULE_GET_API(CommandFilterGetClientId); - REDISMODULE_GET_API(Fork); - REDISMODULE_GET_API(SendChildHeartbeat); - REDISMODULE_GET_API(ExitFromChild); - REDISMODULE_GET_API(KillForkChild); - REDISMODULE_GET_API(GetUsedMemoryRatio); - REDISMODULE_GET_API(MallocSize); - REDISMODULE_GET_API(MallocUsableSize); - REDISMODULE_GET_API(MallocSizeString); - REDISMODULE_GET_API(MallocSizeDict); - REDISMODULE_GET_API(CreateModuleUser); - REDISMODULE_GET_API(FreeModuleUser); - REDISMODULE_GET_API(SetContextUser); - REDISMODULE_GET_API(SetModuleUserACL); - REDISMODULE_GET_API(SetModuleUserACLString); - REDISMODULE_GET_API(GetModuleUserACLString); - REDISMODULE_GET_API(GetCurrentUserName); - REDISMODULE_GET_API(GetModuleUserFromUserName); - REDISMODULE_GET_API(ACLCheckCommandPermissions); - REDISMODULE_GET_API(ACLCheckKeyPermissions); - REDISMODULE_GET_API(ACLCheckChannelPermissions); - REDISMODULE_GET_API(ACLAddLogEntry); - REDISMODULE_GET_API(ACLAddLogEntryByUserName); - REDISMODULE_GET_API(DeauthenticateAndCloseClient); - REDISMODULE_GET_API(AuthenticateClientWithACLUser); - REDISMODULE_GET_API(AuthenticateClientWithUser); - REDISMODULE_GET_API(RedactClientCommandArgument); - REDISMODULE_GET_API(GetClientCertificate); - REDISMODULE_GET_API(GetCommandKeys); - REDISMODULE_GET_API(GetCommandKeysWithFlags); - REDISMODULE_GET_API(GetCurrentCommandName); - REDISMODULE_GET_API(RegisterDefragFunc); - REDISMODULE_GET_API(DefragAlloc); - REDISMODULE_GET_API(DefragRedisModuleString); - REDISMODULE_GET_API(DefragShouldStop); - REDISMODULE_GET_API(DefragCursorSet); - REDISMODULE_GET_API(DefragCursorGet); - REDISMODULE_GET_API(GetKeyNameFromDefragCtx); - REDISMODULE_GET_API(GetDbIdFromDefragCtx); - REDISMODULE_GET_API(EventLoopAdd); - REDISMODULE_GET_API(EventLoopDel); - REDISMODULE_GET_API(EventLoopAddOneShot); - REDISMODULE_GET_API(RegisterBoolConfig); - REDISMODULE_GET_API(RegisterNumericConfig); - REDISMODULE_GET_API(RegisterStringConfig); - REDISMODULE_GET_API(RegisterEnumConfig); - REDISMODULE_GET_API(LoadConfigs); - REDISMODULE_GET_API(RdbStreamCreateFromFile); - REDISMODULE_GET_API(RdbStreamFree); - REDISMODULE_GET_API(RdbLoad); - REDISMODULE_GET_API(RdbSave); - - if (RedisModule_IsModuleNameBusy && RedisModule_IsModuleNameBusy(name)) return REDISMODULE_ERR; - RedisModule_SetModuleAttribs(ctx,name,ver,apiver); - return REDISMODULE_OK; -} - -#define RedisModule_Assert(_e) ((_e)?(void)0 : (RedisModule__Assert(#_e,__FILE__,__LINE__),exit(1))) - -#define RMAPI_FUNC_SUPPORTED(func) (func != NULL) + * The above directive will pull in the VALKEYMODULE_* definitions while + * ensuring that any reference to REDISMODULE_* in the module's source + * will resolve to the appropriate VALKEYMODULE_* counterpart. + */ -#endif /* REDISMODULE_CORE */ -#endif /* REDISMODULE_H */ +#include "valkeymodule.h" +#define REDISMODULE_H VALKEYMODULE_H +#define REDISMODULE_OK VALKEYMODULE_OK +#define REDISMODULE_ERR VALKEYMODULE_ERR +#define REDISMODULE_AUTH_HANDLED VALKEYMODULE_AUTH_HANDLED +#define REDISMODULE_AUTH_NOT_HANDLED VALKEYMODULE_AUTH_NOT_HANDLED +#define REDISMODULE_APIVER_1 VALKEYMODULE_APIVER_1 +#define REDISMODULE_TYPE_METHOD_VERSION VALKEYMODULE_TYPE_METHOD_VERSION +#define REDISMODULE_READ VALKEYMODULE_READ +#define REDISMODULE_WRITE VALKEYMODULE_WRITE +#define REDISMODULE_OPEN_KEY_NOTOUCH VALKEYMODULE_OPEN_KEY_NOTOUCH +#define REDISMODULE_OPEN_KEY_NONOTIFY VALKEYMODULE_OPEN_KEY_NONOTIFY +#define REDISMODULE_OPEN_KEY_NOSTATS VALKEYMODULE_OPEN_KEY_NOSTATS +#define REDISMODULE_OPEN_KEY_NOEXPIRE VALKEYMODULE_OPEN_KEY_NOEXPIRE +#define REDISMODULE_OPEN_KEY_NOEFFECTS VALKEYMODULE_OPEN_KEY_NOEFFECTS +#define REDISMODULE_LIST_HEAD VALKEYMODULE_LIST_HEAD +#define REDISMODULE_LIST_TAIL VALKEYMODULE_LIST_TAIL +#define REDISMODULE_KEYTYPE_EMPTY VALKEYMODULE_KEYTYPE_EMPTY +#define REDISMODULE_KEYTYPE_STRING VALKEYMODULE_KEYTYPE_STRING +#define REDISMODULE_KEYTYPE_LIST VALKEYMODULE_KEYTYPE_LIST +#define REDISMODULE_KEYTYPE_HASH VALKEYMODULE_KEYTYPE_HASH +#define REDISMODULE_KEYTYPE_SET VALKEYMODULE_KEYTYPE_SET +#define REDISMODULE_KEYTYPE_ZSET VALKEYMODULE_KEYTYPE_ZSET +#define REDISMODULE_KEYTYPE_MODULE VALKEYMODULE_KEYTYPE_MODULE +#define REDISMODULE_KEYTYPE_STREAM VALKEYMODULE_KEYTYPE_STREAM +#define REDISMODULE_REPLY_UNKNOWN VALKEYMODULE_REPLY_UNKNOWN +#define REDISMODULE_REPLY_STRING VALKEYMODULE_REPLY_STRING +#define REDISMODULE_REPLY_ERROR VALKEYMODULE_REPLY_ERROR +#define REDISMODULE_REPLY_INTEGER VALKEYMODULE_REPLY_INTEGER +#define REDISMODULE_REPLY_ARRAY VALKEYMODULE_REPLY_ARRAY +#define REDISMODULE_REPLY_NULL VALKEYMODULE_REPLY_NULL +#define REDISMODULE_REPLY_MAP VALKEYMODULE_REPLY_MAP +#define REDISMODULE_REPLY_SET VALKEYMODULE_REPLY_SET +#define REDISMODULE_REPLY_BOOL VALKEYMODULE_REPLY_BOOL +#define REDISMODULE_REPLY_DOUBLE VALKEYMODULE_REPLY_DOUBLE +#define REDISMODULE_REPLY_BIG_NUMBER VALKEYMODULE_REPLY_BIG_NUMBER +#define REDISMODULE_REPLY_VERBATIM_STRING VALKEYMODULE_REPLY_VERBATIM_STRING +#define REDISMODULE_REPLY_ATTRIBUTE VALKEYMODULE_REPLY_ATTRIBUTE +#define REDISMODULE_REPLY_PROMISE VALKEYMODULE_REPLY_PROMISE +#define REDISMODULE_POSTPONED_ARRAY_LEN VALKEYMODULE_POSTPONED_ARRAY_LEN +#define REDISMODULE_POSTPONED_LEN VALKEYMODULE_POSTPONED_LEN +#define REDISMODULE_NO_EXPIRE VALKEYMODULE_NO_EXPIRE +#define REDISMODULE_ZADD_XX VALKEYMODULE_ZADD_XX +#define REDISMODULE_ZADD_NX VALKEYMODULE_ZADD_NX +#define REDISMODULE_ZADD_ADDED VALKEYMODULE_ZADD_ADDED +#define REDISMODULE_ZADD_UPDATED VALKEYMODULE_ZADD_UPDATED +#define REDISMODULE_ZADD_NOP VALKEYMODULE_ZADD_NOP +#define REDISMODULE_ZADD_GT VALKEYMODULE_ZADD_GT +#define REDISMODULE_ZADD_LT VALKEYMODULE_ZADD_LT +#define REDISMODULE_HASH_NONE VALKEYMODULE_HASH_NONE +#define REDISMODULE_HASH_NX VALKEYMODULE_HASH_NX +#define REDISMODULE_HASH_XX VALKEYMODULE_HASH_XX +#define REDISMODULE_HASH_CFIELDS VALKEYMODULE_HASH_CFIELDS +#define REDISMODULE_HASH_EXISTS VALKEYMODULE_HASH_EXISTS +#define REDISMODULE_HASH_COUNT_ALL VALKEYMODULE_HASH_COUNT_ALL +#define REDISMODULE_CONFIG_DEFAULT VALKEYMODULE_CONFIG_DEFAULT +#define REDISMODULE_CONFIG_IMMUTABLE VALKEYMODULE_CONFIG_IMMUTABLE +#define REDISMODULE_CONFIG_SENSITIVE VALKEYMODULE_CONFIG_SENSITIVE +#define REDISMODULE_CONFIG_HIDDEN VALKEYMODULE_CONFIG_HIDDEN +#define REDISMODULE_CONFIG_PROTECTED VALKEYMODULE_CONFIG_PROTECTED +#define REDISMODULE_CONFIG_DENY_LOADING VALKEYMODULE_CONFIG_DENY_LOADING +#define REDISMODULE_CONFIG_MEMORY VALKEYMODULE_CONFIG_MEMORY +#define REDISMODULE_CONFIG_BITFLAGS VALKEYMODULE_CONFIG_BITFLAGS +#define REDISMODULE_STREAM_ADD_AUTOID VALKEYMODULE_STREAM_ADD_AUTOID +#define REDISMODULE_STREAM_ITERATOR_EXCLUSIVE VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE +#define REDISMODULE_STREAM_ITERATOR_REVERSE VALKEYMODULE_STREAM_ITERATOR_REVERSE +#define REDISMODULE_STREAM_TRIM_APPROX VALKEYMODULE_STREAM_TRIM_APPROX +#define REDISMODULE_CTX_FLAGS_LUA VALKEYMODULE_CTX_FLAGS_LUA +#define REDISMODULE_CTX_FLAGS_MULTI VALKEYMODULE_CTX_FLAGS_MULTI +#define REDISMODULE_CTX_FLAGS_MASTER VALKEYMODULE_CTX_FLAGS_PRIMARY +#define REDISMODULE_CTX_FLAGS_SLAVE VALKEYMODULE_CTX_FLAGS_REPLICA +#define REDISMODULE_CTX_FLAGS_READONLY VALKEYMODULE_CTX_FLAGS_READONLY +#define REDISMODULE_CTX_FLAGS_CLUSTER VALKEYMODULE_CTX_FLAGS_CLUSTER +#define REDISMODULE_CTX_FLAGS_AOF VALKEYMODULE_CTX_FLAGS_AOF +#define REDISMODULE_CTX_FLAGS_RDB VALKEYMODULE_CTX_FLAGS_RDB +#define REDISMODULE_CTX_FLAGS_MAXMEMORY VALKEYMODULE_CTX_FLAGS_MAXMEMORY +#define REDISMODULE_CTX_FLAGS_EVICT VALKEYMODULE_CTX_FLAGS_EVICT +#define REDISMODULE_CTX_FLAGS_OOM VALKEYMODULE_CTX_FLAGS_OOM +#define REDISMODULE_CTX_FLAGS_OOM_WARNING VALKEYMODULE_CTX_FLAGS_OOM_WARNING +#define REDISMODULE_CTX_FLAGS_REPLICATED VALKEYMODULE_CTX_FLAGS_REPLICATED +#define REDISMODULE_CTX_FLAGS_LOADING VALKEYMODULE_CTX_FLAGS_LOADING +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE +#define REDISMODULE_CTX_FLAGS_ACTIVE_CHILD VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD +#define REDISMODULE_CTX_FLAGS_MULTI_DIRTY VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY +#define REDISMODULE_CTX_FLAGS_IS_CHILD VALKEYMODULE_CTX_FLAGS_IS_CHILD +#define REDISMODULE_CTX_FLAGS_DENY_BLOCKING VALKEYMODULE_CTX_FLAGS_DENY_BLOCKING +#define REDISMODULE_CTX_FLAGS_RESP3 VALKEYMODULE_CTX_FLAGS_RESP3 +#define REDISMODULE_CTX_FLAGS_ASYNC_LOADING VALKEYMODULE_CTX_FLAGS_ASYNC_LOADING +#define REDISMODULE_CTX_FLAGS_SERVER_STARTUP VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP +#define REDISMODULE_NOTIFY_KEYSPACE VALKEYMODULE_NOTIFY_KEYSPACE +#define REDISMODULE_NOTIFY_KEYEVENT VALKEYMODULE_NOTIFY_KEYEVENT +#define REDISMODULE_NOTIFY_GENERIC VALKEYMODULE_NOTIFY_GENERIC +#define REDISMODULE_NOTIFY_STRING VALKEYMODULE_NOTIFY_STRING +#define REDISMODULE_NOTIFY_LIST VALKEYMODULE_NOTIFY_LIST +#define REDISMODULE_NOTIFY_SET VALKEYMODULE_NOTIFY_SET +#define REDISMODULE_NOTIFY_HASH VALKEYMODULE_NOTIFY_HASH +#define REDISMODULE_NOTIFY_ZSET VALKEYMODULE_NOTIFY_ZSET +#define REDISMODULE_NOTIFY_EXPIRED VALKEYMODULE_NOTIFY_EXPIRED +#define REDISMODULE_NOTIFY_EVICTED VALKEYMODULE_NOTIFY_EVICTED +#define REDISMODULE_NOTIFY_STREAM VALKEYMODULE_NOTIFY_STREAM +#define REDISMODULE_NOTIFY_KEY_MISS VALKEYMODULE_NOTIFY_KEY_MISS +#define REDISMODULE_NOTIFY_LOADED VALKEYMODULE_NOTIFY_LOADED +#define REDISMODULE_NOTIFY_MODULE VALKEYMODULE_NOTIFY_MODULE +#define REDISMODULE_NOTIFY_NEW VALKEYMODULE_NOTIFY_NEW +#define REDISMODULE_NOTIFY_ALL VALKEYMODULE_NOTIFY_ALL +#define REDISMODULE_HASH_DELETE VALKEYMODULE_HASH_DELETE +#define REDISMODULE_ERRORMSG_WRONGTYPE VALKEYMODULE_ERRORMSG_WRONGTYPE +#define REDISMODULE_POSITIVE_INFINITE VALKEYMODULE_POSITIVE_INFINITE +#define REDISMODULE_NEGATIVE_INFINITE VALKEYMODULE_NEGATIVE_INFINITE +#define REDISMODULE_NODE_ID_LEN VALKEYMODULE_NODE_ID_LEN +#define REDISMODULE_NODE_MYSELF VALKEYMODULE_NODE_MYSELF +#define REDISMODULE_NODE_MASTER VALKEYMODULE_NODE_PRIMARY +#define REDISMODULE_NODE_SLAVE VALKEYMODULE_NODE_REPLICA +#define REDISMODULE_NODE_PFAIL VALKEYMODULE_NODE_PFAIL +#define REDISMODULE_NODE_FAIL VALKEYMODULE_NODE_FAIL +#define REDISMODULE_NODE_NOFAILOVER VALKEYMODULE_NODE_NOFAILOVER +#define REDISMODULE_CLUSTER_FLAG_NONE VALKEYMODULE_CLUSTER_FLAG_NONE +#define REDISMODULE_CLUSTER_FLAG_NO_FAILOVER VALKEYMODULE_CLUSTER_FLAG_NO_FAILOVER +#define REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION +#define REDISMODULE_NOT_USED(V) VALKEYMODULE_NOT_USED(V) +#define REDISMODULE_LOGLEVEL_DEBUG VALKEYMODULE_LOGLEVEL_DEBUG +#define REDISMODULE_LOGLEVEL_VERBOSE VALKEYMODULE_LOGLEVEL_VERBOSE +#define REDISMODULE_LOGLEVEL_NOTICE VALKEYMODULE_LOGLEVEL_NOTICE +#define REDISMODULE_LOGLEVEL_WARNING VALKEYMODULE_LOGLEVEL_WARNING +#define REDISMODULE_AUX_BEFORE_RDB VALKEYMODULE_AUX_BEFORE_RDB +#define REDISMODULE_AUX_AFTER_RDB VALKEYMODULE_AUX_AFTER_RDB +#define REDISMODULE_YIELD_FLAG_NONE VALKEYMODULE_YIELD_FLAG_NONE +#define REDISMODULE_YIELD_FLAG_CLIENTS VALKEYMODULE_YIELD_FLAG_CLIENTS +#define REDISMODULE_BLOCK_UNBLOCK_DEFAULT VALKEYMODULE_BLOCK_UNBLOCK_DEFAULT +#define REDISMODULE_BLOCK_UNBLOCK_DELETED VALKEYMODULE_BLOCK_UNBLOCK_DELETED +#define REDISMODULE_CMDFILTER_NOSELF VALKEYMODULE_CMDFILTER_NOSELF +#define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS +#define REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED +#define REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD +#define REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS +#define REDISMODULE_CMD_ARG_NONE VALKEYMODULE_CMD_ARG_NONE +#define REDISMODULE_CMD_ARG_OPTIONAL VALKEYMODULE_CMD_ARG_OPTIONAL +#define REDISMODULE_CMD_ARG_MULTIPLE VALKEYMODULE_CMD_ARG_MULTIPLE +#define REDISMODULE_CMD_ARG_MULTIPLE_TOKEN VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN +#define REDISMODULE_CMD_KEY_RO VALKEYMODULE_CMD_KEY_RO +#define REDISMODULE_CMD_KEY_RW VALKEYMODULE_CMD_KEY_RW +#define REDISMODULE_CMD_KEY_OW VALKEYMODULE_CMD_KEY_OW +#define REDISMODULE_CMD_KEY_RM VALKEYMODULE_CMD_KEY_RM +#define REDISMODULE_CMD_KEY_ACCESS VALKEYMODULE_CMD_KEY_ACCESS +#define REDISMODULE_CMD_KEY_UPDATE VALKEYMODULE_CMD_KEY_UPDATE +#define REDISMODULE_CMD_KEY_INSERT VALKEYMODULE_CMD_KEY_INSERT +#define REDISMODULE_CMD_KEY_DELETE VALKEYMODULE_CMD_KEY_DELETE +#define REDISMODULE_CMD_KEY_NOT_KEY VALKEYMODULE_CMD_KEY_NOT_KEY +#define REDISMODULE_CMD_KEY_INCOMPLETE VALKEYMODULE_CMD_KEY_INCOMPLETE +#define REDISMODULE_CMD_KEY_VARIABLE_FLAGS VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS +#define REDISMODULE_CMD_CHANNEL_PATTERN VALKEYMODULE_CMD_CHANNEL_PATTERN +#define REDISMODULE_CMD_CHANNEL_PUBLISH VALKEYMODULE_CMD_CHANNEL_PUBLISH +#define REDISMODULE_CMD_CHANNEL_SUBSCRIBE VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE +#define REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE +#define REDISMODULE_COMMAND_INFO_VERSION VALKEYMODULE_COMMAND_INFO_VERSION +#define REDISMODULE_EVENTLOOP_READABLE VALKEYMODULE_EVENTLOOP_READABLE +#define REDISMODULE_EVENTLOOP_WRITABLE VALKEYMODULE_EVENTLOOP_WRITABLE +#define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED +#define REDISMODULE_EVENT_PERSISTENCE VALKEYMODULE_EVENT_PERSISTENCE +#define REDISMODULE_EVENT_FLUSHDB VALKEYMODULE_EVENT_FLUSHDB +#define REDISMODULE_EVENT_LOADING VALKEYMODULE_EVENT_LOADING +#define REDISMODULE_EVENT_CLIENT_CHANGE VALKEYMODULE_EVENT_CLIENT_CHANGE +#define REDISMODULE_EVENT_SHUTDOWN VALKEYMODULE_EVENT_SHUTDOWN +#define REDISMODULE_EVENT_REPLICA_CHANGE VALKEYMODULE_EVENT_REPLICA_CHANGE +#define REDISMODULE_EVENT_MASTER_LINK_CHANGE VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE +#define REDISMODULE_EVENT_CRON_LOOP VALKEYMODULE_EVENT_CRON_LOOP +#define REDISMODULE_EVENT_MODULE_CHANGE VALKEYMODULE_EVENT_MODULE_CHANGE +#define REDISMODULE_EVENT_LOADING_PROGRESS VALKEYMODULE_EVENT_LOADING_PROGRESS +#define REDISMODULE_EVENT_SWAPDB VALKEYMODULE_EVENT_SWAPDB +#define REDISMODULE_EVENT_REPL_BACKUP VALKEYMODULE_EVENT_REPL_BACKUP +#define REDISMODULE_EVENT_FORK_CHILD VALKEYMODULE_EVENT_FORK_CHILD +#define REDISMODULE_EVENT_REPL_ASYNC_LOAD VALKEYMODULE_EVENT_REPL_ASYNC_LOAD +#define REDISMODULE_EVENT_EVENTLOOP VALKEYMODULE_EVENT_EVENTLOOP +#define REDISMODULE_EVENT_CONFIG VALKEYMODULE_EVENT_CONFIG +#define REDISMODULE_EVENT_KEY VALKEYMODULE_EVENT_KEY +#define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START +#define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START +#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START +#define REDISMODULE_SUBEVENT_PERSISTENCE_ENDED VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED +#define REDISMODULE_SUBEVENT_PERSISTENCE_FAILED VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED +#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START +#define REDISMODULE_SUBEVENT_LOADING_RDB_START VALKEYMODULE_SUBEVENT_LOADING_RDB_START +#define REDISMODULE_SUBEVENT_LOADING_AOF_START VALKEYMODULE_SUBEVENT_LOADING_AOF_START +#define REDISMODULE_SUBEVENT_LOADING_REPL_START VALKEYMODULE_SUBEVENT_LOADING_REPL_START +#define REDISMODULE_SUBEVENT_LOADING_ENDED VALKEYMODULE_SUBEVENT_LOADING_ENDED +#define REDISMODULE_SUBEVENT_LOADING_FAILED VALKEYMODULE_SUBEVENT_LOADING_FAILED +#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED +#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED +#define REDISMODULE_SUBEVENT_MASTER_LINK_UP VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP +#define REDISMODULE_SUBEVENT_MASTER_LINK_DOWN VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN +#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE +#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE +#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY +#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA +#define REDISMODULE_SUBEVENT_FLUSHDB_START VALKEYMODULE_SUBEVENT_FLUSHDB_START +#define REDISMODULE_SUBEVENT_FLUSHDB_END VALKEYMODULE_SUBEVENT_FLUSHDB_END +#define REDISMODULE_SUBEVENT_MODULE_LOADED VALKEYMODULE_SUBEVENT_MODULE_LOADED +#define REDISMODULE_SUBEVENT_MODULE_UNLOADED VALKEYMODULE_SUBEVENT_MODULE_UNLOADED +#define REDISMODULE_SUBEVENT_CONFIG_CHANGE VALKEYMODULE_SUBEVENT_CONFIG_CHANGE +#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB +#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF +#define REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE VALKEYMODULE_SUBEVENT_REPL_BACKUP_CREATE +#define REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE VALKEYMODULE_SUBEVENT_REPL_BACKUP_RESTORE +#define REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD VALKEYMODULE_SUBEVENT_REPL_BACKUP_DISCARD +#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED +#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED +#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED +#define REDISMODULE_SUBEVENT_FORK_CHILD_BORN VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN +#define REDISMODULE_SUBEVENT_FORK_CHILD_DIED VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED +#define REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP +#define REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP +#define REDISMODULE_SUBEVENT_KEY_DELETED VALKEYMODULE_SUBEVENT_KEY_DELETED +#define REDISMODULE_SUBEVENT_KEY_EXPIRED VALKEYMODULE_SUBEVENT_KEY_EXPIRED +#define REDISMODULE_SUBEVENT_KEY_EVICTED VALKEYMODULE_SUBEVENT_KEY_EVICTED +#define REDISMODULE_SUBEVENT_KEY_OVERWRITTEN VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN +#define REDISMODULE_CLIENTINFO_FLAG_SSL VALKEYMODULE_CLIENTINFO_FLAG_SSL +#define REDISMODULE_CLIENTINFO_FLAG_PUBSUB VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB +#define REDISMODULE_CLIENTINFO_FLAG_BLOCKED VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED +#define REDISMODULE_CLIENTINFO_FLAG_TRACKING VALKEYMODULE_CLIENTINFO_FLAG_TRACKING +#define REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET +#define REDISMODULE_CLIENTINFO_FLAG_MULTI VALKEYMODULE_CLIENTINFO_FLAG_MULTI +#define REDISMODULE_CLIENTINFO_VERSION VALKEYMODULE_CLIENTINFO_VERSION +#define REDISMODULE_CLIENTINFO_INITIALIZER_V1 VALKEYMODULE_CLIENTINFO_INITIALIZER_V1 +#define REDISMODULE_REPLICATIONINFO_VERSION VALKEYMODULE_REPLICATIONINFO_VERSION +#define REDISMODULE_FLUSHINFO_VERSION VALKEYMODULE_FLUSHINFO_VERSION +#define REDISMODULE_MODULE_CHANGE_VERSION VALKEYMODULE_MODULE_CHANGE_VERSION +#define REDISMODULE_CONFIGCHANGE_VERSION VALKEYMODULE_CONFIGCHANGE_VERSION +#define REDISMODULE_CRON_LOOP_VERSION VALKEYMODULE_CRON_LOOP_VERSION +#define REDISMODULE_LOADING_PROGRESS_VERSION VALKEYMODULE_LOADING_PROGRESS_VERSION +#define REDISMODULE_SWAPDBINFO_VERSION VALKEYMODULE_SWAPDBINFO_VERSION +#define REDISMODULE_KEYINFO_VERSION VALKEYMODULE_KEYINFO_VERSION +#define REDISMODULE_GET_API(name) VALKEYMODULE_GET_API(name) +#define REDISMODULE_API VALKEYMODULE_API +#define REDISMODULE_ATTR VALKEYMODULE_ATTR + +#define REDISMODULE_ACL_LOG_AUTH VALKEYMODULE_ACL_LOG_AUTH +#define REDISMODULE_ACL_LOG_CMD VALKEYMODULE_ACL_LOG_CMD +#define REDISMODULE_ACL_LOG_KEY VALKEYMODULE_ACL_LOG_KEY +#define REDISMODULE_ACL_LOG_CHANNEL VALKEYMODULE_ACL_LOG_CHANNEL + +#define REDISMODULE_KSPEC_BS_INVALID VALKEYMODULE_KSPEC_BS_INVALID +#define REDISMODULE_KSPEC_BS_UNKNOWN VALKEYMODULE_KSPEC_BS_UNKNOWN +#define REDISMODULE_KSPEC_BS_INDEX VALKEYMODULE_KSPEC_BS_INDEX +#define REDISMODULE_KSPEC_BS_KEYWORD VALKEYMODULE_KSPEC_BS_KEYWORD + +#define REDISMODULE_KSPEC_FK_OMITTED VALKEYMODULE_KSPEC_FK_OMITTED +#define REDISMODULE_KSPEC_FK_UNKNOWN VALKEYMODULE_KSPEC_FK_UNKNOWN +#define REDISMODULE_KSPEC_FK_RANGE VALKEYMODULE_KSPEC_FK_RANGE +#define REDISMODULE_KSPEC_FK_KEYNUM VALKEYMODULE_KSPEC_FK_KEYNUM + +#define REDISMODULE_ARG_TYPE_STRING VALKEYMODULE_ARG_TYPE_STRING +#define REDISMODULE_ARG_TYPE_INTEGER VALKEYMODULE_ARG_TYPE_INTEGER +#define REDISMODULE_ARG_TYPE_DOUBLE VALKEYMODULE_ARG_TYPE_DOUBLE +#define REDISMODULE_ARG_TYPE_KEY VALKEYMODULE_ARG_TYPE_KEY +#define REDISMODULE_ARG_TYPE_PATTERN VALKEYMODULE_ARG_TYPE_PATTERN +#define REDISMODULE_ARG_TYPE_UNIX_TIME VALKEYMODULE_ARG_TYPE_UNIX_TIME +#define REDISMODULE_ARG_TYPE_PURE_TOKEN VALKEYMODULE_ARG_TYPE_PURE_TOKEN +#define REDISMODULE_ARG_TYPE_ONEOF VALKEYMODULE_ARG_TYPE_ONEOF +#define REDISMODULE_ARG_TYPE_BLOCK VALKEYMODULE_ARG_TYPE_BLOCK + +/* RedisModule typedefs */ +#define RedisModuleString ValkeyModuleString +#define RedisModuleKey ValkeyModuleKey +#define RedisModuleStreamID ValkeyModuleStreamID +#define RedisModuleCommandArg ValkeyModuleCommandArg +#define RedisModuleEvent ValkeyModuleEvent +#define RedisModuleClientInfo ValkeyModuleClientInfo +#define RedisModuleReplicationInfo ValkeyModuleReplicationInfo +#define RedisModuleFlushInfo ValkeyModuleFlushInfo +#define RedisModuleModuleChange ValkeyModuleModuleChange +#define RedisModuleConfigChange ValkeyModuleConfigChange +#define RedisModuleCronLoopInfo ValkeyModuleCronLoopInfo +#define RedisModuleLoadingProgressInfo ValkeyModuleLoadingProgressInfo +#define RedisModuleSwapDbInfo ValkeyModuleSwapDbInfo +#define RedisModuleKeyInfo ValkeyModuleKeyInfo +#define RedisModuleIO ValkeyModuleIO +#define RedisModuleDigest ValkeyModuleDigest +#define RedisModuleInfoCtx ValkeyModuleInfoCtx +#define RedisModuleDefragCtx ValkeyModuleDefragCtx +#define RedisModuleCtx ValkeyModuleCtx +#define RedisModuleCommand ValkeyModuleCommand +#define RedisModuleCallReply ValkeyModuleCallReply +#define RedisModuleType ValkeyModuleType +#define RedisModuleBlockedClient ValkeyModuleBlockedClient +#define RedisModuleClusterInfo ValkeyModuleClusterInfo +#define RedisModuleDict ValkeyModuleDict +#define RedisModuleDictIter ValkeyModuleDictIter +#define RedisModuleCommandFilterCtx ValkeyModuleCommandFilterCtx +#define RedisModuleCommandFilter ValkeyModuleCommandFilter +#define RedisModuleServerInfoData ValkeyModuleServerInfoData +#define RedisModuleScanCursor ValkeyModuleScanCursor +#define RedisModuleUser ValkeyModuleUser +#define RedisModuleKeyOptCtx ValkeyModuleKeyOptCtx +#define RedisModuleRdbStream ValkeyModuleRdbStream +#define RedisModuleTypeMethods ValkeyModuleTypeMethods +#define RedisModuleTimerID ValkeyModuleTimerID +#define RedisModuleClientInfo ValkeyModuleClientInfo +#define RedisModuleClientInfoV1 ValkeyModuleClientInfoV1 +#define RedisModuleLoadingProgress ValkeyModuleLoadingProgress +#define RedisModuleCronLoop ValkeyModuleCronLoop +#define RedisModuleConfigChangeV1 ValkeyModuleConfigChangeV1 +#define RedisModuleKeyInfoV1 ValkeyModuleKeyInfoV1 +#define RedisModuleCommandInfo ValkeyModuleCommandInfo +#define RedisModuleCommandKeySpec ValkeyModuleCommandKeySpec +#define RedisModuleCommandHistoryEntry ValkeyModuleCommandHistoryEntry + +/* RedisModule APIs */ +#define RedisModule_OnLoad ValkeyModule_OnLoad +#define RedisModule_Init ValkeyModule_Init +#define RedisModule_Assert ValkeyModule_Assert +#define RedisModule_Alloc ValkeyModule_Alloc +#define RedisModule_TryAlloc ValkeyModule_TryAlloc +#define RedisModule_Realloc ValkeyModule_Realloc +#define RedisModule_TryRealloc ValkeyModule_TryRealloc +#define RedisModule_Free ValkeyModule_Free +#define RedisModule_Calloc ValkeyModule_Calloc +#define RedisModule_TryCalloc ValkeyModule_TryCalloc +#define RedisModule_Strdup ValkeyModule_Strdup +#define RedisModule_GetApi ValkeyModule_GetApi +#define RedisModule_CreateCommand ValkeyModule_CreateCommand +#define RedisModule_GetCommand ValkeyModule_GetCommand +#define RedisModule_CreateSubcommand ValkeyModule_CreateSubcommand +#define RedisModule_SetCommandInfo ValkeyModule_SetCommandInfo +#define RedisModule_SetCommandACLCategories ValkeyModule_SetCommandACLCategories +#define RedisModule_AddACLCategory ValkeyModule_AddACLCategory +#define RedisModule_SetModuleAttribs ValkeyModule_SetModuleAttribs +#define RedisModule_IsModuleNameBusy ValkeyModule_IsModuleNameBusy +#define RedisModule_WrongArity ValkeyModule_WrongArity +#define RedisModule_ReplyWithLongLong ValkeyModule_ReplyWithLongLong +#define RedisModule_GetSelectedDb ValkeyModule_GetSelectedDb +#define RedisModule_SelectDb ValkeyModule_SelectDb +#define RedisModule_KeyExists ValkeyModule_KeyExists +#define RedisModule_OpenKey ValkeyModule_OpenKey +#define RedisModule_GetOpenKeyModesAll ValkeyModule_GetOpenKeyModesAll +#define RedisModule_CloseKey ValkeyModule_CloseKey +#define RedisModule_KeyType ValkeyModule_KeyType +#define RedisModule_ValueLength ValkeyModule_ValueLength +#define RedisModule_ListPush ValkeyModule_ListPush +#define RedisModule_ListPop ValkeyModule_ListPop +#define RedisModule_ListGet ValkeyModule_ListGet +#define RedisModule_ListSet ValkeyModule_ListSet +#define RedisModule_ListInsert ValkeyModule_ListInsert +#define RedisModule_ListDelete ValkeyModule_ListDelete +#define RedisModule_Call ValkeyModule_Call +#define RedisModule_CallReplyProto ValkeyModule_CallReplyProto +#define RedisModule_FreeCallReply ValkeyModule_FreeCallReply +#define RedisModule_CallReplyType ValkeyModule_CallReplyType +#define RedisModule_CallReplyInteger ValkeyModule_CallReplyInteger +#define RedisModule_CallReplyDouble ValkeyModule_CallReplyDouble +#define RedisModule_CallReplyBool ValkeyModule_CallReplyBool +#define RedisModule_CallReplyBigNumber ValkeyModule_CallReplyBigNumber +#define RedisModule_CallReplyVerbatim ValkeyModule_CallReplyVerbatim +#define RedisModule_CallReplySetElement ValkeyModule_CallReplySetElement +#define RedisModule_CallReplyMapElement ValkeyModule_CallReplyMapElement +#define RedisModule_CallReplyAttributeElement ValkeyModule_CallReplyAttributeElement +#define RedisModule_CallReplyPromiseSetUnblockHandler ValkeyModule_CallReplyPromiseSetUnblockHandler +#define RedisModule_CallReplyPromiseAbort ValkeyModule_CallReplyPromiseAbort +#define RedisModule_CallReplyAttribute ValkeyModule_CallReplyAttribute +#define RedisModule_CallReplyLength ValkeyModule_CallReplyLength +#define RedisModule_CallReplyArrayElement ValkeyModule_CallReplyArrayElement +#define RedisModule_CreateString ValkeyModule_CreateString +#define RedisModule_CreateStringFromLongLong ValkeyModule_CreateStringFromLongLong +#define RedisModule_CreateStringFromULongLong ValkeyModule_CreateStringFromULongLong +#define RedisModule_CreateStringFromDouble ValkeyModule_CreateStringFromDouble +#define RedisModule_CreateStringFromLongDouble ValkeyModule_CreateStringFromLongDouble +#define RedisModule_CreateStringFromString ValkeyModule_CreateStringFromString +#define RedisModule_CreateStringFromStreamID ValkeyModule_CreateStringFromStreamID +#define RedisModule_CreateStringPrintf ValkeyModule_CreateStringPrintf +#define RedisModule_FreeString ValkeyModule_FreeString +#define RedisModule_StringPtrLen ValkeyModule_StringPtrLen +#define RedisModule_ReplyWithError ValkeyModule_ReplyWithError +#define RedisModule_ReplyWithErrorFormat ValkeyModule_ReplyWithErrorFormat +#define RedisModule_ReplyWithSimpleString ValkeyModule_ReplyWithSimpleString +#define RedisModule_ReplyWithArray ValkeyModule_ReplyWithArray +#define RedisModule_ReplyWithMap ValkeyModule_ReplyWithMap +#define RedisModule_ReplyWithSet ValkeyModule_ReplyWithSet +#define RedisModule_ReplyWithAttribute ValkeyModule_ReplyWithAttribute +#define RedisModule_ReplyWithNullArray ValkeyModule_ReplyWithNullArray +#define RedisModule_ReplyWithEmptyArray ValkeyModule_ReplyWithEmptyArray +#define RedisModule_ReplySetArrayLength ValkeyModule_ReplySetArrayLength +#define RedisModule_ReplySetMapLength ValkeyModule_ReplySetMapLength +#define RedisModule_ReplySetSetLength ValkeyModule_ReplySetSetLength +#define RedisModule_ReplySetAttributeLength ValkeyModule_ReplySetAttributeLength +#define RedisModule_ReplySetPushLength ValkeyModule_ReplySetPushLength +#define RedisModule_ReplyWithStringBuffer ValkeyModule_ReplyWithStringBuffer +#define RedisModule_ReplyWithCString ValkeyModule_ReplyWithCString +#define RedisModule_ReplyWithString ValkeyModule_ReplyWithString +#define RedisModule_ReplyWithEmptyString ValkeyModule_ReplyWithEmptyString +#define RedisModule_ReplyWithVerbatimString ValkeyModule_ReplyWithVerbatimString +#define RedisModule_ReplyWithVerbatimStringType ValkeyModule_ReplyWithVerbatimStringType +#define RedisModule_ReplyWithNull ValkeyModule_ReplyWithNull +#define RedisModule_ReplyWithBool ValkeyModule_ReplyWithBool +#define RedisModule_ReplyWithLongDouble ValkeyModule_ReplyWithLongDouble +#define RedisModule_ReplyWithDouble ValkeyModule_ReplyWithDouble +#define RedisModule_ReplyWithBigNumber ValkeyModule_ReplyWithBigNumber +#define RedisModule_ReplyWithCallReply ValkeyModule_ReplyWithCallReply +#define RedisModule_StringToLongLong ValkeyModule_StringToLongLong +#define RedisModule_StringToULongLong ValkeyModule_StringToULongLong +#define RedisModule_StringToDouble ValkeyModule_StringToDouble +#define RedisModule_StringToLongDouble ValkeyModule_StringToLongDouble +#define RedisModule_StringToStreamID ValkeyModule_StringToStreamID +#define RedisModule_AutoMemory ValkeyModule_AutoMemory +#define RedisModule_Replicate ValkeyModule_Replicate +#define RedisModule_ReplicateVerbatim ValkeyModule_ReplicateVerbatim +#define RedisModule_CallReplyStringPtr ValkeyModule_CallReplyStringPtr +#define RedisModule_CreateStringFromCallReply ValkeyModule_CreateStringFromCallReply +#define RedisModule_DeleteKey ValkeyModule_DeleteKey +#define RedisModule_UnlinkKey ValkeyModule_UnlinkKey +#define RedisModule_StringSet ValkeyModule_StringSet +#define RedisModule_StringDMA ValkeyModule_StringDMA +#define RedisModule_StringTruncate ValkeyModule_StringTruncate +#define RedisModule_GetExpire ValkeyModule_GetExpire +#define RedisModule_SetExpire ValkeyModule_SetExpire +#define RedisModule_GetAbsExpire ValkeyModule_GetAbsExpire +#define RedisModule_SetAbsExpire ValkeyModule_SetAbsExpire +#define RedisModule_ResetDataset ValkeyModule_ResetDataset +#define RedisModule_DbSize ValkeyModule_DbSize +#define RedisModule_RandomKey ValkeyModule_RandomKey +#define RedisModule_ZsetAdd ValkeyModule_ZsetAdd +#define RedisModule_ZsetIncrby ValkeyModule_ZsetIncrby +#define RedisModule_ZsetScore ValkeyModule_ZsetScore +#define RedisModule_ZsetRem ValkeyModule_ZsetRem +#define RedisModule_ZsetRangeStop ValkeyModule_ZsetRangeStop +#define RedisModule_ZsetFirstInScoreRange ValkeyModule_ZsetFirstInScoreRange +#define RedisModule_ZsetLastInScoreRange ValkeyModule_ZsetLastInScoreRange +#define RedisModule_ZsetFirstInLexRange ValkeyModule_ZsetFirstInLexRange +#define RedisModule_ZsetLastInLexRange ValkeyModule_ZsetLastInLexRange +#define RedisModule_ZsetRangeCurrentElement ValkeyModule_ZsetRangeCurrentElement +#define RedisModule_ZsetRangeNext ValkeyModule_ZsetRangeNext +#define RedisModule_ZsetRangePrev ValkeyModule_ZsetRangePrev +#define RedisModule_ZsetRangeEndReached ValkeyModule_ZsetRangeEndReached +#define RedisModule_HashSet ValkeyModule_HashSet +#define RedisModule_HashGet ValkeyModule_HashGet +#define RedisModule_StreamAdd ValkeyModule_StreamAdd +#define RedisModule_StreamDelete ValkeyModule_StreamDelete +#define RedisModule_StreamIteratorStart ValkeyModule_StreamIteratorStart +#define RedisModule_StreamIteratorStop ValkeyModule_StreamIteratorStop +#define RedisModule_StreamIteratorNextID ValkeyModule_StreamIteratorNextID +#define RedisModule_StreamIteratorNextField ValkeyModule_StreamIteratorNextField +#define RedisModule_StreamIteratorDelete ValkeyModule_StreamIteratorDelete +#define RedisModule_StreamTrimByLength ValkeyModule_StreamTrimByLength +#define RedisModule_StreamTrimByID ValkeyModule_StreamTrimByID +#define RedisModule_IsKeysPositionRequest ValkeyModule_IsKeysPositionRequest +#define RedisModule_KeyAtPos ValkeyModule_KeyAtPos +#define RedisModule_KeyAtPosWithFlags ValkeyModule_KeyAtPosWithFlags +#define RedisModule_IsChannelsPositionRequest ValkeyModule_IsChannelsPositionRequest +#define RedisModule_ChannelAtPosWithFlags ValkeyModule_ChannelAtPosWithFlags +#define RedisModule_GetClientId ValkeyModule_GetClientId +#define RedisModule_GetClientUserNameById ValkeyModule_GetClientUserNameById +#define RedisModule_GetClientInfoById ValkeyModule_GetClientInfoById +#define RedisModule_GetClientNameById ValkeyModule_GetClientNameById +#define RedisModule_SetClientNameById ValkeyModule_SetClientNameById +#define RedisModule_PublishMessage ValkeyModule_PublishMessage +#define RedisModule_PublishMessageShard ValkeyModule_PublishMessageShard +#define RedisModule_GetContextFlags ValkeyModule_GetContextFlags +#define RedisModule_AvoidReplicaTraffic ValkeyModule_AvoidReplicaTraffic +#define RedisModule_PoolAlloc ValkeyModule_PoolAlloc +#define RedisModule_CreateDataType ValkeyModule_CreateDataType +#define RedisModule_ModuleTypeSetValue ValkeyModule_ModuleTypeSetValue +#define RedisModule_ModuleTypeReplaceValue ValkeyModule_ModuleTypeReplaceValue +#define RedisModule_ModuleTypeGetType ValkeyModule_ModuleTypeGetType +#define RedisModule_ModuleTypeGetValue ValkeyModule_ModuleTypeGetValue +#define RedisModule_IsIOError ValkeyModule_IsIOError +#define RedisModule_SetModuleOptions ValkeyModule_SetModuleOptions +#define RedisModule_SignalModifiedKey ValkeyModule_SignalModifiedKey +#define RedisModule_SaveUnsigned ValkeyModule_SaveUnsigned +#define RedisModule_LoadUnsigned ValkeyModule_LoadUnsigned +#define RedisModule_SaveSigned ValkeyModule_SaveSigned +#define RedisModule_LoadSigned ValkeyModule_LoadSigned +#define RedisModule_EmitAOF ValkeyModule_EmitAOF +#define RedisModule_SaveString ValkeyModule_SaveString +#define RedisModule_SaveStringBuffer ValkeyModule_SaveStringBuffer +#define RedisModule_LoadString ValkeyModule_LoadString +#define RedisModule_LoadStringBuffer ValkeyModule_LoadStringBuffer +#define RedisModule_SaveDouble ValkeyModule_SaveDouble +#define RedisModule_LoadDouble ValkeyModule_LoadDouble +#define RedisModule_SaveFloat ValkeyModule_SaveFloat +#define RedisModule_LoadFloat ValkeyModule_LoadFloat +#define RedisModule_SaveLongDouble ValkeyModule_SaveLongDouble +#define RedisModule_LoadLongDouble ValkeyModule_LoadLongDouble +#define RedisModule_LoadDataTypeFromString ValkeyModule_LoadDataTypeFromString +#define RedisModule_LoadDataTypeFromStringEncver ValkeyModule_LoadDataTypeFromStringEncver +#define RedisModule_SaveDataTypeToString ValkeyModule_SaveDataTypeToString +#define RedisModule_Log ValkeyModule_Log +#define RedisModule_LogIOError ValkeyModule_LogIOError +#define RedisModule__Assert ValkeyModule__Assert +#define RedisModule_LatencyAddSample ValkeyModule_LatencyAddSample +#define RedisModule_StringAppendBuffer ValkeyModule_StringAppendBuffer +#define RedisModule_TrimStringAllocation ValkeyModule_TrimStringAllocation +#define RedisModule_RetainString ValkeyModule_RetainString +#define RedisModule_HoldString ValkeyModule_HoldString +#define RedisModule_StringCompare ValkeyModule_StringCompare +#define RedisModule_GetContextFromIO ValkeyModule_GetContextFromIO +#define RedisModule_GetKeyNameFromIO ValkeyModule_GetKeyNameFromIO +#define RedisModule_GetKeyNameFromModuleKey ValkeyModule_GetKeyNameFromModuleKey +#define RedisModule_GetDbIdFromModuleKey ValkeyModule_GetDbIdFromModuleKey +#define RedisModule_GetDbIdFromIO ValkeyModule_GetDbIdFromIO +#define RedisModule_GetDbIdFromOptCtx ValkeyModule_GetDbIdFromOptCtx +#define RedisModule_GetToDbIdFromOptCtx ValkeyModule_GetToDbIdFromOptCtx +#define RedisModule_GetKeyNameFromOptCtx ValkeyModule_GetKeyNameFromOptCtx +#define RedisModule_GetToKeyNameFromOptCtx ValkeyModule_GetToKeyNameFromOptCtx +#define RedisModule_Milliseconds ValkeyModule_Milliseconds +#define RedisModule_MonotonicMicroseconds ValkeyModule_MonotonicMicroseconds +#define RedisModule_Microseconds ValkeyModule_Microseconds +#define RedisModule_CachedMicroseconds ValkeyModule_CachedMicroseconds +#define RedisModule_DigestAddStringBuffer ValkeyModule_DigestAddStringBuffer +#define RedisModule_DigestAddLongLong ValkeyModule_DigestAddLongLong +#define RedisModule_DigestEndSequence ValkeyModule_DigestEndSequence +#define RedisModule_GetDbIdFromDigest ValkeyModule_GetDbIdFromDigest +#define RedisModule_GetKeyNameFromDigest ValkeyModule_GetKeyNameFromDigest +#define RedisModule_CreateDict ValkeyModule_CreateDict +#define RedisModule_FreeDict ValkeyModule_FreeDict +#define RedisModule_DictSize ValkeyModule_DictSize +#define RedisModule_DictSetC ValkeyModule_DictSetC +#define RedisModule_DictReplaceC ValkeyModule_DictReplaceC +#define RedisModule_DictSet ValkeyModule_DictSet +#define RedisModule_DictReplace ValkeyModule_DictReplace +#define RedisModule_DictGetC ValkeyModule_DictGetC +#define RedisModule_DictGet ValkeyModule_DictGet +#define RedisModule_DictDelC ValkeyModule_DictDelC +#define RedisModule_DictDel ValkeyModule_DictDel +#define RedisModule_DictIteratorStartC ValkeyModule_DictIteratorStartC +#define RedisModule_DictIteratorStart ValkeyModule_DictIteratorStart +#define RedisModule_DictIteratorStop ValkeyModule_DictIteratorStop +#define RedisModule_DictIteratorReseekC ValkeyModule_DictIteratorReseekC +#define RedisModule_DictIteratorReseek ValkeyModule_DictIteratorReseek +#define RedisModule_DictNextC ValkeyModule_DictNextC +#define RedisModule_DictPrevC ValkeyModule_DictPrevC +#define RedisModule_DictNext ValkeyModule_DictNext +#define RedisModule_DictPrev ValkeyModule_DictPrev +#define RedisModule_DictCompareC ValkeyModule_DictCompareC +#define RedisModule_DictCompare ValkeyModule_DictCompare +#define RedisModule_RegisterInfoFunc ValkeyModule_RegisterInfoFunc +#define RedisModule_RegisterAuthCallback ValkeyModule_RegisterAuthCallback +#define RedisModule_InfoAddSection ValkeyModule_InfoAddSection +#define RedisModule_InfoBeginDictField ValkeyModule_InfoBeginDictField +#define RedisModule_InfoEndDictField ValkeyModule_InfoEndDictField +#define RedisModule_InfoAddFieldString ValkeyModule_InfoAddFieldString +#define RedisModule_InfoAddFieldCString ValkeyModule_InfoAddFieldCString +#define RedisModule_InfoAddFieldDouble ValkeyModule_InfoAddFieldDouble +#define RedisModule_InfoAddFieldLongLong ValkeyModule_InfoAddFieldLongLong +#define RedisModule_InfoAddFieldULongLong ValkeyModule_InfoAddFieldULongLong +#define RedisModule_GetServerInfo ValkeyModule_GetServerInfo +#define RedisModule_FreeServerInfo ValkeyModule_FreeServerInfo +#define RedisModule_ServerInfoGetField ValkeyModule_ServerInfoGetField +#define RedisModule_ServerInfoGetFieldC ValkeyModule_ServerInfoGetFieldC +#define RedisModule_ServerInfoGetFieldSigned ValkeyModule_ServerInfoGetFieldSigned +#define RedisModule_ServerInfoGetFieldUnsigned ValkeyModule_ServerInfoGetFieldUnsigned +#define RedisModule_ServerInfoGetFieldDouble ValkeyModule_ServerInfoGetFieldDouble +#define RedisModule_SubscribeToServerEvent ValkeyModule_SubscribeToServerEvent +#define RedisModule_SetLRU ValkeyModule_SetLRU +#define RedisModule_GetLRU ValkeyModule_GetLRU +#define RedisModule_SetLFU ValkeyModule_SetLFU +#define RedisModule_GetLFU ValkeyModule_GetLFU +#define RedisModule_BlockClientOnKeys ValkeyModule_BlockClientOnKeys +#define RedisModule_BlockClientOnKeysWithFlags ValkeyModule_BlockClientOnKeysWithFlags +#define RedisModule_SignalKeyAsReady ValkeyModule_SignalKeyAsReady +#define RedisModule_GetBlockedClientReadyKey ValkeyModule_GetBlockedClientReadyKey +#define RedisModule_ScanCursorCreate ValkeyModule_ScanCursorCreate +#define RedisModule_ScanCursorRestart ValkeyModule_ScanCursorRestart +#define RedisModule_ScanCursorDestroy ValkeyModule_ScanCursorDestroy +#define RedisModule_Scan ValkeyModule_Scan +#define RedisModule_ScanKey ValkeyModule_ScanKey +#define RedisModule_GetContextFlagsAll ValkeyModule_GetContextFlagsAll +#define RedisModule_GetModuleOptionsAll ValkeyModule_GetModuleOptionsAll +#define RedisModule_GetKeyspaceNotificationFlagsAll ValkeyModule_GetKeyspaceNotificationFlagsAll +#define RedisModule_IsSubEventSupported ValkeyModule_IsSubEventSupported +#define RedisModule_GetServerVersion ValkeyModule_GetServerVersion +#define RedisModule_GetTypeMethodVersion ValkeyModule_GetTypeMethodVersion +#define RedisModule_Yield ValkeyModule_Yield +#define RedisModule_BlockClient ValkeyModule_BlockClient +#define RedisModule_BlockClientGetPrivateData ValkeyModule_BlockClientGetPrivateData +#define RedisModule_BlockClientSetPrivateData ValkeyModule_BlockClientSetPrivateData +#define RedisModule_BlockClientOnAuth ValkeyModule_BlockClientOnAuth +#define RedisModule_UnblockClient ValkeyModule_UnblockClient +#define RedisModule_IsBlockedReplyRequest ValkeyModule_IsBlockedReplyRequest +#define RedisModule_IsBlockedTimeoutRequest ValkeyModule_IsBlockedTimeoutRequest +#define RedisModule_GetBlockedClientPrivateData ValkeyModule_GetBlockedClientPrivateData +#define RedisModule_GetBlockedClientHandle ValkeyModule_GetBlockedClientHandle +#define RedisModule_AbortBlock ValkeyModule_AbortBlock +#define RedisModule_BlockedClientMeasureTimeStart ValkeyModule_BlockedClientMeasureTimeStart +#define RedisModule_BlockedClientMeasureTimeEnd ValkeyModule_BlockedClientMeasureTimeEnd +#define RedisModule_GetThreadSafeContext ValkeyModule_GetThreadSafeContext +#define RedisModule_GetDetachedThreadSafeContext ValkeyModule_GetDetachedThreadSafeContext +#define RedisModule_FreeThreadSafeContext ValkeyModule_FreeThreadSafeContext +#define RedisModule_ThreadSafeContextLock ValkeyModule_ThreadSafeContextLock +#define RedisModule_ThreadSafeContextTryLock ValkeyModule_ThreadSafeContextTryLock +#define RedisModule_ThreadSafeContextUnlock ValkeyModule_ThreadSafeContextUnlock +#define RedisModule_SubscribeToKeyspaceEvents ValkeyModule_SubscribeToKeyspaceEvents +#define RedisModule_AddPostNotificationJob ValkeyModule_AddPostNotificationJob +#define RedisModule_NotifyKeyspaceEvent ValkeyModule_NotifyKeyspaceEvent +#define RedisModule_GetNotifyKeyspaceEvents ValkeyModule_GetNotifyKeyspaceEvents +#define RedisModule_BlockedClientDisconnected ValkeyModule_BlockedClientDisconnected +#define RedisModule_RegisterClusterMessageReceiver ValkeyModule_RegisterClusterMessageReceiver +#define RedisModule_SendClusterMessage ValkeyModule_SendClusterMessage +#define RedisModule_GetClusterNodeInfo ValkeyModule_GetClusterNodeInfo +#define RedisModule_GetClusterNodesList ValkeyModule_GetClusterNodesList +#define RedisModule_FreeClusterNodesList ValkeyModule_FreeClusterNodesList +#define RedisModule_CreateTimer ValkeyModule_CreateTimer +#define RedisModule_StopTimer ValkeyModule_StopTimer +#define RedisModule_GetTimerInfo ValkeyModule_GetTimerInfo +#define RedisModule_GetMyClusterID ValkeyModule_GetMyClusterID +#define RedisModule_GetClusterSize ValkeyModule_GetClusterSize +#define RedisModule_GetRandomBytes ValkeyModule_GetRandomBytes +#define RedisModule_GetRandomHexChars ValkeyModule_GetRandomHexChars +#define RedisModule_SetDisconnectCallback ValkeyModule_SetDisconnectCallback +#define RedisModule_SetClusterFlags ValkeyModule_SetClusterFlags +#define RedisModule_ClusterKeySlot ValkeyModule_ClusterKeySlot +#define RedisModule_ClusterCanonicalKeyNameInSlot ValkeyModule_ClusterCanonicalKeyNameInSlot +#define RedisModule_ExportSharedAPI ValkeyModule_ExportSharedAPI +#define RedisModule_GetSharedAPI ValkeyModule_GetSharedAPI +#define RedisModule_RegisterCommandFilter ValkeyModule_RegisterCommandFilter +#define RedisModule_UnregisterCommandFilter ValkeyModule_UnregisterCommandFilter +#define RedisModule_CommandFilterArgsCount ValkeyModule_CommandFilterArgsCount +#define RedisModule_CommandFilterArgGet ValkeyModule_CommandFilterArgGet +#define RedisModule_CommandFilterArgInsert ValkeyModule_CommandFilterArgInsert +#define RedisModule_CommandFilterArgReplace ValkeyModule_CommandFilterArgReplace +#define RedisModule_CommandFilterArgDelete ValkeyModule_CommandFilterArgDelete +#define RedisModule_CommandFilterGetClientId ValkeyModule_CommandFilterGetClientId +#define RedisModule_Fork ValkeyModule_Fork +#define RedisModule_SendChildHeartbeat ValkeyModule_SendChildHeartbeat +#define RedisModule_ExitFromChild ValkeyModule_ExitFromChild +#define RedisModule_KillForkChild ValkeyModule_KillForkChild +#define RedisModule_GetUsedMemoryRatio ValkeyModule_GetUsedMemoryRatio +#define RedisModule_MallocSize ValkeyModule_MallocSize +#define RedisModule_MallocUsableSize ValkeyModule_MallocUsableSize +#define RedisModule_MallocSizeString ValkeyModule_MallocSizeString +#define RedisModule_MallocSizeDict ValkeyModule_MallocSizeDict +#define RedisModule_CreateModuleUser ValkeyModule_CreateModuleUser +#define RedisModule_FreeModuleUser ValkeyModule_FreeModuleUser +#define RedisModule_SetContextUser ValkeyModule_SetContextUser +#define RedisModule_SetModuleUserACL ValkeyModule_SetModuleUserACL +#define RedisModule_SetModuleUserACLString ValkeyModule_SetModuleUserACLString +#define RedisModule_GetModuleUserACLString ValkeyModule_GetModuleUserACLString +#define RedisModule_GetCurrentUserName ValkeyModule_GetCurrentUserName +#define RedisModule_GetModuleUserFromUserName ValkeyModule_GetModuleUserFromUserName +#define RedisModule_ACLCheckCommandPermissions ValkeyModule_ACLCheckCommandPermissions +#define RedisModule_ACLCheckKeyPermissions ValkeyModule_ACLCheckKeyPermissions +#define RedisModule_ACLCheckChannelPermissions ValkeyModule_ACLCheckChannelPermissions +#define RedisModule_ACLAddLogEntry ValkeyModule_ACLAddLogEntry +#define RedisModule_ACLAddLogEntryByUserName ValkeyModule_ACLAddLogEntryByUserName +#define RedisModule_AuthenticateClientWithACLUser ValkeyModule_AuthenticateClientWithACLUser +#define RedisModule_AuthenticateClientWithUser ValkeyModule_AuthenticateClientWithUser +#define RedisModule_DeauthenticateAndCloseClient ValkeyModule_DeauthenticateAndCloseClient +#define RedisModule_RedactClientCommandArgument ValkeyModule_RedactClientCommandArgument +#define RedisModule_GetClientCertificate ValkeyModule_GetClientCertificate +#define RedisModule_GetCommandKeys ValkeyModule_GetCommandKeys +#define RedisModule_GetCommandKeysWithFlags ValkeyModule_GetCommandKeysWithFlags +#define RedisModule_GetCurrentCommandName ValkeyModule_GetCurrentCommandName +#define RedisModule_RegisterDefragFunc ValkeyModule_RegisterDefragFunc +#define RedisModule_DefragAlloc ValkeyModule_DefragAlloc +#define RedisModule_DefragRedisModuleString ValkeyModule_DefragModuleString +#define RedisModule_DefragShouldStop ValkeyModule_DefragShouldStop +#define RedisModule_DefragCursorSet ValkeyModule_DefragCursorSet +#define RedisModule_DefragCursorGet ValkeyModule_DefragCursorGet +#define RedisModule_GetDbIdFromDefragCtx ValkeyModule_GetDbIdFromDefragCtx +#define RedisModule_GetKeyNameFromDefragCtx ValkeyModule_GetKeyNameFromDefragCtx +#define RedisModule_EventLoopAdd ValkeyModule_EventLoopAdd +#define RedisModule_EventLoopDel ValkeyModule_EventLoopDel +#define RedisModule_EventLoopAddOneShot ValkeyModule_EventLoopAddOneShot +#define RedisModule_RegisterBoolConfig ValkeyModule_RegisterBoolConfig +#define RedisModule_RegisterNumericConfig ValkeyModule_RegisterNumericConfig +#define RedisModule_RegisterStringConfig ValkeyModule_RegisterStringConfig +#define RedisModule_RegisterEnumConfig ValkeyModule_RegisterEnumConfig +#define RedisModule_LoadConfigs ValkeyModule_LoadConfigs +#define RedisModule_RdbStreamCreateFromFile ValkeyModule_RdbStreamCreateFromFile +#define RedisModule_RdbStreamFree ValkeyModule_RdbStreamFree +#define RedisModule_RdbLoad ValkeyModule_RdbLoad +#define RedisModule_RdbSave ValkeyModule_RdbSave + +/* RedisModuleEvent */ +#define RedisModuleEvent_FlushDB ValkeyModuleEvent_FlushDB +#define RedisModuleEvent_FlushDBV2 ValkeyModuleEvent_FlushDBV2 +#define RedisModuleEvent_FlushDBV1 ValkeyModuleEvent_FlushDBV1 +#define RedisModuleEvent_FlushDB ValkeyModuleEvent_FlushDB +#define RedisModuleEvent_ReplicationRoleChanged ValkeyModuleEvent_ReplicationRoleChanged +#define RedisModuleEvent_Persistence ValkeyModuleEvent_Persistence +#define RedisModuleEvent_FlushDB ValkeyModuleEvent_FlushDB +#define RedisModuleEvent_Loading ValkeyModuleEvent_Loading +#define RedisModuleEvent_ClientChange ValkeyModuleEvent_ClientChange +#define RedisModuleEvent_Shutdown ValkeyModuleEvent_Shutdown +#define RedisModuleEvent_ReplicaChange ValkeyModuleEvent_ReplicaChange +#define RedisModuleEvent_CronLoop ValkeyModuleEvent_CronLoop +#define RedisModuleEvent_MasterLinkChange ValkeyModuleEvent_MasterLinkChange +#define RedisModuleEvent_ModuleChange ValkeyModuleEvent_ModuleChange +#define RedisModuleEvent_LoadingProgress ValkeyModuleEvent_LoadingProgress +#define RedisModuleEvent_SwapDB ValkeyModuleEvent_SwapDB +#define RedisModuleEvent_ReplAsyncLoad ValkeyModuleEvent_ReplAsyncLoad +#define RedisModuleEvent_ForkChild ValkeyModuleEvent_ForkChild +#define RedisModuleEvent_EventLoop ValkeyModuleEvent_EventLoop +#define RedisModuleEvent_Config ValkeyModuleEvent_Config +#define RedisModuleEvent_Key ValkeyModuleEvent_Key diff --git a/src/replication.c b/src/replication.c index eec67e06b1..5fb477cd8b 100644 --- a/src/replication.c +++ b/src/replication.c @@ -821,8 +821,8 @@ int masterTryPartialResynchronization(client *c, long long psync_offset) { refreshGoodSlavesCount(); /* Fire the replica change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, - REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, + VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, NULL); return C_OK; /* The caller can return, no full resync needed. */ @@ -1308,8 +1308,8 @@ int replicaPutOnline(client *slave) { refreshGoodSlavesCount(); /* Fire the replica change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, - REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, + VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, NULL); serverLog(LL_NOTICE,"Synchronization with replica %s succeeded", replicationGetSlaveName(slave)); @@ -2068,8 +2068,8 @@ void readSyncBulkPayload(connection *conn) { diskless_load_tempDb = disklessLoadInitTempDb(); temp_functions_lib_ctx = functionsLibCtxCreate(); - moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD, - REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, NULL); } else { replicationAttachToNewMaster(); @@ -2142,8 +2142,8 @@ void readSyncBulkPayload(connection *conn) { if (server.repl_diskless_load == REPL_DISKLESS_LOAD_SWAPDB) { /* Discard potentially partially loaded tempDb. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD, - REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED, NULL); disklessLoadDiscardTempDb(diskless_load_tempDb); @@ -2173,8 +2173,8 @@ void readSyncBulkPayload(connection *conn) { /* swap existing functions ctx with the temporary one */ functionsLibCtxSwapWithCurrent(temp_functions_lib_ctx); - moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD, - REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED, NULL); /* Delete the old db as it's useless now. */ @@ -2269,8 +2269,8 @@ void readSyncBulkPayload(connection *conn) { server.repl_down_since = 0; /* Fire the master link modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_UP, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP, NULL); /* After a full resynchronization we use the replication ID and @@ -3044,14 +3044,14 @@ void replicationSetMaster(char *ip, int port) { } /* Fire the role change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, - REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED, + VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA, NULL); /* Fire the master link modules event. */ if (server.repl_state == REPL_STATE_CONNECTED) - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL); server.repl_state = REPL_STATE_CONNECT; @@ -3066,8 +3066,8 @@ void replicationUnsetMaster(void) { /* Fire the master link modules event. */ if (server.repl_state == REPL_STATE_CONNECTED) - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL); /* Clear masterhost first, since the freeClient calls @@ -3108,8 +3108,8 @@ void replicationUnsetMaster(void) { server.repl_down_since = 0; /* Fire the role change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, - REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED, + VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY, NULL); /* Restart the AOF subsystem in case we shut it down during a sync when @@ -3122,8 +3122,8 @@ void replicationUnsetMaster(void) { void replicationHandleMasterDisconnection(void) { /* Fire the master link modules event. */ if (server.repl_state == REPL_STATE_CONNECTED) - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL); server.master = NULL; @@ -3411,8 +3411,8 @@ void replicationResurrectCachedMaster(connection *conn) { server.repl_down_since = 0; /* Fire the master link modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_UP, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP, NULL); /* Re-add to the list of clients. */ diff --git a/src/server.c b/src/server.c index e2e906e69e..c41247e9dc 100644 --- a/src/server.c +++ b/src/server.c @@ -568,7 +568,7 @@ dictType objToDictDictType = { }; /* Modules system dictionary type. Keys are module name, - * values are pointer to RedisModule struct. */ + * values are pointer to ValkeyModule struct. */ dictType modulesDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ @@ -677,8 +677,8 @@ void resetChildState(void) { server.stat_current_save_keys_total = 0; updateDictResizePolicy(); closeChildInfoPipe(); - moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD, - REDISMODULE_SUBEVENT_FORK_CHILD_DIED, + moduleFireServerEvent(VALKEYMODULE_EVENT_FORK_CHILD, + VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED, NULL); } @@ -1523,8 +1523,8 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { } /* Fire the cron loop modules event. */ - RedisModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,server.hz}; - moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP, + ValkeyModuleCronLoopV1 ei = {VALKEYMODULE_CRON_LOOP_VERSION,server.hz}; + moduleFireServerEvent(VALKEYMODULE_EVENT_CRON_LOOP, 0, &ei); @@ -1686,8 +1686,8 @@ void beforeSleep(struct aeEventLoop *eventLoop) { activeExpireCycle(ACTIVE_EXPIRE_CYCLE_FAST); if (moduleCount()) { - moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP, - REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP, + moduleFireServerEvent(VALKEYMODULE_EVENT_EVENTLOOP, + VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP, NULL); } @@ -1816,8 +1816,8 @@ void afterSleep(struct aeEventLoop *eventLoop) { atomicSet(server.module_gil_acquring, 1); moduleAcquireGIL(); atomicSet(server.module_gil_acquring, 0); - moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP, - REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP, + moduleFireServerEvent(VALKEYMODULE_EVENT_EVENTLOOP, + VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP, NULL); latencyEndMonitor(latency); latencyAddSampleIfNeeded("module-acquire-GIL",latency); @@ -4502,7 +4502,7 @@ int finishShutdown(void) { if (server.aof_manifest) aofManifestFree(server.aof_manifest); /* Fire the shutdown modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_SHUTDOWN,0,NULL); + moduleFireServerEvent(VALKEYMODULE_EVENT_SHUTDOWN,0,NULL); /* Remove the pid file if possible and needed. */ if (server.daemonize || server.pidfile) { @@ -6514,8 +6514,8 @@ int serverFork(int purpose) { } updateDictResizePolicy(); - moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD, - REDISMODULE_SUBEVENT_FORK_CHILD_BORN, + moduleFireServerEvent(VALKEYMODULE_EVENT_FORK_CHILD, + VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN, NULL); } return childpid; diff --git a/src/server.h b/src/server.h index 95836def5b..0ca24e3c92 100644 --- a/src/server.h +++ b/src/server.h @@ -80,9 +80,9 @@ typedef long long ustime_t; /* microsecond time type. */ #include "rax.h" /* Radix tree */ #include "connection.h" /* Connection abstraction */ -#define REDISMODULE_CORE 1 +#define VALKEYMODULE_CORE 1 typedef struct serverObject robj; -#include "redismodule.h" /* Redis modules API defines. */ +#include "valkeymodule.h" /* Redis modules API defines. */ /* Following includes allow test functions to be called from Redis main() */ #include "zipmap.h" @@ -711,7 +711,7 @@ typedef enum { /* The "module" object type is a special one that signals that the object * is one directly managed by a Redis module. In this case the value points * to a moduleValue struct, which contains the object value (which is only - * handled by the module itself) and the RedisModuleType struct which lists + * handled by the module itself) and the ValkeyModuleType struct which lists * function pointers in order to serialize, deserialize, AOF-rewrite and * free the object. * @@ -724,53 +724,53 @@ typedef enum { #define OBJ_TYPE_MAX 7 /* Maximum number of object types */ /* Extract encver / signature from a module type ID. */ -#define REDISMODULE_TYPE_ENCVER_BITS 10 -#define REDISMODULE_TYPE_ENCVER_MASK ((1<>REDISMODULE_TYPE_ENCVER_BITS) +#define VALKEYMODULE_TYPE_ENCVER_BITS 10 +#define VALKEYMODULE_TYPE_ENCVER_MASK ((1<>VALKEYMODULE_TYPE_ENCVER_BITS) /* Bit flags for moduleTypeAuxSaveFunc */ -#define REDISMODULE_AUX_BEFORE_RDB (1<<0) -#define REDISMODULE_AUX_AFTER_RDB (1<<1) +#define VALKEYMODULE_AUX_BEFORE_RDB (1<<0) +#define VALKEYMODULE_AUX_AFTER_RDB (1<<1) -struct RedisModule; -struct RedisModuleIO; -struct RedisModuleDigest; -struct RedisModuleCtx; +struct ValkeyModule; +struct ValkeyModuleIO; +struct ValkeyModuleDigest; +struct ValkeyModuleCtx; struct moduleLoadQueueEntry; -struct RedisModuleKeyOptCtx; -struct RedisModuleCommand; +struct ValkeyModuleKeyOptCtx; +struct ValkeyModuleCommand; struct clusterState; /* Each module type implementation should export a set of methods in order * to serialize and deserialize the value in the RDB file, rewrite the AOF * log, create the digest for "DEBUG DIGEST", and free the value when a key * is deleted. */ -typedef void *(*moduleTypeLoadFunc)(struct RedisModuleIO *io, int encver); -typedef void (*moduleTypeSaveFunc)(struct RedisModuleIO *io, void *value); -typedef int (*moduleTypeAuxLoadFunc)(struct RedisModuleIO *rdb, int encver, int when); -typedef void (*moduleTypeAuxSaveFunc)(struct RedisModuleIO *rdb, int when); -typedef void (*moduleTypeRewriteFunc)(struct RedisModuleIO *io, struct serverObject *key, void *value); -typedef void (*moduleTypeDigestFunc)(struct RedisModuleDigest *digest, void *value); +typedef void *(*moduleTypeLoadFunc)(struct ValkeyModuleIO *io, int encver); +typedef void (*moduleTypeSaveFunc)(struct ValkeyModuleIO *io, void *value); +typedef int (*moduleTypeAuxLoadFunc)(struct ValkeyModuleIO *rdb, int encver, int when); +typedef void (*moduleTypeAuxSaveFunc)(struct ValkeyModuleIO *rdb, int when); +typedef void (*moduleTypeRewriteFunc)(struct ValkeyModuleIO *io, struct serverObject *key, void *value); +typedef void (*moduleTypeDigestFunc)(struct ValkeyModuleDigest *digest, void *value); typedef size_t (*moduleTypeMemUsageFunc)(const void *value); typedef void (*moduleTypeFreeFunc)(void *value); typedef size_t (*moduleTypeFreeEffortFunc)(struct serverObject *key, const void *value); typedef void (*moduleTypeUnlinkFunc)(struct serverObject *key, void *value); typedef void *(*moduleTypeCopyFunc)(struct serverObject *fromkey, struct serverObject *tokey, const void *value); -typedef int (*moduleTypeDefragFunc)(struct RedisModuleDefragCtx *ctx, struct serverObject *key, void **value); -typedef size_t (*moduleTypeMemUsageFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value, size_t sample_size); -typedef void (*moduleTypeFreeFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value); -typedef size_t (*moduleTypeFreeEffortFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value); -typedef void (*moduleTypeUnlinkFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value); -typedef void *(*moduleTypeCopyFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value); -typedef int (*moduleTypeAuthCallback)(struct RedisModuleCtx *ctx, void *username, void *password, const char **err); +typedef int (*moduleTypeDefragFunc)(struct ValkeyModuleDefragCtx *ctx, struct serverObject *key, void **value); +typedef size_t (*moduleTypeMemUsageFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value, size_t sample_size); +typedef void (*moduleTypeFreeFunc2)(struct ValkeyModuleKeyOptCtx *ctx, void *value); +typedef size_t (*moduleTypeFreeEffortFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef void (*moduleTypeUnlinkFunc2)(struct ValkeyModuleKeyOptCtx *ctx, void *value); +typedef void *(*moduleTypeCopyFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef int (*moduleTypeAuthCallback)(struct ValkeyModuleCtx *ctx, void *username, void *password, const char **err); /* The module type, which is referenced in each value of a given type, defines * the methods and links to the module exporting the type. */ -typedef struct RedisModuleType { +typedef struct ValkeyModuleType { uint64_t id; /* Higher 54 bits of type ID + 10 lower bits of encoding ver. */ - struct RedisModule *module; + struct ValkeyModule *module; moduleTypeLoadFunc rdb_load; moduleTypeSaveFunc rdb_save; moduleTypeRewriteFunc aof_rewrite; @@ -813,7 +813,7 @@ typedef struct moduleValue { } moduleValue; /* This structure represents a module inside the system. */ -struct RedisModule { +struct ValkeyModule { void *handle; /* Module dlopen() handle. */ char *name; /* Module name. */ int ver; /* Module version. We use just progressive integers. */ @@ -827,25 +827,25 @@ struct RedisModule { int in_call; /* RM_Call() nesting level */ int in_hook; /* Hooks callback nesting level for this module (0 or 1). */ int options; /* Module options and capabilities. */ - int blocked_clients; /* Count of RedisModuleBlockedClient in this module. */ - RedisModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */ - RedisModuleDefragFunc defrag_cb; /* Callback for global data defrag. */ + int blocked_clients; /* Count of ValkeyModuleBlockedClient in this module. */ + ValkeyModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */ + ValkeyModuleDefragFunc defrag_cb; /* Callback for global data defrag. */ struct moduleLoadQueueEntry *loadmod; /* Module load arguments for config rewrite. */ int num_commands_with_acl_categories; /* Number of commands in this module included in acl categories */ int onload; /* Flag to identify if the call is being made from Onload (0 or 1) */ size_t num_acl_categories_added; /* Number of acl categories added by this module. */ }; -typedef struct RedisModule RedisModule; +typedef struct ValkeyModule ValkeyModule; /* This is a wrapper for the 'rio' streams used inside rdb.c in Redis, so that * the user does not have to take the total count of the written bytes nor * to care about error conditions. */ -struct RedisModuleIO { +struct ValkeyModuleIO { size_t bytes; /* Bytes read / written so far. */ rio *rio; /* Rio stream. */ moduleType *type; /* Module type doing the operation. */ int error; /* True if error condition happened. */ - struct RedisModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/ + struct ValkeyModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/ struct serverObject *key; /* Optional name of key processed */ int dbid; /* The dbid of the key being processed, -1 when unknown. */ sds pre_flush_buffer; /* A buffer that should be flushed before next write operation @@ -870,7 +870,7 @@ struct RedisModuleIO { * a data structure, so that a digest can be created in a way that correctly * reflects the values. See the DEBUG DIGEST command implementation for more * background. */ -struct RedisModuleDigest { +struct ValkeyModuleDigest { unsigned char o[20]; /* Ordered elements. */ unsigned char x[20]; /* Xored elements. */ struct serverObject *key; /* Optional name of key processed */ @@ -1041,11 +1041,11 @@ typedef struct blockingState { long long reploffset; /* Replication offset to reach. */ /* BLOCKED_MODULE */ - void *module_blocked_handle; /* RedisModuleBlockedClient structure. + void *module_blocked_handle; /* ValkeyModuleBlockedClient structure. which is opaque for the Redis core, only handled in module.c. */ - void *async_rm_call_handle; /* RedisModuleAsyncRMCallPromise structure. + void *async_rm_call_handle; /* ValkeyModuleAsyncRMCallPromise structure. which is opaque for the Redis core, only handled in module.c. */ } blockingState; @@ -1232,13 +1232,13 @@ typedef struct client { listNode *client_list_node; /* list node in client list */ listNode *postponed_list_node; /* list node within the postponed list */ listNode *pending_read_list_node; /* list node in clients pending read list */ - void *module_blocked_client; /* Pointer to the RedisModuleBlockedClient associated with this + void *module_blocked_client; /* Pointer to the ValkeyModuleBlockedClient associated with this * client. This is set in case of module authentication before the * unblocked client is reprocessed to handle reply callbacks. */ void *module_auth_ctx; /* Ongoing / attempted module based auth callback's ctx. * This is only tracked within the context of the command attempting * authentication. If not NULL, it means module auth is in progress. */ - RedisModuleUserChangedFunc auth_callback; /* Module callback to execute + ValkeyModuleUserChangedFunc auth_callback; /* Module callback to execute * when the authenticated user * changes. */ void *auth_callback_privdata; /* Private data that is passed when the auth @@ -2014,7 +2014,7 @@ struct valkeyServer { int cluster_module_flags; /* Set of flags that Redis modules are able to set in order to suppress certain native Redis Cluster features. Check the - REDISMODULE_CLUSTER_FLAG_*. */ + VALKEYMODULE_CLUSTER_FLAG_*. */ int cluster_allow_reads_when_down; /* Are reads allowed when the cluster is down? */ int cluster_config_file_lock_fd; /* cluster config fd, will be flocked. */ @@ -2113,7 +2113,7 @@ typedef struct { * 2. keynum: there's an arg that contains the number of key args somewhere before the keys themselves */ -/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecBeginSearchType */ +/* WARNING! Must be synced with generate-command-code.py and ValkeyModuleKeySpecBeginSearchType */ typedef enum { KSPEC_BS_INVALID = 0, /* Must be 0 */ KSPEC_BS_UNKNOWN, @@ -2121,7 +2121,7 @@ typedef enum { KSPEC_BS_KEYWORD } kspec_bs_type; -/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecFindKeysType */ +/* WARNING! Must be synced with generate-command-code.py and ValkeyModuleKeySpecFindKeysType */ typedef enum { KSPEC_FK_INVALID = 0, /* Must be 0 */ KSPEC_FK_UNKNOWN, @@ -2129,7 +2129,7 @@ typedef enum { KSPEC_FK_KEYNUM } kspec_fk_type; -/* WARNING! This struct must match RedisModuleCommandKeySpec */ +/* WARNING! This struct must match ValkeyModuleCommandKeySpec */ typedef struct { /* Declarative data */ const char *notes; @@ -2209,7 +2209,7 @@ typedef struct jsonObject { #endif -/* WARNING! This struct must match RedisModuleCommandHistoryEntry */ +/* WARNING! This struct must match ValkeyModuleCommandHistoryEntry */ typedef struct { const char *since; const char *changes; @@ -2383,7 +2383,7 @@ struct serverCommand { dict *subcommands_dict; /* A dictionary that holds the subcommands, the key is the subcommand sds name * (not the fullname), and the value is the serverCommand structure pointer. */ struct serverCommand *parent; - struct RedisModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */ + struct ValkeyModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */ }; struct serverError { @@ -2505,7 +2505,7 @@ moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name); void moduleTypeNameByID(char *name, uint64_t moduleid); const char *moduleTypeModuleName(moduleType *mt); const char *moduleNameFromCommand(struct serverCommand *cmd); -void moduleFreeContext(struct RedisModuleCtx *ctx); +void moduleFreeContext(struct ValkeyModuleCtx *ctx); void moduleCallCommandUnblockedHandler(client *c); int isModuleClientUnblocked(client *c); void unblockClientFromModule(client *c); diff --git a/src/tls.c b/src/tls.c index bb1cee14c7..ee3cd0fa3b 100644 --- a/src/tls.c +++ b/src/tls.c @@ -27,7 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define REDISMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */ +#define VALKEYMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */ #include "server.h" #include "connhelpers.h" @@ -1171,36 +1171,36 @@ int RedisRegisterConnectionTypeTLS(void) { #include "release.h" -int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) { +int ValkeyModule_OnLoad(void *ctx, ValkeyModuleString **argv, int argc) { UNUSED(argv); UNUSED(argc); /* Connection modules must be part of the same build as redis. */ if (strcmp(REDIS_BUILD_ID_RAW, serverBuildIdRaw())) { serverLog(LL_NOTICE, "Connection type %s was not built together with the redis-server used.", CONN_TYPE_TLS); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (RedisModule_Init(ctx,"tls",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + if (ValkeyModule_Init(ctx,"tls",1,VALKEYMODULE_APIVER_1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; /* Connection modules is available only bootup. */ - if ((RedisModule_GetContextFlags(ctx) & REDISMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) { + if ((ValkeyModule_GetContextFlags(ctx) & VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) { serverLog(LL_NOTICE, "Connection type %s can be loaded only during bootup", CONN_TYPE_TLS); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - RedisModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD); + ValkeyModule_SetModuleOptions(ctx, VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD); if(connTypeRegister(&CT_TLS) != C_OK) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -int RedisModule_OnUnload(void *arg) { +int ValkeyModule_OnUnload(void *arg) { UNUSED(arg); serverLog(LL_NOTICE, "Connection type %s can not be unloaded", CONN_TYPE_TLS); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } #endif diff --git a/src/valkeymodule.h b/src/valkeymodule.h new file mode 100644 index 0000000000..3df3e733a1 --- /dev/null +++ b/src/valkeymodule.h @@ -0,0 +1,1698 @@ +/* + * valkeymodule.h + * + * This header file is forked from redismodule.h to reflect the new naming conventions adopted in Valkey. + * + * Key Changes: + * - Symbolic names have been changed from VALKEYMODULE_* to VALKEYMODULE_* to align with the + * new module naming convention. Developers must use these new symbolic names in their module + * implementations. + * - Terminology has been updated to be more inclusive: "slave" is now "replica", and "master" + * is now "primary". These changes are part of an effort to use more accurate and inclusive language. + * + * When developing modules for Valkey, ensure to include "valkeymodule.h". This header file contains + * the updated definitions and should be used to maintain compatibility with the changes made in Valkey. + */ + +#ifndef VALKEYMODULE_H +#define VALKEYMODULE_H + +#include +#include +#include +#include + + +typedef struct ValkeyModuleString ValkeyModuleString; +typedef struct ValkeyModuleKey ValkeyModuleKey; + +/* -------------- Defines NOT common between core and modules ------------- */ + +#if defined VALKEYMODULE_CORE +/* Things only defined for the modules core (server), not exported to modules + * that include this file. */ + +#define ValkeyModuleString robj + +#endif /* defined VALKEYMODULE_CORE */ + +#if !defined VALKEYMODULE_CORE && !defined VALKEYMODULE_CORE_MODULE +/* Things defined for modules, but not for core-modules. */ + +typedef long long mstime_t; +typedef long long ustime_t; + +#endif /* !defined VALKEYMODULE_CORE && !defined VALKEYMODULE_CORE_MODULE */ + +/* ---------------- Defines common between core and modules --------------- */ + +/* Error status return values. */ +#define VALKEYMODULE_OK 0 +#define VALKEYMODULE_ERR 1 + +/* Module Based Authentication status return values. */ +#define VALKEYMODULE_AUTH_HANDLED 0 +#define VALKEYMODULE_AUTH_NOT_HANDLED 1 + +/* API versions. */ +#define VALKEYMODULE_APIVER_1 1 + +/* Version of the ValkeyModuleTypeMethods structure. Once the ValkeyModuleTypeMethods + * structure is changed, this version number needs to be changed synchronistically. */ +#define VALKEYMODULE_TYPE_METHOD_VERSION 5 + +/* API flags and constants */ +#define VALKEYMODULE_READ (1<<0) +#define VALKEYMODULE_WRITE (1<<1) + +/* ValkeyModule_OpenKey extra flags for the 'mode' argument. + * Avoid touching the LRU/LFU of the key when opened. */ +#define VALKEYMODULE_OPEN_KEY_NOTOUCH (1<<16) +/* Don't trigger keyspace event on key misses. */ +#define VALKEYMODULE_OPEN_KEY_NONOTIFY (1<<17) +/* Don't update keyspace hits/misses counters. */ +#define VALKEYMODULE_OPEN_KEY_NOSTATS (1<<18) +/* Avoid deleting lazy expired keys. */ +#define VALKEYMODULE_OPEN_KEY_NOEXPIRE (1<<19) +/* Avoid any effects from fetching the key */ +#define VALKEYMODULE_OPEN_KEY_NOEFFECTS (1<<20) +/* Mask of all VALKEYMODULE_OPEN_KEY_* values. Any new mode should be added to this list. + * Should not be used directly by the module, use RM_GetOpenKeyModesAll instead. + * Located here so when we will add new modes we will not forget to update it. */ +#define _VALKEYMODULE_OPEN_KEY_ALL VALKEYMODULE_READ | VALKEYMODULE_WRITE | VALKEYMODULE_OPEN_KEY_NOTOUCH | VALKEYMODULE_OPEN_KEY_NONOTIFY | VALKEYMODULE_OPEN_KEY_NOSTATS | VALKEYMODULE_OPEN_KEY_NOEXPIRE | VALKEYMODULE_OPEN_KEY_NOEFFECTS + +/* List push and pop */ +#define VALKEYMODULE_LIST_HEAD 0 +#define VALKEYMODULE_LIST_TAIL 1 + +/* Key types. */ +#define VALKEYMODULE_KEYTYPE_EMPTY 0 +#define VALKEYMODULE_KEYTYPE_STRING 1 +#define VALKEYMODULE_KEYTYPE_LIST 2 +#define VALKEYMODULE_KEYTYPE_HASH 3 +#define VALKEYMODULE_KEYTYPE_SET 4 +#define VALKEYMODULE_KEYTYPE_ZSET 5 +#define VALKEYMODULE_KEYTYPE_MODULE 6 +#define VALKEYMODULE_KEYTYPE_STREAM 7 + +/* Reply types. */ +#define VALKEYMODULE_REPLY_UNKNOWN -1 +#define VALKEYMODULE_REPLY_STRING 0 +#define VALKEYMODULE_REPLY_ERROR 1 +#define VALKEYMODULE_REPLY_INTEGER 2 +#define VALKEYMODULE_REPLY_ARRAY 3 +#define VALKEYMODULE_REPLY_NULL 4 +#define VALKEYMODULE_REPLY_MAP 5 +#define VALKEYMODULE_REPLY_SET 6 +#define VALKEYMODULE_REPLY_BOOL 7 +#define VALKEYMODULE_REPLY_DOUBLE 8 +#define VALKEYMODULE_REPLY_BIG_NUMBER 9 +#define VALKEYMODULE_REPLY_VERBATIM_STRING 10 +#define VALKEYMODULE_REPLY_ATTRIBUTE 11 +#define VALKEYMODULE_REPLY_PROMISE 12 + +/* Postponed array length. */ +#define VALKEYMODULE_POSTPONED_ARRAY_LEN -1 /* Deprecated, please use VALKEYMODULE_POSTPONED_LEN */ +#define VALKEYMODULE_POSTPONED_LEN -1 + +/* Expire */ +#define VALKEYMODULE_NO_EXPIRE -1 + +/* Sorted set API flags. */ +#define VALKEYMODULE_ZADD_XX (1<<0) +#define VALKEYMODULE_ZADD_NX (1<<1) +#define VALKEYMODULE_ZADD_ADDED (1<<2) +#define VALKEYMODULE_ZADD_UPDATED (1<<3) +#define VALKEYMODULE_ZADD_NOP (1<<4) +#define VALKEYMODULE_ZADD_GT (1<<5) +#define VALKEYMODULE_ZADD_LT (1<<6) + +/* Hash API flags. */ +#define VALKEYMODULE_HASH_NONE 0 +#define VALKEYMODULE_HASH_NX (1<<0) +#define VALKEYMODULE_HASH_XX (1<<1) +#define VALKEYMODULE_HASH_CFIELDS (1<<2) +#define VALKEYMODULE_HASH_EXISTS (1<<3) +#define VALKEYMODULE_HASH_COUNT_ALL (1<<4) + +#define VALKEYMODULE_CONFIG_DEFAULT 0 /* This is the default for a module config. */ +#define VALKEYMODULE_CONFIG_IMMUTABLE (1ULL<<0) /* Can this value only be set at startup? */ +#define VALKEYMODULE_CONFIG_SENSITIVE (1ULL<<1) /* Does this value contain sensitive information */ +#define VALKEYMODULE_CONFIG_HIDDEN (1ULL<<4) /* This config is hidden in `config get ` (used for tests/debugging) */ +#define VALKEYMODULE_CONFIG_PROTECTED (1ULL<<5) /* Becomes immutable if enable-protected-configs is enabled. */ +#define VALKEYMODULE_CONFIG_DENY_LOADING (1ULL<<6) /* This config is forbidden during loading. */ + +#define VALKEYMODULE_CONFIG_MEMORY (1ULL<<7) /* Indicates if this value can be set as a memory value */ +#define VALKEYMODULE_CONFIG_BITFLAGS (1ULL<<8) /* Indicates if this value can be set as a multiple enum values */ + +/* StreamID type. */ +typedef struct ValkeyModuleStreamID { + uint64_t ms; + uint64_t seq; +} ValkeyModuleStreamID; + +/* StreamAdd() flags. */ +#define VALKEYMODULE_STREAM_ADD_AUTOID (1<<0) +/* StreamIteratorStart() flags. */ +#define VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE (1<<0) +#define VALKEYMODULE_STREAM_ITERATOR_REVERSE (1<<1) +/* StreamIteratorTrim*() flags. */ +#define VALKEYMODULE_STREAM_TRIM_APPROX (1<<0) + +/* Context Flags: Info about the current context returned by + * RM_GetContextFlags(). */ + +/* The command is running in the context of a Lua script */ +#define VALKEYMODULE_CTX_FLAGS_LUA (1<<0) +/* The command is running inside a Valkey transaction */ +#define VALKEYMODULE_CTX_FLAGS_MULTI (1<<1) +/* The instance is a primary */ +#define VALKEYMODULE_CTX_FLAGS_PRIMARY (1<<2) +/* The instance is a replic */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA (1<<3) +/* The instance is read-only (usually meaning it's a replica as well) */ +#define VALKEYMODULE_CTX_FLAGS_READONLY (1<<4) +/* The instance is running in cluster mode */ +#define VALKEYMODULE_CTX_FLAGS_CLUSTER (1<<5) +/* The instance has AOF enabled */ +#define VALKEYMODULE_CTX_FLAGS_AOF (1<<6) +/* The instance has RDB enabled */ +#define VALKEYMODULE_CTX_FLAGS_RDB (1<<7) +/* The instance has Maxmemory set */ +#define VALKEYMODULE_CTX_FLAGS_MAXMEMORY (1<<8) +/* Maxmemory is set and has an eviction policy that may delete keys */ +#define VALKEYMODULE_CTX_FLAGS_EVICT (1<<9) +/* Valkey is out of memory according to the maxmemory flag. */ +#define VALKEYMODULE_CTX_FLAGS_OOM (1<<10) +/* Less than 25% of memory available according to maxmemory. */ +#define VALKEYMODULE_CTX_FLAGS_OOM_WARNING (1<<11) +/* The command was sent over the replication link. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICATED (1<<12) +/* Valkey is currently loading either from AOF or RDB. */ +#define VALKEYMODULE_CTX_FLAGS_LOADING (1<<13) +/* The replica has no link with its primary, note that + * there is the inverse flag as well: + * + * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE + * + * The two flags are exclusive, one or the other can be set. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE (1<<14) +/* The replica is trying to connect with the primary. + * (REPL_STATE_CONNECT and REPL_STATE_CONNECTING states) */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING (1<<15) +/* THe replica is receiving an RDB file from its primary. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING (1<<16) +/* The replica is online, receiving updates from its primary. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE (1<<17) +/* There is currently some background process active. */ +#define VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18) +/* The next EXEC will fail due to dirty CAS (touched keys). */ +#define VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY (1<<19) +/* Valkey is currently running inside background child process. */ +#define VALKEYMODULE_CTX_FLAGS_IS_CHILD (1<<20) +/* The current client does not allow blocking, either called from + * within multi, lua, or from another module using RM_Call */ +#define VALKEYMODULE_CTX_FLAGS_DENY_BLOCKING (1<<21) +/* The current client uses RESP3 protocol */ +#define VALKEYMODULE_CTX_FLAGS_RESP3 (1<<22) +/* Valkey is currently async loading database for diskless replication. */ +#define VALKEYMODULE_CTX_FLAGS_ASYNC_LOADING (1<<23) +/* Valkey is starting. */ +#define VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP (1<<24) + +/* Next context flag, must be updated when adding new flags above! +This flag should not be used directly by the module. + * Use ValkeyModule_GetContextFlagsAll instead. */ +#define _VALKEYMODULE_CTX_FLAGS_NEXT (1<<25) + +/* Keyspace changes notification classes. Every class is associated with a + * character for configuration purposes. + * NOTE: These have to be in sync with NOTIFY_* in server.h */ +#define VALKEYMODULE_NOTIFY_KEYSPACE (1<<0) /* K */ +#define VALKEYMODULE_NOTIFY_KEYEVENT (1<<1) /* E */ +#define VALKEYMODULE_NOTIFY_GENERIC (1<<2) /* g */ +#define VALKEYMODULE_NOTIFY_STRING (1<<3) /* $ */ +#define VALKEYMODULE_NOTIFY_LIST (1<<4) /* l */ +#define VALKEYMODULE_NOTIFY_SET (1<<5) /* s */ +#define VALKEYMODULE_NOTIFY_HASH (1<<6) /* h */ +#define VALKEYMODULE_NOTIFY_ZSET (1<<7) /* z */ +#define VALKEYMODULE_NOTIFY_EXPIRED (1<<8) /* x */ +#define VALKEYMODULE_NOTIFY_EVICTED (1<<9) /* e */ +#define VALKEYMODULE_NOTIFY_STREAM (1<<10) /* t */ +#define VALKEYMODULE_NOTIFY_KEY_MISS (1<<11) /* m (Note: This one is excluded from VALKEYMODULE_NOTIFY_ALL on purpose) */ +#define VALKEYMODULE_NOTIFY_LOADED (1<<12) /* module only key space notification, indicate a key loaded from rdb */ +#define VALKEYMODULE_NOTIFY_MODULE (1<<13) /* d, module key space notification */ +#define VALKEYMODULE_NOTIFY_NEW (1<<14) /* n, new key notification */ + +/* Next notification flag, must be updated when adding new flags above! +This flag should not be used directly by the module. + * Use ValkeyModule_GetKeyspaceNotificationFlagsAll instead. */ +#define _VALKEYMODULE_NOTIFY_NEXT (1<<15) + +#define VALKEYMODULE_NOTIFY_ALL (VALKEYMODULE_NOTIFY_GENERIC | VALKEYMODULE_NOTIFY_STRING | VALKEYMODULE_NOTIFY_LIST | VALKEYMODULE_NOTIFY_SET | VALKEYMODULE_NOTIFY_HASH | VALKEYMODULE_NOTIFY_ZSET | VALKEYMODULE_NOTIFY_EXPIRED | VALKEYMODULE_NOTIFY_EVICTED | VALKEYMODULE_NOTIFY_STREAM | VALKEYMODULE_NOTIFY_MODULE) /* A */ + +/* A special pointer that we can use between the core and the module to signal + * field deletion, and that is impossible to be a valid pointer. */ +#define VALKEYMODULE_HASH_DELETE ((ValkeyModuleString*)(long)1) + +/* Error messages. */ +#define VALKEYMODULE_ERRORMSG_WRONGTYPE "WRONGTYPE Operation against a key holding the wrong kind of value" + +#define VALKEYMODULE_POSITIVE_INFINITE (1.0/0.0) +#define VALKEYMODULE_NEGATIVE_INFINITE (-1.0/0.0) + +/* Cluster API defines. */ +#define VALKEYMODULE_NODE_ID_LEN 40 +#define VALKEYMODULE_NODE_MYSELF (1<<0) +#define VALKEYMODULE_NODE_PRIMARY (1<<1) +#define VALKEYMODULE_NODE_REPLICA (1<<2) +#define VALKEYMODULE_NODE_PFAIL (1<<3) +#define VALKEYMODULE_NODE_FAIL (1<<4) +#define VALKEYMODULE_NODE_NOFAILOVER (1<<5) + +#define VALKEYMODULE_CLUSTER_FLAG_NONE 0 +#define VALKEYMODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1) +#define VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2) + +#define VALKEYMODULE_NOT_USED(V) ((void) V) + +/* Logging level strings */ +#define VALKEYMODULE_LOGLEVEL_DEBUG "debug" +#define VALKEYMODULE_LOGLEVEL_VERBOSE "verbose" +#define VALKEYMODULE_LOGLEVEL_NOTICE "notice" +#define VALKEYMODULE_LOGLEVEL_WARNING "warning" + +/* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */ +#define VALKEYMODULE_AUX_BEFORE_RDB (1<<0) +#define VALKEYMODULE_AUX_AFTER_RDB (1<<1) + +/* RM_Yield flags */ +#define VALKEYMODULE_YIELD_FLAG_NONE (1<<0) +#define VALKEYMODULE_YIELD_FLAG_CLIENTS (1<<1) + +/* RM_BlockClientOnKeysWithFlags flags */ +#define VALKEYMODULE_BLOCK_UNBLOCK_DEFAULT (0) +#define VALKEYMODULE_BLOCK_UNBLOCK_DELETED (1<<0) + +/* This type represents a timer handle, and is returned when a timer is + * registered and used in order to invalidate a timer. It's just a 64 bit + * number, because this is how each timer is represented inside the radix tree + * of timers that are going to expire, sorted by expire time. */ +typedef uint64_t ValkeyModuleTimerID; + +/* CommandFilter Flags */ + +/* Do filter ValkeyModule_Call() commands initiated by module itself. */ +#define VALKEYMODULE_CMDFILTER_NOSELF (1<<0) + +/* Declare that the module can handle errors with ValkeyModule_SetModuleOptions. */ +#define VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0) + +/* When set, Valkey will not call ValkeyModule_SignalModifiedKey(), implicitly in + * ValkeyModule_CloseKey, and the module needs to do that when manually when keys + * are modified from the user's perspective, to invalidate WATCH. */ +#define VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED (1<<1) + +/* Declare that the module can handle diskless async replication with ValkeyModule_SetModuleOptions. */ +#define VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD (1<<2) + +/* Declare that the module want to get nested key space notifications. + * If enabled, the module is responsible to break endless loop. */ +#define VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS (1<<3) + +/* Next option flag, must be updated when adding new module flags above! + * This flag should not be used directly by the module. + * Use ValkeyModule_GetModuleOptionsAll instead. */ +#define _VALKEYMODULE_OPTIONS_FLAGS_NEXT (1<<4) + +/* Definitions for ValkeyModule_SetCommandInfo. */ + +typedef enum { + VALKEYMODULE_ARG_TYPE_STRING, + VALKEYMODULE_ARG_TYPE_INTEGER, + VALKEYMODULE_ARG_TYPE_DOUBLE, + VALKEYMODULE_ARG_TYPE_KEY, /* A string, but represents a keyname */ + VALKEYMODULE_ARG_TYPE_PATTERN, + VALKEYMODULE_ARG_TYPE_UNIX_TIME, + VALKEYMODULE_ARG_TYPE_PURE_TOKEN, + VALKEYMODULE_ARG_TYPE_ONEOF, /* Must have sub-arguments */ + VALKEYMODULE_ARG_TYPE_BLOCK /* Must have sub-arguments */ +} ValkeyModuleCommandArgType; + +#define VALKEYMODULE_CMD_ARG_NONE (0) +#define VALKEYMODULE_CMD_ARG_OPTIONAL (1<<0) /* The argument is optional (like GET in SET command) */ +#define VALKEYMODULE_CMD_ARG_MULTIPLE (1<<1) /* The argument may repeat itself (like key in DEL) */ +#define VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN (1<<2) /* The argument may repeat itself, and so does its token (like `GET pattern` in SORT) */ +#define _VALKEYMODULE_CMD_ARG_NEXT (1<<3) + +typedef enum { + VALKEYMODULE_KSPEC_BS_INVALID = 0, /* Must be zero. An implicitly value of + * zero is provided when the field is + * absent in a struct literal. */ + VALKEYMODULE_KSPEC_BS_UNKNOWN, + VALKEYMODULE_KSPEC_BS_INDEX, + VALKEYMODULE_KSPEC_BS_KEYWORD +} ValkeyModuleKeySpecBeginSearchType; + +typedef enum { + VALKEYMODULE_KSPEC_FK_OMITTED = 0, /* Used when the field is absent in a + * struct literal. Don't use this value + * explicitly. */ + VALKEYMODULE_KSPEC_FK_UNKNOWN, + VALKEYMODULE_KSPEC_FK_RANGE, + VALKEYMODULE_KSPEC_FK_KEYNUM +} ValkeyModuleKeySpecFindKeysType; + +/* Key-spec flags. For details, see the documentation of + * ValkeyModule_SetCommandInfo and the key-spec flags in server.h. */ +#define VALKEYMODULE_CMD_KEY_RO (1ULL<<0) +#define VALKEYMODULE_CMD_KEY_RW (1ULL<<1) +#define VALKEYMODULE_CMD_KEY_OW (1ULL<<2) +#define VALKEYMODULE_CMD_KEY_RM (1ULL<<3) +#define VALKEYMODULE_CMD_KEY_ACCESS (1ULL<<4) +#define VALKEYMODULE_CMD_KEY_UPDATE (1ULL<<5) +#define VALKEYMODULE_CMD_KEY_INSERT (1ULL<<6) +#define VALKEYMODULE_CMD_KEY_DELETE (1ULL<<7) +#define VALKEYMODULE_CMD_KEY_NOT_KEY (1ULL<<8) +#define VALKEYMODULE_CMD_KEY_INCOMPLETE (1ULL<<9) +#define VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS (1ULL<<10) + +/* Channel flags, for details see the documentation of + * ValkeyModule_ChannelAtPosWithFlags. */ +#define VALKEYMODULE_CMD_CHANNEL_PATTERN (1ULL<<0) +#define VALKEYMODULE_CMD_CHANNEL_PUBLISH (1ULL<<1) +#define VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE (1ULL<<2) +#define VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE (1ULL<<3) + +typedef struct ValkeyModuleCommandArg { + const char *name; + ValkeyModuleCommandArgType type; + int key_spec_index; /* If type is KEY, this is a zero-based index of + * the key_spec in the command. For other types, + * you may specify -1. */ + const char *token; /* If type is PURE_TOKEN, this is the token. */ + const char *summary; + const char *since; + int flags; /* The VALKEYMODULE_CMD_ARG_* macros. */ + const char *deprecated_since; + struct ValkeyModuleCommandArg *subargs; + const char *display_text; +} ValkeyModuleCommandArg; + +typedef struct { + const char *since; + const char *changes; +} ValkeyModuleCommandHistoryEntry; + +typedef struct { + const char *notes; + uint64_t flags; /* VALKEYMODULE_CMD_KEY_* macros. */ + ValkeyModuleKeySpecBeginSearchType begin_search_type; + union { + struct { + /* The index from which we start the search for keys */ + int pos; + } index; + struct { + /* The keyword that indicates the beginning of key args */ + const char *keyword; + /* An index in argv from which to start searching. + * Can be negative, which means start search from the end, in reverse + * (Example: -2 means to start in reverse from the penultimate arg) */ + int startfrom; + } keyword; + } bs; + ValkeyModuleKeySpecFindKeysType find_keys_type; + union { + struct { + /* Index of the last key relative to the result of the begin search + * step. Can be negative, in which case it's not relative. -1 + * indicating till the last argument, -2 one before the last and so + * on. */ + int lastkey; + /* How many args should we skip after finding a key, in order to + * find the next one. */ + int keystep; + /* If lastkey is -1, we use limit to stop the search by a factor. 0 + * and 1 mean no limit. 2 means 1/2 of the remaining args, 3 means + * 1/3, and so on. */ + int limit; + } range; + struct { + /* Index of the argument containing the number of keys to come + * relative to the result of the begin search step */ + int keynumidx; + /* Index of the fist key. (Usually it's just after keynumidx, in + * which case it should be set to keynumidx + 1.) */ + int firstkey; + /* How many args should we skip after finding a key, in order to + * find the next one, relative to the result of the begin search + * step. */ + int keystep; + } keynum; + } fk; +} ValkeyModuleCommandKeySpec; + +typedef struct { + int version; + size_t sizeof_historyentry; + size_t sizeof_keyspec; + size_t sizeof_arg; +} ValkeyModuleCommandInfoVersion; + +static const ValkeyModuleCommandInfoVersion ValkeyModule_CurrentCommandInfoVersion = { + .version = 1, + .sizeof_historyentry = sizeof(ValkeyModuleCommandHistoryEntry), + .sizeof_keyspec = sizeof(ValkeyModuleCommandKeySpec), + .sizeof_arg = sizeof(ValkeyModuleCommandArg) +}; + +#define VALKEYMODULE_COMMAND_INFO_VERSION (&ValkeyModule_CurrentCommandInfoVersion) + +typedef struct { + /* Always set version to VALKEYMODULE_COMMAND_INFO_VERSION */ + const ValkeyModuleCommandInfoVersion *version; + const char *summary; /* Summary of the command */ + const char *complexity; /* Complexity description */ + const char *since; /* Debut module version of the command */ + ValkeyModuleCommandHistoryEntry *history; /* History */ + /* A string of space-separated tips meant for clients/proxies regarding this + * command */ + const char *tips; + /* Number of arguments, it is possible to use -N to say >= N */ + int arity; + ValkeyModuleCommandKeySpec *key_specs; + ValkeyModuleCommandArg *args; +} ValkeyModuleCommandInfo; + +/* Eventloop definitions. */ +#define VALKEYMODULE_EVENTLOOP_READABLE 1 +#define VALKEYMODULE_EVENTLOOP_WRITABLE 2 +typedef void (*ValkeyModuleEventLoopFunc)(int fd, void *user_data, int mask); +typedef void (*ValkeyModuleEventLoopOneShotFunc)(void *user_data); + +/* Server events definitions. + * Those flags should not be used directly by the module, instead + * the module should use ValkeyModuleEvent_* variables. + * Note: This must be synced with moduleEventVersions */ +#define VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED 0 +#define VALKEYMODULE_EVENT_PERSISTENCE 1 +#define VALKEYMODULE_EVENT_FLUSHDB 2 +#define VALKEYMODULE_EVENT_LOADING 3 +#define VALKEYMODULE_EVENT_CLIENT_CHANGE 4 +#define VALKEYMODULE_EVENT_SHUTDOWN 5 +#define VALKEYMODULE_EVENT_REPLICA_CHANGE 6 +#define VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE 7 +#define VALKEYMODULE_EVENT_CRON_LOOP 8 +#define VALKEYMODULE_EVENT_MODULE_CHANGE 9 +#define VALKEYMODULE_EVENT_LOADING_PROGRESS 10 +#define VALKEYMODULE_EVENT_SWAPDB 11 +#define VALKEYMODULE_EVENT_REPL_BACKUP 12 /* Not used anymore. */ +#define VALKEYMODULE_EVENT_FORK_CHILD 13 +#define VALKEYMODULE_EVENT_REPL_ASYNC_LOAD 14 +#define VALKEYMODULE_EVENT_EVENTLOOP 15 +#define VALKEYMODULE_EVENT_CONFIG 16 +#define VALKEYMODULE_EVENT_KEY 17 +#define _VALKEYMODULE_EVENT_NEXT 18 /* Next event flag, should be updated if a new event added. */ + +typedef struct ValkeyModuleEvent { + uint64_t id; /* VALKEYMODULE_EVENT_... defines. */ + uint64_t dataver; /* Version of the structure we pass as 'data'. */ +} ValkeyModuleEvent; + +struct ValkeyModuleCtx; +struct ValkeyModuleDefragCtx; +typedef void (*ValkeyModuleEventCallback)(struct ValkeyModuleCtx *ctx, ValkeyModuleEvent eid, uint64_t subevent, void *data); + +/* IMPORTANT: When adding a new version of one of below structures that contain + * event data (ValkeyModuleFlushInfoV1 for example) we have to avoid renaming the + * old ValkeyModuleEvent structure. + * For example, if we want to add ValkeyModuleFlushInfoV2, the ValkeyModuleEvent + * structures should be: + * ValkeyModuleEvent_FlushDB = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 1 + * }, + * ValkeyModuleEvent_FlushDBV2 = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 2 + * } + * and NOT: + * ValkeyModuleEvent_FlushDBV1 = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 1 + * }, + * ValkeyModuleEvent_FlushDB = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 2 + * } + * The reason for that is forward-compatibility: We want that module that + * compiled with a new valkeymodule.h to be able to work with a old server, + * unless the author explicitly decided to use the newer event type. + */ +static const ValkeyModuleEvent + ValkeyModuleEvent_ReplicationRoleChanged = { + VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED, + 1 + }, + ValkeyModuleEvent_Persistence = { + VALKEYMODULE_EVENT_PERSISTENCE, + 1 + }, + ValkeyModuleEvent_FlushDB = { + VALKEYMODULE_EVENT_FLUSHDB, + 1 + }, + ValkeyModuleEvent_Loading = { + VALKEYMODULE_EVENT_LOADING, + 1 + }, + ValkeyModuleEvent_ClientChange = { + VALKEYMODULE_EVENT_CLIENT_CHANGE, + 1 + }, + ValkeyModuleEvent_Shutdown = { + VALKEYMODULE_EVENT_SHUTDOWN, + 1 + }, + ValkeyModuleEvent_ReplicaChange = { + VALKEYMODULE_EVENT_REPLICA_CHANGE, + 1 + }, + ValkeyModuleEvent_CronLoop = { + VALKEYMODULE_EVENT_CRON_LOOP, + 1 + }, + ValkeyModuleEvent_MasterLinkChange = { + VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + 1 + }, + ValkeyModuleEvent_ModuleChange = { + VALKEYMODULE_EVENT_MODULE_CHANGE, + 1 + }, + ValkeyModuleEvent_LoadingProgress = { + VALKEYMODULE_EVENT_LOADING_PROGRESS, + 1 + }, + ValkeyModuleEvent_SwapDB = { + VALKEYMODULE_EVENT_SWAPDB, + 1 + }, + ValkeyModuleEvent_ReplAsyncLoad = { + VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + 1 + }, + ValkeyModuleEvent_ForkChild = { + VALKEYMODULE_EVENT_FORK_CHILD, + 1 + }, + ValkeyModuleEvent_EventLoop = { + VALKEYMODULE_EVENT_EVENTLOOP, + 1 + }, + ValkeyModuleEvent_Config = { + VALKEYMODULE_EVENT_CONFIG, + 1 + }, + ValkeyModuleEvent_Key = { + VALKEYMODULE_EVENT_KEY, + 1 + }; + +/* Those are values that are used for the 'subevent' callback argument. */ +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START 0 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START 1 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START 2 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED 3 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED 4 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START 5 +#define _VALKEYMODULE_SUBEVENT_PERSISTENCE_NEXT 6 + +#define VALKEYMODULE_SUBEVENT_LOADING_RDB_START 0 +#define VALKEYMODULE_SUBEVENT_LOADING_AOF_START 1 +#define VALKEYMODULE_SUBEVENT_LOADING_REPL_START 2 +#define VALKEYMODULE_SUBEVENT_LOADING_ENDED 3 +#define VALKEYMODULE_SUBEVENT_LOADING_FAILED 4 +#define _VALKEYMODULE_SUBEVENT_LOADING_NEXT 5 + +#define VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED 0 +#define VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED 1 +#define _VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP 0 +#define VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN 1 +#define _VALKEYMODULE_SUBEVENT_PRIMARY_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE 0 +#define VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE 1 +#define _VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_NEXT 2 + +#define VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY 0 +#define VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA 1 +#define _VALKEYMODULE_EVENT_REPLROLECHANGED_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_FLUSHDB_START 0 +#define VALKEYMODULE_SUBEVENT_FLUSHDB_END 1 +#define _VALKEYMODULE_SUBEVENT_FLUSHDB_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_MODULE_LOADED 0 +#define VALKEYMODULE_SUBEVENT_MODULE_UNLOADED 1 +#define _VALKEYMODULE_SUBEVENT_MODULE_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_CONFIG_CHANGE 0 +#define _VALKEYMODULE_SUBEVENT_CONFIG_NEXT 1 + +#define VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB 0 +#define VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF 1 +#define _VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED 0 +#define VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED 1 +#define VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED 2 +#define _VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT 3 + +#define VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN 0 +#define VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED 1 +#define _VALKEYMODULE_SUBEVENT_FORK_CHILD_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP 0 +#define VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP 1 +#define _VALKEYMODULE_SUBEVENT_EVENTLOOP_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_KEY_DELETED 0 +#define VALKEYMODULE_SUBEVENT_KEY_EXPIRED 1 +#define VALKEYMODULE_SUBEVENT_KEY_EVICTED 2 +#define VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN 3 +#define _VALKEYMODULE_SUBEVENT_KEY_NEXT 4 + +#define _VALKEYMODULE_SUBEVENT_SHUTDOWN_NEXT 0 +#define _VALKEYMODULE_SUBEVENT_CRON_LOOP_NEXT 0 +#define _VALKEYMODULE_SUBEVENT_SWAPDB_NEXT 0 + +/* ValkeyModuleClientInfo flags. */ +#define VALKEYMODULE_CLIENTINFO_FLAG_SSL (1<<0) +#define VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1) +#define VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED (1<<2) +#define VALKEYMODULE_CLIENTINFO_FLAG_TRACKING (1<<3) +#define VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET (1<<4) +#define VALKEYMODULE_CLIENTINFO_FLAG_MULTI (1<<5) + +/* Here we take all the structures that the module pass to the core + * and the other way around. Notably the list here contains the structures + * used by the hooks API ValkeyModule_RegisterToServerEvent(). + * + * The structures always start with a 'version' field. This is useful + * when we want to pass a reference to the structure to the core APIs, + * for the APIs to fill the structure. In that case, the structure 'version' + * field is initialized before passing it to the core, so that the core is + * able to cast the pointer to the appropriate structure version. In this + * way we obtain ABI compatibility. + * + * Here we'll list all the structure versions in case they evolve over time, + * however using a define, we'll make sure to use the last version as the + * public name for the module to use. */ + +#define VALKEYMODULE_CLIENTINFO_VERSION 1 +typedef struct ValkeyModuleClientInfo { + uint64_t version; /* Version of this structure for ABI compat. */ + uint64_t flags; /* VALKEYMODULE_CLIENTINFO_FLAG_* */ + uint64_t id; /* Client ID. */ + char addr[46]; /* IPv4 or IPv6 address. */ + uint16_t port; /* TCP port. */ + uint16_t db; /* Selected DB. */ +} ValkeyModuleClientInfoV1; + +#define ValkeyModuleClientInfo ValkeyModuleClientInfoV1 + +#define VALKEYMODULE_CLIENTINFO_INITIALIZER_V1 { .version = 1 } + +#define VALKEYMODULE_REPLICATIONINFO_VERSION 1 +typedef struct ValkeyModuleReplicationInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + int master; /* true if primary, false if replica */ + char *masterhost; /* primary instance hostname for NOW_REPLICA */ + int masterport; /* primary instance port for NOW_REPLICA */ + char *replid1; /* Main replication ID */ + char *replid2; /* Secondary replication ID */ + uint64_t repl1_offset; /* Main replication offset */ + uint64_t repl2_offset; /* Offset of replid2 validity */ +} ValkeyModuleReplicationInfoV1; + +#define ValkeyModuleReplicationInfo ValkeyModuleReplicationInfoV1 + +#define VALKEYMODULE_FLUSHINFO_VERSION 1 +typedef struct ValkeyModuleFlushInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + int32_t sync; /* Synchronous or threaded flush?. */ + int32_t dbnum; /* Flushed database number, -1 for ALL. */ +} ValkeyModuleFlushInfoV1; + +#define ValkeyModuleFlushInfo ValkeyModuleFlushInfoV1 + +#define VALKEYMODULE_MODULE_CHANGE_VERSION 1 +typedef struct ValkeyModuleModuleChange { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + const char* module_name;/* Name of module loaded or unloaded. */ + int32_t module_version; /* Module version. */ +} ValkeyModuleModuleChangeV1; + +#define ValkeyModuleModuleChange ValkeyModuleModuleChangeV1 + +#define VALKEYMODULE_CONFIGCHANGE_VERSION 1 +typedef struct ValkeyModuleConfigChange { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + uint32_t num_changes; /* how many Valkey config options were changed */ + const char **config_names; /* the config names that were changed */ +} ValkeyModuleConfigChangeV1; + +#define ValkeyModuleConfigChange ValkeyModuleConfigChangeV1 + +#define VALKEYMODULE_CRON_LOOP_VERSION 1 +typedef struct ValkeyModuleCronLoopInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + int32_t hz; /* Approximate number of events per second. */ +} ValkeyModuleCronLoopV1; + +#define ValkeyModuleCronLoop ValkeyModuleCronLoopV1 + +#define VALKEYMODULE_LOADING_PROGRESS_VERSION 1 +typedef struct ValkeyModuleLoadingProgressInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + int32_t hz; /* Approximate number of events per second. */ + int32_t progress; /* Approximate progress between 0 and 1024, or -1 + * if unknown. */ +} ValkeyModuleLoadingProgressV1; + +#define ValkeyModuleLoadingProgress ValkeyModuleLoadingProgressV1 + +#define VALKEYMODULE_SWAPDBINFO_VERSION 1 +typedef struct ValkeyModuleSwapDbInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + int32_t dbnum_first; /* Swap Db first dbnum */ + int32_t dbnum_second; /* Swap Db second dbnum */ +} ValkeyModuleSwapDbInfoV1; + +#define ValkeyModuleSwapDbInfo ValkeyModuleSwapDbInfoV1 + +#define VALKEYMODULE_KEYINFO_VERSION 1 +typedef struct ValkeyModuleKeyInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + ValkeyModuleKey *key; /* Opened key. */ +} ValkeyModuleKeyInfoV1; + +#define ValkeyModuleKeyInfo ValkeyModuleKeyInfoV1 + +typedef enum { + VALKEYMODULE_ACL_LOG_AUTH = 0, /* Authentication failure */ + VALKEYMODULE_ACL_LOG_CMD, /* Command authorization failure */ + VALKEYMODULE_ACL_LOG_KEY, /* Key authorization failure */ + VALKEYMODULE_ACL_LOG_CHANNEL /* Channel authorization failure */ +} ValkeyModuleACLLogEntryReason; + +/* Incomplete structures needed by both the core and modules. */ +typedef struct ValkeyModuleIO ValkeyModuleIO; +typedef struct ValkeyModuleDigest ValkeyModuleDigest; +typedef struct ValkeyModuleInfoCtx ValkeyModuleInfoCtx; +typedef struct ValkeyModuleDefragCtx ValkeyModuleDefragCtx; + +/* Function pointers needed by both the core and modules, these needs to be + * exposed since you can't cast a function pointer to (void *). */ +typedef void (*ValkeyModuleInfoFunc)(ValkeyModuleInfoCtx *ctx, int for_crash_report); +typedef void (*ValkeyModuleDefragFunc)(ValkeyModuleDefragCtx *ctx); +typedef void (*ValkeyModuleUserChangedFunc) (uint64_t client_id, void *privdata); + +/* ------------------------- End of common defines ------------------------ */ + +/* ----------- The rest of the defines are only for modules ----------------- */ +#if !defined VALKEYMODULE_CORE || defined VALKEYMODULE_CORE_MODULE +/* Things defined for modules and core-modules. */ + +/* Macro definitions specific to individual compilers */ +#ifndef VALKEYMODULE_ATTR_UNUSED +# ifdef __GNUC__ +# define VALKEYMODULE_ATTR_UNUSED __attribute__((unused)) +# else +# define VALKEYMODULE_ATTR_UNUSED +# endif +#endif + +#ifndef VALKEYMODULE_ATTR_PRINTF +# ifdef __GNUC__ +# define VALKEYMODULE_ATTR_PRINTF(idx,cnt) __attribute__((format(printf,idx,cnt))) +# else +# define VALKEYMODULE_ATTR_PRINTF(idx,cnt) +# endif +#endif + +#ifndef VALKEYMODULE_ATTR_COMMON +# if defined(__GNUC__) && !(defined(__clang__) && defined(__cplusplus)) +# define VALKEYMODULE_ATTR_COMMON __attribute__((__common__)) +# else +# define VALKEYMODULE_ATTR_COMMON +# endif +#endif + +/* Incomplete structures for compiler checks but opaque access. */ +typedef struct ValkeyModuleCtx ValkeyModuleCtx; +typedef struct ValkeyModuleCommand ValkeyModuleCommand; +typedef struct ValkeyModuleCallReply ValkeyModuleCallReply; +typedef struct ValkeyModuleType ValkeyModuleType; +typedef struct ValkeyModuleBlockedClient ValkeyModuleBlockedClient; +typedef struct ValkeyModuleClusterInfo ValkeyModuleClusterInfo; +typedef struct ValkeyModuleDict ValkeyModuleDict; +typedef struct ValkeyModuleDictIter ValkeyModuleDictIter; +typedef struct ValkeyModuleCommandFilterCtx ValkeyModuleCommandFilterCtx; +typedef struct ValkeyModuleCommandFilter ValkeyModuleCommandFilter; +typedef struct ValkeyModuleServerInfoData ValkeyModuleServerInfoData; +typedef struct ValkeyModuleScanCursor ValkeyModuleScanCursor; +typedef struct ValkeyModuleUser ValkeyModuleUser; +typedef struct ValkeyModuleKeyOptCtx ValkeyModuleKeyOptCtx; +typedef struct ValkeyModuleRdbStream ValkeyModuleRdbStream; + +typedef int (*ValkeyModuleCmdFunc)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc); +typedef void (*ValkeyModuleDisconnectFunc)(ValkeyModuleCtx *ctx, ValkeyModuleBlockedClient *bc); +typedef int (*ValkeyModuleNotificationFunc)(ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key); +typedef void (*ValkeyModulePostNotificationJobFunc) (ValkeyModuleCtx *ctx, void *pd); +typedef void *(*ValkeyModuleTypeLoadFunc)(ValkeyModuleIO *rdb, int encver); +typedef void (*ValkeyModuleTypeSaveFunc)(ValkeyModuleIO *rdb, void *value); +typedef int (*ValkeyModuleTypeAuxLoadFunc)(ValkeyModuleIO *rdb, int encver, int when); +typedef void (*ValkeyModuleTypeAuxSaveFunc)(ValkeyModuleIO *rdb, int when); +typedef void (*ValkeyModuleTypeRewriteFunc)(ValkeyModuleIO *aof, ValkeyModuleString *key, void *value); +typedef size_t (*ValkeyModuleTypeMemUsageFunc)(const void *value); +typedef size_t (*ValkeyModuleTypeMemUsageFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value, size_t sample_size); +typedef void (*ValkeyModuleTypeDigestFunc)(ValkeyModuleDigest *digest, void *value); +typedef void (*ValkeyModuleTypeFreeFunc)(void *value); +typedef size_t (*ValkeyModuleTypeFreeEffortFunc)(ValkeyModuleString *key, const void *value); +typedef size_t (*ValkeyModuleTypeFreeEffortFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef void (*ValkeyModuleTypeUnlinkFunc)(ValkeyModuleString *key, const void *value); +typedef void (*ValkeyModuleTypeUnlinkFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef void *(*ValkeyModuleTypeCopyFunc)(ValkeyModuleString *fromkey, ValkeyModuleString *tokey, const void *value); +typedef void *(*ValkeyModuleTypeCopyFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef int (*ValkeyModuleTypeDefragFunc)(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *key, void **value); +typedef void (*ValkeyModuleClusterMessageReceiver)(ValkeyModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*ValkeyModuleTimerProc)(ValkeyModuleCtx *ctx, void *data); +typedef void (*ValkeyModuleCommandFilterFunc) (ValkeyModuleCommandFilterCtx *filter); +typedef void (*ValkeyModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); +typedef void (*ValkeyModuleScanCB)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, ValkeyModuleKey *key, void *privdata); +typedef void (*ValkeyModuleScanKeyCB)(ValkeyModuleKey *key, ValkeyModuleString *field, ValkeyModuleString *value, void *privdata); +typedef ValkeyModuleString * (*ValkeyModuleConfigGetStringFunc)(const char *name, void *privdata); +typedef long long (*ValkeyModuleConfigGetNumericFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetBoolFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetEnumFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigSetStringFunc)(const char *name, ValkeyModuleString *val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigApplyFunc)(ValkeyModuleCtx *ctx, void *privdata, ValkeyModuleString **err); +typedef void (*ValkeyModuleOnUnblocked)(ValkeyModuleCtx *ctx, ValkeyModuleCallReply *reply, void *private_data); +typedef int (*ValkeyModuleAuthCallback)(ValkeyModuleCtx *ctx, ValkeyModuleString *username, ValkeyModuleString *password, ValkeyModuleString **err); + +typedef struct ValkeyModuleTypeMethods { + uint64_t version; + ValkeyModuleTypeLoadFunc rdb_load; + ValkeyModuleTypeSaveFunc rdb_save; + ValkeyModuleTypeRewriteFunc aof_rewrite; + ValkeyModuleTypeMemUsageFunc mem_usage; + ValkeyModuleTypeDigestFunc digest; + ValkeyModuleTypeFreeFunc free; + ValkeyModuleTypeAuxLoadFunc aux_load; + ValkeyModuleTypeAuxSaveFunc aux_save; + int aux_save_triggers; + ValkeyModuleTypeFreeEffortFunc free_effort; + ValkeyModuleTypeUnlinkFunc unlink; + ValkeyModuleTypeCopyFunc copy; + ValkeyModuleTypeDefragFunc defrag; + ValkeyModuleTypeMemUsageFunc2 mem_usage2; + ValkeyModuleTypeFreeEffortFunc2 free_effort2; + ValkeyModuleTypeUnlinkFunc2 unlink2; + ValkeyModuleTypeCopyFunc2 copy2; + ValkeyModuleTypeAuxSaveFunc aux_save2; +} ValkeyModuleTypeMethods; + +#define VALKEYMODULE_GET_API(name) \ + ValkeyModule_GetApi("ValkeyModule_" #name, ((void **)&ValkeyModule_ ## name)) + +/* Default API declaration prefix (not 'extern' for backwards compatibility) */ +#ifndef VALKEYMODULE_API +#define VALKEYMODULE_API +#endif + +/* Default API declaration suffix (compiler attributes) */ +#ifndef VALKEYMODULE_ATTR +#define VALKEYMODULE_ATTR VALKEYMODULE_ATTR_COMMON +#endif + +VALKEYMODULE_API void * (*ValkeyModule_Alloc)(size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_TryAlloc)(size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_Realloc)(void *ptr, size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_TryRealloc)(void *ptr, size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_Free)(void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_Calloc)(size_t nmemb, size_t size) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_TryCalloc)(size_t nmemb, size_t size) VALKEYMODULE_ATTR; +VALKEYMODULE_API char * (*ValkeyModule_Strdup)(const char *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetApi)(const char *, void *) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CreateCommand)(ValkeyModuleCtx *ctx, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCommand *(*ValkeyModule_GetCommand)(ValkeyModuleCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CreateSubcommand)(ValkeyModuleCommand *parent, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetCommandInfo)(ValkeyModuleCommand *command, const ValkeyModuleCommandInfo *info) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetCommandACLCategories)(ValkeyModuleCommand *command, const char *ctgrsflags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AddACLCategory)(ValkeyModuleCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetModuleAttribs)(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsModuleNameBusy)(const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_WrongArity)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithLongLong)(ValkeyModuleCtx *ctx, long long ll) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetSelectedDb)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SelectDb)(ValkeyModuleCtx *ctx, int newid) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_KeyExists)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleKey * (*ValkeyModule_OpenKey)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, int mode) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetOpenKeyModesAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_CloseKey)(ValkeyModuleKey *kp) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_KeyType)(ValkeyModuleKey *kp) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_ValueLength)(ValkeyModuleKey *kp) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListPush)(ValkeyModuleKey *kp, int where, ValkeyModuleString *ele) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ListPop)(ValkeyModuleKey *key, int where) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ListGet)(ValkeyModuleKey *key, long index) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListSet)(ValkeyModuleKey *key, long index, ValkeyModuleString *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListInsert)(ValkeyModuleKey *key, long index, ValkeyModuleString *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListDelete)(ValkeyModuleKey *key, long index) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_Call)(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_CallReplyProto)(ValkeyModuleCallReply *reply, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeCallReply)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyType)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_CallReplyInteger)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API double (*ValkeyModule_CallReplyDouble)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyBool)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char* (*ValkeyModule_CallReplyBigNumber)(ValkeyModuleCallReply *reply, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char* (*ValkeyModule_CallReplyVerbatim)(ValkeyModuleCallReply *reply, size_t *len, const char **format) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_CallReplySetElement)(ValkeyModuleCallReply *reply, size_t idx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyMapElement)(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyAttributeElement)(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_CallReplyPromiseSetUnblockHandler)(ValkeyModuleCallReply *reply, ValkeyModuleOnUnblocked on_unblock, void *private_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyPromiseAbort)(ValkeyModuleCallReply *reply, void **private_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_CallReplyAttribute)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_CallReplyLength)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_CallReplyArrayElement)(ValkeyModuleCallReply *reply, size_t idx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateString)(ValkeyModuleCtx *ctx, const char *ptr, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromLongLong)(ValkeyModuleCtx *ctx, long long ll) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromULongLong)(ValkeyModuleCtx *ctx, unsigned long long ull) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromDouble)(ValkeyModuleCtx *ctx, double d) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromLongDouble)(ValkeyModuleCtx *ctx, long double ld, int humanfriendly) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromString)(ValkeyModuleCtx *ctx, const ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromStreamID)(ValkeyModuleCtx *ctx, const ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringPrintf)(ValkeyModuleCtx *ctx, const char *fmt, ...) VALKEYMODULE_ATTR_PRINTF(2,3) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_StringPtrLen)(const ValkeyModuleString *str, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithError)(ValkeyModuleCtx *ctx, const char *err) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithErrorFormat)(ValkeyModuleCtx *ctx, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithSimpleString)(ValkeyModuleCtx *ctx, const char *msg) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithArray)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithMap)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithSet)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithAttribute)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithNullArray)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithEmptyArray)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetArrayLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetMapLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetSetLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetAttributeLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetPushLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithStringBuffer)(ValkeyModuleCtx *ctx, const char *buf, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithCString)(ValkeyModuleCtx *ctx, const char *buf) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithEmptyString)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithVerbatimString)(ValkeyModuleCtx *ctx, const char *buf, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithVerbatimStringType)(ValkeyModuleCtx *ctx, const char *buf, size_t len, const char *ext) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithNull)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithBool)(ValkeyModuleCtx *ctx, int b) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithLongDouble)(ValkeyModuleCtx *ctx, long double d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithDouble)(ValkeyModuleCtx *ctx, double d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithBigNumber)(ValkeyModuleCtx *ctx, const char *bignum, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithCallReply)(ValkeyModuleCtx *ctx, ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToLongLong)(const ValkeyModuleString *str, long long *ll) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToULongLong)(const ValkeyModuleString *str, unsigned long long *ull) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToDouble)(const ValkeyModuleString *str, double *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToLongDouble)(const ValkeyModuleString *str, long double *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToStreamID)(const ValkeyModuleString *str, ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_AutoMemory)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_Replicate)(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplicateVerbatim)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_CallReplyStringPtr)(ValkeyModuleCallReply *reply, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromCallReply)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DeleteKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_UnlinkKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringSet)(ValkeyModuleKey *key, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API char * (*ValkeyModule_StringDMA)(ValkeyModuleKey *key, size_t *len, int mode) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringTruncate)(ValkeyModuleKey *key, size_t newlen) VALKEYMODULE_ATTR; +VALKEYMODULE_API mstime_t (*ValkeyModule_GetExpire)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetExpire)(ValkeyModuleKey *key, mstime_t expire) VALKEYMODULE_ATTR; +VALKEYMODULE_API mstime_t (*ValkeyModule_GetAbsExpire)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetAbsExpire)(ValkeyModuleKey *key, mstime_t expire) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ResetDataset)(int restart_aof, int async) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_DbSize)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_RandomKey)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetAdd)(ValkeyModuleKey *key, double score, ValkeyModuleString *ele, int *flagsptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetIncrby)(ValkeyModuleKey *key, double score, ValkeyModuleString *ele, int *flagsptr, double *newscore) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetScore)(ValkeyModuleKey *key, ValkeyModuleString *ele, double *score) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRem)(ValkeyModuleKey *key, ValkeyModuleString *ele, int *deleted) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ZsetRangeStop)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetFirstInScoreRange)(ValkeyModuleKey *key, double min, double max, int minex, int maxex) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetLastInScoreRange)(ValkeyModuleKey *key, double min, double max, int minex, int maxex) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetFirstInLexRange)(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetLastInLexRange)(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ZsetRangeCurrentElement)(ValkeyModuleKey *key, double *score) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRangeNext)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRangePrev)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRangeEndReached)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_HashSet)(ValkeyModuleKey *key, int flags, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_HashGet)(ValkeyModuleKey *key, int flags, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamAdd)(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id, ValkeyModuleString **argv, int64_t numfields) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamDelete)(ValkeyModuleKey *key, ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorStart)(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *startid, ValkeyModuleStreamID *endid) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorStop)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorNextID)(ValkeyModuleKey *key, ValkeyModuleStreamID *id, long *numfields) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorNextField)(ValkeyModuleKey *key, ValkeyModuleString **field_ptr, ValkeyModuleString **value_ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorDelete)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_StreamTrimByLength)(ValkeyModuleKey *key, int flags, long long length) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_StreamTrimByID)(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsKeysPositionRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_KeyAtPos)(ValkeyModuleCtx *ctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_KeyAtPosWithFlags)(ValkeyModuleCtx *ctx, int pos, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsChannelsPositionRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ChannelAtPosWithFlags)(ValkeyModuleCtx *ctx, int pos, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_GetClientId)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetClientUserNameById)(ValkeyModuleCtx *ctx, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetClientInfoById)(void *ci, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetClientNameById)(ValkeyModuleCtx *ctx, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetClientNameById)(uint64_t id, ValkeyModuleString *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_PublishMessage)(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_PublishMessageShard)(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetContextFlags)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AvoidReplicaTraffic)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_PoolAlloc)(ValkeyModuleCtx *ctx, size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleType * (*ValkeyModule_CreateDataType)(ValkeyModuleCtx *ctx, const char *name, int encver, ValkeyModuleTypeMethods *typemethods) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ModuleTypeSetValue)(ValkeyModuleKey *key, ValkeyModuleType *mt, void *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ModuleTypeReplaceValue)(ValkeyModuleKey *key, ValkeyModuleType *mt, void *new_value, void **old_value) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleType * (*ValkeyModule_ModuleTypeGetType)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_ModuleTypeGetValue)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsIOError)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetModuleOptions)(ValkeyModuleCtx *ctx, int options) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SignalModifiedKey)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveUnsigned)(ValkeyModuleIO *io, uint64_t value) VALKEYMODULE_ATTR; +VALKEYMODULE_API uint64_t (*ValkeyModule_LoadUnsigned)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveSigned)(ValkeyModuleIO *io, int64_t value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int64_t (*ValkeyModule_LoadSigned)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_EmitAOF)(ValkeyModuleIO *io, const char *cmdname, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveString)(ValkeyModuleIO *io, ValkeyModuleString *s) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveStringBuffer)(ValkeyModuleIO *io, const char *str, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_LoadString)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API char * (*ValkeyModule_LoadStringBuffer)(ValkeyModuleIO *io, size_t *lenptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveDouble)(ValkeyModuleIO *io, double value) VALKEYMODULE_ATTR; +VALKEYMODULE_API double (*ValkeyModule_LoadDouble)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveFloat)(ValkeyModuleIO *io, float value) VALKEYMODULE_ATTR; +VALKEYMODULE_API float (*ValkeyModule_LoadFloat)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveLongDouble)(ValkeyModuleIO *io, long double value) VALKEYMODULE_ATTR; +VALKEYMODULE_API long double (*ValkeyModule_LoadLongDouble)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_LoadDataTypeFromString)(const ValkeyModuleString *str, const ValkeyModuleType *mt) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_LoadDataTypeFromStringEncver)(const ValkeyModuleString *str, const ValkeyModuleType *mt, int encver) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_SaveDataTypeToString)(ValkeyModuleCtx *ctx, void *data, const ValkeyModuleType *mt) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_Log)(ValkeyModuleCtx *ctx, const char *level, const char *fmt, ...) VALKEYMODULE_ATTR VALKEYMODULE_ATTR_PRINTF(3,4); +VALKEYMODULE_API void (*ValkeyModule_LogIOError)(ValkeyModuleIO *io, const char *levelstr, const char *fmt, ...) VALKEYMODULE_ATTR VALKEYMODULE_ATTR_PRINTF(3,4); +VALKEYMODULE_API void (*ValkeyModule__Assert)(const char *estr, const char *file, int line) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_LatencyAddSample)(const char *event, mstime_t latency) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringAppendBuffer)(ValkeyModuleCtx *ctx, ValkeyModuleString *str, const char *buf, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_TrimStringAllocation)(ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RetainString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_HoldString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringCompare)(const ValkeyModuleString *a, const ValkeyModuleString *b) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCtx * (*ValkeyModule_GetContextFromIO)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromIO)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromModuleKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromModuleKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromIO)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetToDbIdFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetToKeyNameFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API mstime_t (*ValkeyModule_Milliseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API uint64_t (*ValkeyModule_MonotonicMicroseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API ustime_t (*ValkeyModule_Microseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API ustime_t (*ValkeyModule_CachedMicroseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DigestAddStringBuffer)(ValkeyModuleDigest *md, const char *ele, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DigestAddLongLong)(ValkeyModuleDigest *md, long long ele) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DigestEndSequence)(ValkeyModuleDigest *md) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromDigest)(ValkeyModuleDigest *dig) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromDigest)(ValkeyModuleDigest *dig) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleDict * (*ValkeyModule_CreateDict)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeDict)(ValkeyModuleCtx *ctx, ValkeyModuleDict *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API uint64_t (*ValkeyModule_DictSize)(ValkeyModuleDict *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictSetC)(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictReplaceC)(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictSet)(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictReplace)(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictGetC)(ValkeyModuleDict *d, void *key, size_t keylen, int *nokey) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictGet)(ValkeyModuleDict *d, ValkeyModuleString *key, int *nokey) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictDelC)(ValkeyModuleDict *d, void *key, size_t keylen, void *oldval) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictDel)(ValkeyModuleDict *d, ValkeyModuleString *key, void *oldval) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleDictIter * (*ValkeyModule_DictIteratorStartC)(ValkeyModuleDict *d, const char *op, void *key, size_t keylen) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleDictIter * (*ValkeyModule_DictIteratorStart)(ValkeyModuleDict *d, const char *op, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DictIteratorStop)(ValkeyModuleDictIter *di) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictIteratorReseekC)(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictIteratorReseek)(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictNextC)(ValkeyModuleDictIter *di, size_t *keylen, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictPrevC)(ValkeyModuleDictIter *di, size_t *keylen, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_DictNext)(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_DictPrev)(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictCompareC)(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictCompare)(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterInfoFunc)(ValkeyModuleCtx *ctx, ValkeyModuleInfoFunc cb) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RegisterAuthCallback)(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback cb) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddSection)(ValkeyModuleInfoCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoBeginDictField)(ValkeyModuleInfoCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoEndDictField)(ValkeyModuleInfoCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldString)(ValkeyModuleInfoCtx *ctx, const char *field, ValkeyModuleString *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldCString)(ValkeyModuleInfoCtx *ctx, const char *field,const char *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldDouble)(ValkeyModuleInfoCtx *ctx, const char *field, double value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldLongLong)(ValkeyModuleInfoCtx *ctx, const char *field, long long value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldULongLong)(ValkeyModuleInfoCtx *ctx, const char *field, unsigned long long value) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleServerInfoData * (*ValkeyModule_GetServerInfo)(ValkeyModuleCtx *ctx, const char *section) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeServerInfo)(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ServerInfoGetField)(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data, const char* field) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_ServerInfoGetFieldC)(ValkeyModuleServerInfoData *data, const char* field) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_ServerInfoGetFieldSigned)(ValkeyModuleServerInfoData *data, const char* field, int *out_err) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_ServerInfoGetFieldUnsigned)(ValkeyModuleServerInfoData *data, const char* field, int *out_err) VALKEYMODULE_ATTR; +VALKEYMODULE_API double (*ValkeyModule_ServerInfoGetFieldDouble)(ValkeyModuleServerInfoData *data, const char* field, int *out_err) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SubscribeToServerEvent)(ValkeyModuleCtx *ctx, ValkeyModuleEvent event, ValkeyModuleEventCallback callback) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetLRU)(ValkeyModuleKey *key, mstime_t lru_idle) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetLRU)(ValkeyModuleKey *key, mstime_t *lru_idle) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetLFU)(ValkeyModuleKey *key, long long lfu_freq) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetLFU)(ValkeyModuleKey *key, long long *lfu_freq) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClientOnKeys)(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClientOnKeysWithFlags)(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SignalKeyAsReady)(ValkeyModuleCtx *ctx, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetBlockedClientReadyKey)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleScanCursor * (*ValkeyModule_ScanCursorCreate)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ScanCursorRestart)(ValkeyModuleScanCursor *cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ScanCursorDestroy)(ValkeyModuleScanCursor *cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_Scan)(ValkeyModuleCtx *ctx, ValkeyModuleScanCursor *cursor, ValkeyModuleScanCB fn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ScanKey)(ValkeyModuleKey *key, ValkeyModuleScanCursor *cursor, ValkeyModuleScanKeyCB fn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetContextFlagsAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetModuleOptionsAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetKeyspaceNotificationFlagsAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsSubEventSupported)(ValkeyModuleEvent event, uint64_t subevent) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetServerVersion)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetTypeMethodVersion)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_Yield)(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClient)(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_BlockClientGetPrivateData)(ValkeyModuleBlockedClient *blocked_client) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_BlockClientSetPrivateData)(ValkeyModuleBlockedClient *blocked_client, void *private_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClientOnAuth)(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback reply_callback, void (*free_privdata)(ValkeyModuleCtx*,void*)) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_UnblockClient)(ValkeyModuleBlockedClient *bc, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsBlockedReplyRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsBlockedTimeoutRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_GetBlockedClientPrivateData)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_GetBlockedClientHandle)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AbortBlock)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_BlockedClientMeasureTimeStart)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_BlockedClientMeasureTimeEnd)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCtx * (*ValkeyModule_GetThreadSafeContext)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCtx * (*ValkeyModule_GetDetachedThreadSafeContext)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeThreadSafeContext)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ThreadSafeContextLock)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ThreadSafeContextTryLock)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ThreadSafeContextUnlock)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SubscribeToKeyspaceEvents)(ValkeyModuleCtx *ctx, int types, ValkeyModuleNotificationFunc cb) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AddPostNotificationJob)(ValkeyModuleCtx *ctx, ValkeyModulePostNotificationJobFunc callback, void *pd, void (*free_pd)(void*)) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_NotifyKeyspaceEvent)(ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetNotifyKeyspaceEvents)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_BlockedClientDisconnected)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RegisterClusterMessageReceiver)(ValkeyModuleCtx *ctx, uint8_t type, ValkeyModuleClusterMessageReceiver callback) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SendClusterMessage)(ValkeyModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetClusterNodeInfo)(ValkeyModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API char ** (*ValkeyModule_GetClusterNodesList)(ValkeyModuleCtx *ctx, size_t *numnodes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeClusterNodesList)(char **ids) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleTimerID (*ValkeyModule_CreateTimer)(ValkeyModuleCtx *ctx, mstime_t period, ValkeyModuleTimerProc callback, void *data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StopTimer)(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, void **data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetTimerInfo)(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, uint64_t *remaining, void **data) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_GetMyClusterID)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_GetClusterSize)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_GetRandomBytes)(unsigned char *dst, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_GetRandomHexChars)(char *dst, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetDisconnectCallback)(ValkeyModuleBlockedClient *bc, ValkeyModuleDisconnectFunc callback) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetClusterFlags)(ValkeyModuleCtx *ctx, uint64_t flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned int (*ValkeyModule_ClusterKeySlot)(ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char *(*ValkeyModule_ClusterCanonicalKeyNameInSlot)(unsigned int slot) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ExportSharedAPI)(ValkeyModuleCtx *ctx, const char *apiname, void *func) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_GetSharedAPI)(ValkeyModuleCtx *ctx, const char *apiname) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCommandFilter * (*ValkeyModule_RegisterCommandFilter)(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilterFunc cb, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_UnregisterCommandFilter)(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilter *filter) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgsCount)(ValkeyModuleCommandFilterCtx *fctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CommandFilterArgGet)(ValkeyModuleCommandFilterCtx *fctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgInsert)(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgReplace)(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgDelete)(ValkeyModuleCommandFilterCtx *fctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_CommandFilterGetClientId)(ValkeyModuleCommandFilterCtx *fctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_Fork)(ValkeyModuleForkDoneHandler cb, void *user_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SendChildHeartbeat)(double progress) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ExitFromChild)(int retcode) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_KillForkChild)(int child_pid) VALKEYMODULE_ATTR; +VALKEYMODULE_API float (*ValkeyModule_GetUsedMemoryRatio)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocSize)(void* ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocUsableSize)(void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocSizeString)(ValkeyModuleString* str) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocSizeDict)(ValkeyModuleDict* dict) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleUser * (*ValkeyModule_CreateModuleUser)(const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeModuleUser)(ValkeyModuleUser *user) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetContextUser)(ValkeyModuleCtx *ctx, const ValkeyModuleUser *user) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetModuleUserACL)(ValkeyModuleUser *user, const char* acl) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetModuleUserACLString)(ValkeyModuleCtx * ctx, ValkeyModuleUser *user, const char* acl, ValkeyModuleString **error) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetModuleUserACLString)(ValkeyModuleUser *user) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetCurrentUserName)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleUser * (*ValkeyModule_GetModuleUserFromUserName)(ValkeyModuleString *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ACLCheckCommandPermissions)(ValkeyModuleUser *user, ValkeyModuleString **argv, int argc) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ACLCheckKeyPermissions)(ValkeyModuleUser *user, ValkeyModuleString *key, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ACLCheckChannelPermissions)(ValkeyModuleUser *user, ValkeyModuleString *ch, int literal) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ACLAddLogEntry)(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ACLAddLogEntryByUserName)(ValkeyModuleCtx *ctx, ValkeyModuleString *user, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AuthenticateClientWithACLUser)(ValkeyModuleCtx *ctx, const char *name, size_t len, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AuthenticateClientWithUser)(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DeauthenticateAndCloseClient)(ValkeyModuleCtx *ctx, uint64_t client_id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RedactClientCommandArgument)(ValkeyModuleCtx *ctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetClientCertificate)(ValkeyModuleCtx *ctx, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int *(*ValkeyModule_GetCommandKeys)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys) VALKEYMODULE_ATTR; +VALKEYMODULE_API int *(*ValkeyModule_GetCommandKeysWithFlags)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys, int **out_flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char *(*ValkeyModule_GetCurrentCommandName)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterDefragFunc)(ValkeyModuleCtx *ctx, ValkeyModuleDefragFunc func) VALKEYMODULE_ATTR; +VALKEYMODULE_API void *(*ValkeyModule_DefragAlloc)(ValkeyModuleDefragCtx *ctx, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString *(*ValkeyModule_DefragModuleString)(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DefragShouldStop)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DefragCursorSet)(ValkeyModuleDefragCtx *ctx, unsigned long cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DefragCursorGet)(ValkeyModuleDefragCtx *ctx, unsigned long *cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromDefragCtx)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromDefragCtx)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_EventLoopAdd)(int fd, int mask, ValkeyModuleEventLoopFunc func, void *user_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_EventLoopDel)(int fd, int mask) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_EventLoopAddOneShot)(ValkeyModuleEventLoopOneShotFunc func, void *user_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterBoolConfig)(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, ValkeyModuleConfigGetBoolFunc getfn, ValkeyModuleConfigSetBoolFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterNumericConfig)(ValkeyModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, ValkeyModuleConfigGetNumericFunc getfn, ValkeyModuleConfigSetNumericFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterStringConfig)(ValkeyModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, ValkeyModuleConfigGetStringFunc getfn, ValkeyModuleConfigSetStringFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterEnumConfig)(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, ValkeyModuleConfigGetEnumFunc getfn, ValkeyModuleConfigSetEnumFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_LoadConfigs)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleRdbStream *(*ValkeyModule_RdbStreamCreateFromFile)(const char *filename) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RdbStreamFree)(ValkeyModuleRdbStream *stream) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RdbLoad)(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RdbSave)(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) VALKEYMODULE_ATTR; + +#define ValkeyModule_IsAOFClient(id) ((id) == UINT64_MAX) + +/* This is included inline inside each Valkey module. */ +static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) VALKEYMODULE_ATTR_UNUSED; +static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) { + void *getapifuncptr = ((void**)ctx)[0]; + ValkeyModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr; + VALKEYMODULE_GET_API(Alloc); + VALKEYMODULE_GET_API(TryAlloc); + VALKEYMODULE_GET_API(Calloc); + VALKEYMODULE_GET_API(TryCalloc); + VALKEYMODULE_GET_API(Free); + VALKEYMODULE_GET_API(Realloc); + VALKEYMODULE_GET_API(TryRealloc); + VALKEYMODULE_GET_API(Strdup); + VALKEYMODULE_GET_API(CreateCommand); + VALKEYMODULE_GET_API(GetCommand); + VALKEYMODULE_GET_API(CreateSubcommand); + VALKEYMODULE_GET_API(SetCommandInfo); + VALKEYMODULE_GET_API(SetCommandACLCategories); + VALKEYMODULE_GET_API(AddACLCategory); + VALKEYMODULE_GET_API(SetModuleAttribs); + VALKEYMODULE_GET_API(IsModuleNameBusy); + VALKEYMODULE_GET_API(WrongArity); + VALKEYMODULE_GET_API(ReplyWithLongLong); + VALKEYMODULE_GET_API(ReplyWithError); + VALKEYMODULE_GET_API(ReplyWithErrorFormat); + VALKEYMODULE_GET_API(ReplyWithSimpleString); + VALKEYMODULE_GET_API(ReplyWithArray); + VALKEYMODULE_GET_API(ReplyWithMap); + VALKEYMODULE_GET_API(ReplyWithSet); + VALKEYMODULE_GET_API(ReplyWithAttribute); + VALKEYMODULE_GET_API(ReplyWithNullArray); + VALKEYMODULE_GET_API(ReplyWithEmptyArray); + VALKEYMODULE_GET_API(ReplySetArrayLength); + VALKEYMODULE_GET_API(ReplySetMapLength); + VALKEYMODULE_GET_API(ReplySetSetLength); + VALKEYMODULE_GET_API(ReplySetAttributeLength); + VALKEYMODULE_GET_API(ReplySetPushLength); + VALKEYMODULE_GET_API(ReplyWithStringBuffer); + VALKEYMODULE_GET_API(ReplyWithCString); + VALKEYMODULE_GET_API(ReplyWithString); + VALKEYMODULE_GET_API(ReplyWithEmptyString); + VALKEYMODULE_GET_API(ReplyWithVerbatimString); + VALKEYMODULE_GET_API(ReplyWithVerbatimStringType); + VALKEYMODULE_GET_API(ReplyWithNull); + VALKEYMODULE_GET_API(ReplyWithBool); + VALKEYMODULE_GET_API(ReplyWithCallReply); + VALKEYMODULE_GET_API(ReplyWithDouble); + VALKEYMODULE_GET_API(ReplyWithBigNumber); + VALKEYMODULE_GET_API(ReplyWithLongDouble); + VALKEYMODULE_GET_API(GetSelectedDb); + VALKEYMODULE_GET_API(SelectDb); + VALKEYMODULE_GET_API(KeyExists); + VALKEYMODULE_GET_API(OpenKey); + VALKEYMODULE_GET_API(GetOpenKeyModesAll); + VALKEYMODULE_GET_API(CloseKey); + VALKEYMODULE_GET_API(KeyType); + VALKEYMODULE_GET_API(ValueLength); + VALKEYMODULE_GET_API(ListPush); + VALKEYMODULE_GET_API(ListPop); + VALKEYMODULE_GET_API(ListGet); + VALKEYMODULE_GET_API(ListSet); + VALKEYMODULE_GET_API(ListInsert); + VALKEYMODULE_GET_API(ListDelete); + VALKEYMODULE_GET_API(StringToLongLong); + VALKEYMODULE_GET_API(StringToULongLong); + VALKEYMODULE_GET_API(StringToDouble); + VALKEYMODULE_GET_API(StringToLongDouble); + VALKEYMODULE_GET_API(StringToStreamID); + VALKEYMODULE_GET_API(Call); + VALKEYMODULE_GET_API(CallReplyProto); + VALKEYMODULE_GET_API(FreeCallReply); + VALKEYMODULE_GET_API(CallReplyInteger); + VALKEYMODULE_GET_API(CallReplyDouble); + VALKEYMODULE_GET_API(CallReplyBool); + VALKEYMODULE_GET_API(CallReplyBigNumber); + VALKEYMODULE_GET_API(CallReplyVerbatim); + VALKEYMODULE_GET_API(CallReplySetElement); + VALKEYMODULE_GET_API(CallReplyMapElement); + VALKEYMODULE_GET_API(CallReplyAttributeElement); + VALKEYMODULE_GET_API(CallReplyPromiseSetUnblockHandler); + VALKEYMODULE_GET_API(CallReplyPromiseAbort); + VALKEYMODULE_GET_API(CallReplyAttribute); + VALKEYMODULE_GET_API(CallReplyType); + VALKEYMODULE_GET_API(CallReplyLength); + VALKEYMODULE_GET_API(CallReplyArrayElement); + VALKEYMODULE_GET_API(CallReplyStringPtr); + VALKEYMODULE_GET_API(CreateStringFromCallReply); + VALKEYMODULE_GET_API(CreateString); + VALKEYMODULE_GET_API(CreateStringFromLongLong); + VALKEYMODULE_GET_API(CreateStringFromULongLong); + VALKEYMODULE_GET_API(CreateStringFromDouble); + VALKEYMODULE_GET_API(CreateStringFromLongDouble); + VALKEYMODULE_GET_API(CreateStringFromString); + VALKEYMODULE_GET_API(CreateStringFromStreamID); + VALKEYMODULE_GET_API(CreateStringPrintf); + VALKEYMODULE_GET_API(FreeString); + VALKEYMODULE_GET_API(StringPtrLen); + VALKEYMODULE_GET_API(AutoMemory); + VALKEYMODULE_GET_API(Replicate); + VALKEYMODULE_GET_API(ReplicateVerbatim); + VALKEYMODULE_GET_API(DeleteKey); + VALKEYMODULE_GET_API(UnlinkKey); + VALKEYMODULE_GET_API(StringSet); + VALKEYMODULE_GET_API(StringDMA); + VALKEYMODULE_GET_API(StringTruncate); + VALKEYMODULE_GET_API(GetExpire); + VALKEYMODULE_GET_API(SetExpire); + VALKEYMODULE_GET_API(GetAbsExpire); + VALKEYMODULE_GET_API(SetAbsExpire); + VALKEYMODULE_GET_API(ResetDataset); + VALKEYMODULE_GET_API(DbSize); + VALKEYMODULE_GET_API(RandomKey); + VALKEYMODULE_GET_API(ZsetAdd); + VALKEYMODULE_GET_API(ZsetIncrby); + VALKEYMODULE_GET_API(ZsetScore); + VALKEYMODULE_GET_API(ZsetRem); + VALKEYMODULE_GET_API(ZsetRangeStop); + VALKEYMODULE_GET_API(ZsetFirstInScoreRange); + VALKEYMODULE_GET_API(ZsetLastInScoreRange); + VALKEYMODULE_GET_API(ZsetFirstInLexRange); + VALKEYMODULE_GET_API(ZsetLastInLexRange); + VALKEYMODULE_GET_API(ZsetRangeCurrentElement); + VALKEYMODULE_GET_API(ZsetRangeNext); + VALKEYMODULE_GET_API(ZsetRangePrev); + VALKEYMODULE_GET_API(ZsetRangeEndReached); + VALKEYMODULE_GET_API(HashSet); + VALKEYMODULE_GET_API(HashGet); + VALKEYMODULE_GET_API(StreamAdd); + VALKEYMODULE_GET_API(StreamDelete); + VALKEYMODULE_GET_API(StreamIteratorStart); + VALKEYMODULE_GET_API(StreamIteratorStop); + VALKEYMODULE_GET_API(StreamIteratorNextID); + VALKEYMODULE_GET_API(StreamIteratorNextField); + VALKEYMODULE_GET_API(StreamIteratorDelete); + VALKEYMODULE_GET_API(StreamTrimByLength); + VALKEYMODULE_GET_API(StreamTrimByID); + VALKEYMODULE_GET_API(IsKeysPositionRequest); + VALKEYMODULE_GET_API(KeyAtPos); + VALKEYMODULE_GET_API(KeyAtPosWithFlags); + VALKEYMODULE_GET_API(IsChannelsPositionRequest); + VALKEYMODULE_GET_API(ChannelAtPosWithFlags); + VALKEYMODULE_GET_API(GetClientId); + VALKEYMODULE_GET_API(GetClientUserNameById); + VALKEYMODULE_GET_API(GetContextFlags); + VALKEYMODULE_GET_API(AvoidReplicaTraffic); + VALKEYMODULE_GET_API(PoolAlloc); + VALKEYMODULE_GET_API(CreateDataType); + VALKEYMODULE_GET_API(ModuleTypeSetValue); + VALKEYMODULE_GET_API(ModuleTypeReplaceValue); + VALKEYMODULE_GET_API(ModuleTypeGetType); + VALKEYMODULE_GET_API(ModuleTypeGetValue); + VALKEYMODULE_GET_API(IsIOError); + VALKEYMODULE_GET_API(SetModuleOptions); + VALKEYMODULE_GET_API(SignalModifiedKey); + VALKEYMODULE_GET_API(SaveUnsigned); + VALKEYMODULE_GET_API(LoadUnsigned); + VALKEYMODULE_GET_API(SaveSigned); + VALKEYMODULE_GET_API(LoadSigned); + VALKEYMODULE_GET_API(SaveString); + VALKEYMODULE_GET_API(SaveStringBuffer); + VALKEYMODULE_GET_API(LoadString); + VALKEYMODULE_GET_API(LoadStringBuffer); + VALKEYMODULE_GET_API(SaveDouble); + VALKEYMODULE_GET_API(LoadDouble); + VALKEYMODULE_GET_API(SaveFloat); + VALKEYMODULE_GET_API(LoadFloat); + VALKEYMODULE_GET_API(SaveLongDouble); + VALKEYMODULE_GET_API(LoadLongDouble); + VALKEYMODULE_GET_API(SaveDataTypeToString); + VALKEYMODULE_GET_API(LoadDataTypeFromString); + VALKEYMODULE_GET_API(LoadDataTypeFromStringEncver); + VALKEYMODULE_GET_API(EmitAOF); + VALKEYMODULE_GET_API(Log); + VALKEYMODULE_GET_API(LogIOError); + VALKEYMODULE_GET_API(_Assert); + VALKEYMODULE_GET_API(LatencyAddSample); + VALKEYMODULE_GET_API(StringAppendBuffer); + VALKEYMODULE_GET_API(TrimStringAllocation); + VALKEYMODULE_GET_API(RetainString); + VALKEYMODULE_GET_API(HoldString); + VALKEYMODULE_GET_API(StringCompare); + VALKEYMODULE_GET_API(GetContextFromIO); + VALKEYMODULE_GET_API(GetKeyNameFromIO); + VALKEYMODULE_GET_API(GetKeyNameFromModuleKey); + VALKEYMODULE_GET_API(GetDbIdFromModuleKey); + VALKEYMODULE_GET_API(GetDbIdFromIO); + VALKEYMODULE_GET_API(GetKeyNameFromOptCtx); + VALKEYMODULE_GET_API(GetToKeyNameFromOptCtx); + VALKEYMODULE_GET_API(GetDbIdFromOptCtx); + VALKEYMODULE_GET_API(GetToDbIdFromOptCtx); + VALKEYMODULE_GET_API(Milliseconds); + VALKEYMODULE_GET_API(MonotonicMicroseconds); + VALKEYMODULE_GET_API(Microseconds); + VALKEYMODULE_GET_API(CachedMicroseconds); + VALKEYMODULE_GET_API(DigestAddStringBuffer); + VALKEYMODULE_GET_API(DigestAddLongLong); + VALKEYMODULE_GET_API(DigestEndSequence); + VALKEYMODULE_GET_API(GetKeyNameFromDigest); + VALKEYMODULE_GET_API(GetDbIdFromDigest); + VALKEYMODULE_GET_API(CreateDict); + VALKEYMODULE_GET_API(FreeDict); + VALKEYMODULE_GET_API(DictSize); + VALKEYMODULE_GET_API(DictSetC); + VALKEYMODULE_GET_API(DictReplaceC); + VALKEYMODULE_GET_API(DictSet); + VALKEYMODULE_GET_API(DictReplace); + VALKEYMODULE_GET_API(DictGetC); + VALKEYMODULE_GET_API(DictGet); + VALKEYMODULE_GET_API(DictDelC); + VALKEYMODULE_GET_API(DictDel); + VALKEYMODULE_GET_API(DictIteratorStartC); + VALKEYMODULE_GET_API(DictIteratorStart); + VALKEYMODULE_GET_API(DictIteratorStop); + VALKEYMODULE_GET_API(DictIteratorReseekC); + VALKEYMODULE_GET_API(DictIteratorReseek); + VALKEYMODULE_GET_API(DictNextC); + VALKEYMODULE_GET_API(DictPrevC); + VALKEYMODULE_GET_API(DictNext); + VALKEYMODULE_GET_API(DictPrev); + VALKEYMODULE_GET_API(DictCompare); + VALKEYMODULE_GET_API(DictCompareC); + VALKEYMODULE_GET_API(RegisterInfoFunc); + VALKEYMODULE_GET_API(RegisterAuthCallback); + VALKEYMODULE_GET_API(InfoAddSection); + VALKEYMODULE_GET_API(InfoBeginDictField); + VALKEYMODULE_GET_API(InfoEndDictField); + VALKEYMODULE_GET_API(InfoAddFieldString); + VALKEYMODULE_GET_API(InfoAddFieldCString); + VALKEYMODULE_GET_API(InfoAddFieldDouble); + VALKEYMODULE_GET_API(InfoAddFieldLongLong); + VALKEYMODULE_GET_API(InfoAddFieldULongLong); + VALKEYMODULE_GET_API(GetServerInfo); + VALKEYMODULE_GET_API(FreeServerInfo); + VALKEYMODULE_GET_API(ServerInfoGetField); + VALKEYMODULE_GET_API(ServerInfoGetFieldC); + VALKEYMODULE_GET_API(ServerInfoGetFieldSigned); + VALKEYMODULE_GET_API(ServerInfoGetFieldUnsigned); + VALKEYMODULE_GET_API(ServerInfoGetFieldDouble); + VALKEYMODULE_GET_API(GetClientInfoById); + VALKEYMODULE_GET_API(GetClientNameById); + VALKEYMODULE_GET_API(SetClientNameById); + VALKEYMODULE_GET_API(PublishMessage); + VALKEYMODULE_GET_API(PublishMessageShard); + VALKEYMODULE_GET_API(SubscribeToServerEvent); + VALKEYMODULE_GET_API(SetLRU); + VALKEYMODULE_GET_API(GetLRU); + VALKEYMODULE_GET_API(SetLFU); + VALKEYMODULE_GET_API(GetLFU); + VALKEYMODULE_GET_API(BlockClientOnKeys); + VALKEYMODULE_GET_API(BlockClientOnKeysWithFlags); + VALKEYMODULE_GET_API(SignalKeyAsReady); + VALKEYMODULE_GET_API(GetBlockedClientReadyKey); + VALKEYMODULE_GET_API(ScanCursorCreate); + VALKEYMODULE_GET_API(ScanCursorRestart); + VALKEYMODULE_GET_API(ScanCursorDestroy); + VALKEYMODULE_GET_API(Scan); + VALKEYMODULE_GET_API(ScanKey); + VALKEYMODULE_GET_API(GetContextFlagsAll); + VALKEYMODULE_GET_API(GetModuleOptionsAll); + VALKEYMODULE_GET_API(GetKeyspaceNotificationFlagsAll); + VALKEYMODULE_GET_API(IsSubEventSupported); + VALKEYMODULE_GET_API(GetServerVersion); + VALKEYMODULE_GET_API(GetTypeMethodVersion); + VALKEYMODULE_GET_API(Yield); + VALKEYMODULE_GET_API(GetThreadSafeContext); + VALKEYMODULE_GET_API(GetDetachedThreadSafeContext); + VALKEYMODULE_GET_API(FreeThreadSafeContext); + VALKEYMODULE_GET_API(ThreadSafeContextLock); + VALKEYMODULE_GET_API(ThreadSafeContextTryLock); + VALKEYMODULE_GET_API(ThreadSafeContextUnlock); + VALKEYMODULE_GET_API(BlockClient); + VALKEYMODULE_GET_API(BlockClientGetPrivateData); + VALKEYMODULE_GET_API(BlockClientSetPrivateData); + VALKEYMODULE_GET_API(BlockClientOnAuth); + VALKEYMODULE_GET_API(UnblockClient); + VALKEYMODULE_GET_API(IsBlockedReplyRequest); + VALKEYMODULE_GET_API(IsBlockedTimeoutRequest); + VALKEYMODULE_GET_API(GetBlockedClientPrivateData); + VALKEYMODULE_GET_API(GetBlockedClientHandle); + VALKEYMODULE_GET_API(AbortBlock); + VALKEYMODULE_GET_API(BlockedClientMeasureTimeStart); + VALKEYMODULE_GET_API(BlockedClientMeasureTimeEnd); + VALKEYMODULE_GET_API(SetDisconnectCallback); + VALKEYMODULE_GET_API(SubscribeToKeyspaceEvents); + VALKEYMODULE_GET_API(AddPostNotificationJob); + VALKEYMODULE_GET_API(NotifyKeyspaceEvent); + VALKEYMODULE_GET_API(GetNotifyKeyspaceEvents); + VALKEYMODULE_GET_API(BlockedClientDisconnected); + VALKEYMODULE_GET_API(RegisterClusterMessageReceiver); + VALKEYMODULE_GET_API(SendClusterMessage); + VALKEYMODULE_GET_API(GetClusterNodeInfo); + VALKEYMODULE_GET_API(GetClusterNodesList); + VALKEYMODULE_GET_API(FreeClusterNodesList); + VALKEYMODULE_GET_API(CreateTimer); + VALKEYMODULE_GET_API(StopTimer); + VALKEYMODULE_GET_API(GetTimerInfo); + VALKEYMODULE_GET_API(GetMyClusterID); + VALKEYMODULE_GET_API(GetClusterSize); + VALKEYMODULE_GET_API(GetRandomBytes); + VALKEYMODULE_GET_API(GetRandomHexChars); + VALKEYMODULE_GET_API(SetClusterFlags); + VALKEYMODULE_GET_API(ClusterKeySlot); + VALKEYMODULE_GET_API(ClusterCanonicalKeyNameInSlot); + VALKEYMODULE_GET_API(ExportSharedAPI); + VALKEYMODULE_GET_API(GetSharedAPI); + VALKEYMODULE_GET_API(RegisterCommandFilter); + VALKEYMODULE_GET_API(UnregisterCommandFilter); + VALKEYMODULE_GET_API(CommandFilterArgsCount); + VALKEYMODULE_GET_API(CommandFilterArgGet); + VALKEYMODULE_GET_API(CommandFilterArgInsert); + VALKEYMODULE_GET_API(CommandFilterArgReplace); + VALKEYMODULE_GET_API(CommandFilterArgDelete); + VALKEYMODULE_GET_API(CommandFilterGetClientId); + VALKEYMODULE_GET_API(Fork); + VALKEYMODULE_GET_API(SendChildHeartbeat); + VALKEYMODULE_GET_API(ExitFromChild); + VALKEYMODULE_GET_API(KillForkChild); + VALKEYMODULE_GET_API(GetUsedMemoryRatio); + VALKEYMODULE_GET_API(MallocSize); + VALKEYMODULE_GET_API(MallocUsableSize); + VALKEYMODULE_GET_API(MallocSizeString); + VALKEYMODULE_GET_API(MallocSizeDict); + VALKEYMODULE_GET_API(CreateModuleUser); + VALKEYMODULE_GET_API(FreeModuleUser); + VALKEYMODULE_GET_API(SetContextUser); + VALKEYMODULE_GET_API(SetModuleUserACL); + VALKEYMODULE_GET_API(SetModuleUserACLString); + VALKEYMODULE_GET_API(GetModuleUserACLString); + VALKEYMODULE_GET_API(GetCurrentUserName); + VALKEYMODULE_GET_API(GetModuleUserFromUserName); + VALKEYMODULE_GET_API(ACLCheckCommandPermissions); + VALKEYMODULE_GET_API(ACLCheckKeyPermissions); + VALKEYMODULE_GET_API(ACLCheckChannelPermissions); + VALKEYMODULE_GET_API(ACLAddLogEntry); + VALKEYMODULE_GET_API(ACLAddLogEntryByUserName); + VALKEYMODULE_GET_API(DeauthenticateAndCloseClient); + VALKEYMODULE_GET_API(AuthenticateClientWithACLUser); + VALKEYMODULE_GET_API(AuthenticateClientWithUser); + VALKEYMODULE_GET_API(RedactClientCommandArgument); + VALKEYMODULE_GET_API(GetClientCertificate); + VALKEYMODULE_GET_API(GetCommandKeys); + VALKEYMODULE_GET_API(GetCommandKeysWithFlags); + VALKEYMODULE_GET_API(GetCurrentCommandName); + VALKEYMODULE_GET_API(RegisterDefragFunc); + VALKEYMODULE_GET_API(DefragAlloc); + VALKEYMODULE_GET_API(DefragModuleString); + VALKEYMODULE_GET_API(DefragShouldStop); + VALKEYMODULE_GET_API(DefragCursorSet); + VALKEYMODULE_GET_API(DefragCursorGet); + VALKEYMODULE_GET_API(GetKeyNameFromDefragCtx); + VALKEYMODULE_GET_API(GetDbIdFromDefragCtx); + VALKEYMODULE_GET_API(EventLoopAdd); + VALKEYMODULE_GET_API(EventLoopDel); + VALKEYMODULE_GET_API(EventLoopAddOneShot); + VALKEYMODULE_GET_API(RegisterBoolConfig); + VALKEYMODULE_GET_API(RegisterNumericConfig); + VALKEYMODULE_GET_API(RegisterStringConfig); + VALKEYMODULE_GET_API(RegisterEnumConfig); + VALKEYMODULE_GET_API(LoadConfigs); + VALKEYMODULE_GET_API(RdbStreamCreateFromFile); + VALKEYMODULE_GET_API(RdbStreamFree); + VALKEYMODULE_GET_API(RdbLoad); + VALKEYMODULE_GET_API(RdbSave); + + if (ValkeyModule_IsModuleNameBusy && ValkeyModule_IsModuleNameBusy(name)) return VALKEYMODULE_ERR; + ValkeyModule_SetModuleAttribs(ctx,name,ver,apiver); + return VALKEYMODULE_OK; +} + +#define ValkeyModule_Assert(_e) ((_e)?(void)0 : (ValkeyModule__Assert(#_e,__FILE__,__LINE__),exit(1))) + +#define RMAPI_FUNC_SUPPORTED(func) (func != NULL) + +#endif /* VALKEYMODULE_CORE */ +#endif /* VALKEYMODULE_H */ From bc28fb4ac0ba4dc9f97fede94ea7893d8faabce3 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:15:57 -0700 Subject: [PATCH 64/98] Update Server version to valkey version (#232) This commit updates the following fields: 1. server_version -> valkey_version in server info. Since we would like to advertise specific compatibility, we are making the version specific to valkey. servername will remain as an optional indicator, and other valkey compatible stores might choose to advertise something else. 1. We dropped redis-ver from the API. This isn't related to API compatibility, but we didn't want to "fake" that valkey was creating an rdb from a Redis version. 1. Renamed server-ver -> valkey_version in rdb info. Same as point one, we want to explicitly indicate this was created by a valkey server. --------- Signed-off-by: Madelyn Olson --- src/cli_common.c | 2 +- src/config.c | 2 +- src/debug.c | 2 +- src/lolwut.c | 4 ++-- src/lolwut5.c | 2 +- src/lolwut6.c | 2 +- src/mkreleasehdr.sh | 2 +- src/module.c | 2 +- src/networking.c | 2 +- src/rdb.c | 8 +++----- src/script_lua.c | 8 ++++---- src/sentinel.c | 2 +- src/server.c | 8 ++++---- src/version.h | 4 ++-- tests/modules/misc.c | 4 ++-- tests/unit/moduleapi/misc.tcl | 2 +- 16 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/cli_common.c b/src/cli_common.c index c55933418d..b63dd70bfa 100644 --- a/src/cli_common.c +++ b/src/cli_common.c @@ -413,7 +413,7 @@ sds escapeJsonString(sds s, const char *p, size_t len) { } sds cliVersion(void) { - sds version = sdscatprintf(sdsempty(), "%s", SERVER_VERSION); + sds version = sdscatprintf(sdsempty(), "%s", VALKEY_VERSION); /* Add git commit and working tree status when available. */ if (strtoll(serverGitSHA1(),NULL,16)) { diff --git a/src/config.c b/src/config.c index eee7835924..6b7d22969c 100644 --- a/src/config.c +++ b/src/config.c @@ -634,7 +634,7 @@ void loadServerConfigFromString(char *config) { loaderr: if (argv) sdsfreesplitres(argv,argc); - fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", SERVER_VERSION); + fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", VALKEY_VERSION); if (i < totlines) { fprintf(stderr, "Reading the configuration file, at line %d\n", linenum); fprintf(stderr, ">>> '%s'\n", lines[i]); diff --git a/src/debug.c b/src/debug.c index adce284c2b..02133c5c5d 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2252,7 +2252,7 @@ static void sigsegvHandler(int sig, siginfo_t *info, void *secret) { bugReportStart(); serverLog(LL_WARNING, - SERVER_NAME " %s crashed by signal: %d, si_code: %d", SERVER_VERSION, sig, info->si_code); + SERVER_NAME " %s crashed by signal: %d, si_code: %d", VALKEY_VERSION, sig, info->si_code); if (sig == SIGSEGV || sig == SIGBUS) { serverLog(LL_WARNING, "Accessing address: %p", (void*)info->si_addr); diff --git a/src/lolwut.c b/src/lolwut.c index 08c1f58992..eca98cf18e 100644 --- a/src/lolwut.c +++ b/src/lolwut.c @@ -44,7 +44,7 @@ void lolwut6Command(client *c); * This is what unstable versions of Redis will display. */ void lolwutUnstableCommand(client *c) { sds rendered = sdsnew("Redis ver. "); - rendered = sdscat(rendered,SERVER_VERSION); + rendered = sdscat(rendered,VALKEY_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); @@ -52,7 +52,7 @@ void lolwutUnstableCommand(client *c) { /* LOLWUT [VERSION ] [... version specific arguments ...] */ void lolwutCommand(client *c) { - char *v = SERVER_VERSION; + char *v = VALKEY_VERSION; char verstr[64]; if (c->argc >= 3 && !strcasecmp(c->argv[1]->ptr,"version")) { diff --git a/src/lolwut5.c b/src/lolwut5.c index dcc7e7ad90..d293e77d97 100644 --- a/src/lolwut5.c +++ b/src/lolwut5.c @@ -169,7 +169,7 @@ void lolwut5Command(client *c) { sds rendered = renderCanvas(canvas); rendered = sdscat(rendered, "\nGeorg Nees - schotter, plotter on paper, 1968. Redis ver. "); - rendered = sdscat(rendered,SERVER_VERSION); + rendered = sdscat(rendered,VALKEY_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); diff --git a/src/lolwut6.c b/src/lolwut6.c index 38733505a9..440dba9660 100644 --- a/src/lolwut6.c +++ b/src/lolwut6.c @@ -193,7 +193,7 @@ void lolwut6Command(client *c) { rendered = sdscat(rendered, "\nDedicated to the 8 bit game developers of past and present.\n" "Original 8 bit image from Plaguemon by hikikomori. Redis ver. "); - rendered = sdscat(rendered,SERVER_VERSION); + rendered = sdscat(rendered,VALKEY_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); diff --git a/src/mkreleasehdr.sh b/src/mkreleasehdr.sh index b1371fcc09..c8e0b066e4 100755 --- a/src/mkreleasehdr.sh +++ b/src/mkreleasehdr.sh @@ -12,5 +12,5 @@ echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h echo "#include \"version.h\"" >> release.h -echo "#define REDIS_BUILD_ID_RAW SERVER_NAME SERVER_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h +echo "#define REDIS_BUILD_ID_RAW SERVER_NAME VALKEY_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h touch release.c # Force recompile of release.c diff --git a/src/module.c b/src/module.c index 3e48b32836..044d5a6d80 100644 --- a/src/module.c +++ b/src/module.c @@ -13321,7 +13321,7 @@ int VM_GetKeyspaceNotificationFlagsAll(void) { * Example for 6.0.7 the return value will be 0x00060007. */ int VM_GetServerVersion(void) { - return SERVER_VERSION_NUM; + return VALKEY_VERSION_NUM; } /** diff --git a/src/networking.c b/src/networking.c index e8998dc1ad..fdfb9b3fda 100644 --- a/src/networking.c +++ b/src/networking.c @@ -3650,7 +3650,7 @@ void helloCommand(client *c) { addReplyBulkCString(c,"redis"); addReplyBulkCString(c,"version"); - addReplyBulkCString(c,SERVER_VERSION); + addReplyBulkCString(c,VALKEY_VERSION); addReplyBulkCString(c,"proto"); addReplyLongLong(c,c->resp); diff --git a/src/rdb.c b/src/rdb.c index 1c922d31bb..f35a41d8ee 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1195,9 +1195,7 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { int aof_base = (rdbflags & RDBFLAGS_AOF_PREAMBLE) != 0; /* Add a few fields about the state when the RDB was created. */ - if (rdbSaveAuxFieldStrStr(rdb,"server-ver",SERVER_VERSION) == -1) return -1; - /* Print Redis version for backwards compatibility with redis. */ - if (rdbSaveAuxFieldStrStr(rdb,"redis-ver",REDIS_VERSION) == -1) return -1; + if (rdbSaveAuxFieldStrStr(rdb,"valkey-ver",VALKEY_VERSION) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"redis-bits",redis_bits) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"ctime",time(NULL)) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"used-mem",zmalloc_used_memory()) == -1) return -1; @@ -3166,8 +3164,8 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin } else if (!strcasecmp(auxkey->ptr,"redis-ver")) { serverLog(LL_NOTICE,"Loading RDB produced by Redis version %s", (char*)auxval->ptr); - } else if (!strcasecmp(auxkey->ptr,"server-ver")) { - serverLog(LL_NOTICE,"Loading RDB produced by server version %s", + } else if (!strcasecmp(auxkey->ptr,"valkey-ver")) { + serverLog(LL_NOTICE,"Loading RDB produced by valkey version %s", (char*)auxval->ptr); } else if (!strcasecmp(auxkey->ptr,"ctime")) { time_t age = time(NULL)-strtol(auxval->ptr,NULL,10); diff --git a/src/script_lua.c b/src/script_lua.c index fb0739d773..7b9d367d10 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -1393,12 +1393,12 @@ void luaRegisterVersion(lua_State* lua) { lua_settable(lua,-3); /* Now push the Valkey version information. */ - lua_pushstring(lua,"SERVER_VERSION_NUM"); - lua_pushnumber(lua,SERVER_VERSION_NUM); + lua_pushstring(lua,"VALKEY_VERSION_NUM"); + lua_pushnumber(lua,VALKEY_VERSION_NUM); lua_settable(lua,-3); - lua_pushstring(lua,"SERVER_VERSION"); - lua_pushstring(lua,SERVER_VERSION); + lua_pushstring(lua,"VALKEY_VERSION"); + lua_pushstring(lua,VALKEY_VERSION); lua_settable(lua,-3); lua_pushstring(lua,"SERVER_NAME"); diff --git a/src/sentinel.c b/src/sentinel.c index af27ee9c3b..24e8c3ded9 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1846,7 +1846,7 @@ void loadSentinelConfigFromQueue(void) { return; loaderr: - fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", SERVER_VERSION); + fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", VALKEY_VERSION); fprintf(stderr, "Reading the configuration file, at line %d\n", linenum); fprintf(stderr, ">>> '%s'\n", line); fprintf(stderr, "%s\n", err); diff --git a/src/server.c b/src/server.c index c41247e9dc..accb0bdbdb 100644 --- a/src/server.c +++ b/src/server.c @@ -5586,7 +5586,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { info = sdscatfmt(info, "# Server\r\n" FMTARGS( "redis_version:%s\r\n", REDIS_VERSION, "server_name:%s\r\n", SERVER_NAME, - "server_version:%s\r\n", SERVER_VERSION, + "valkey_version:%s\r\n", VALKEY_VERSION, "redis_git_sha1:%s\r\n", serverGitSHA1(), "redis_git_dirty:%i\r\n", strtol(serverGitDirty(),NULL,10) > 0, "redis_build_id:%s\r\n", serverBuildIdString(), @@ -6267,7 +6267,7 @@ void daemonize(void) { sds getVersion(void) { sds version = sdscatprintf(sdsempty(), "v=%s sha=%s:%d malloc=%s bits=%d build=%llx", - SERVER_VERSION, + VALKEY_VERSION, serverGitSHA1(), atoi(serverGitDirty()) > 0, ZMALLOC_LIB, @@ -6321,7 +6321,7 @@ void serverAsciiArt(void) { ); } else { snprintf(buf,1024*16,ascii_logo, - SERVER_VERSION, + VALKEY_VERSION, serverGitSHA1(), strtol(serverGitDirty(),NULL,10) > 0, (sizeof(long) == 8) ? "64" : "32", @@ -7156,7 +7156,7 @@ int main(int argc, char **argv) { serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo"); serverLog(LL_NOTICE, SERVER_NAME " version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", - SERVER_VERSION, + VALKEY_VERSION, (sizeof(long) == 8) ? 64 : 32, serverGitSHA1(), strtol(serverGitDirty(),NULL,10) > 0, diff --git a/src/version.h b/src/version.h index af46071dac..b82be5cbe6 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,6 @@ #define SERVER_NAME "valkey" -#define SERVER_VERSION "255.255.255" -#define SERVER_VERSION_NUM 0x00ffffff +#define VALKEY_VERSION "255.255.255" +#define VALKEY_VERSION_NUM 0x00ffffff /* Redis compatibility version, should never * exceed 7.2.x. */ diff --git a/tests/modules/misc.c b/tests/modules/misc.c index b508e656d6..c062f63a6e 100644 --- a/tests/modules/misc.c +++ b/tests/modules/misc.c @@ -251,7 +251,7 @@ int test_setlfu(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_OK; } -int test_redisversion(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){ +int test_serverversion(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){ (void) argv; (void) argc; @@ -580,7 +580,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_ERR; if (RedisModule_CreateCommand(ctx,"test.setname", test_setname,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"test.redisversion", test_redisversion,"",0,0,0) == REDISMODULE_ERR) + if (RedisModule_CreateCommand(ctx,"test.serverversion", test_serverversion,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; if (RedisModule_CreateCommand(ctx,"test.getclientcert", test_getclientcert,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index ffcf9bd615..da2ca8489c 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -21,7 +21,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { } test {test redis version} { - assert_equal [s server_version] [r test.redisversion] + assert_equal [s valkey_version] [r test.serverversion] } test {test long double conversions} { From 620d325fdc59f4d579fb87e56c2008124abdeb87 Mon Sep 17 00:00:00 2001 From: Parth <661497+parthpatel@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:17:11 -0700 Subject: [PATCH 65/98] Adding server.call/pcall option to LUA scripting. (#136) (#213) This commit does not remove redis.call/pcall just yet. It also does not rename Redis in error messages such as "Please specify at least one argument for this redis lib call". This allows users to maintain full backwards compatibility while introducing an option to use server.call for new code. I verified that the unit tests pass. Also manually verified that the redis-server responds to server.call invocations within lua scripting. Also verified that function registration works as expected. ``` [ok]: EVAL - is Lua able to call Redis API? (0 ms) [ok]: EVAL - is Lua able to call Server API? (1 ms) [ok]: EVAL - No arguments to redis.call/pcall is considered an error (0 ms) [ok]: EVAL - No arguments to server.call/pcall is considered an error (1 ms) ``` --------- Signed-off-by: Parth Patel <661497+parthpatel@users.noreply.github.com> Signed-off-by: Madelyn Olson Co-authored-by: Madelyn Olson --- src/eval.c | 7 ++++++ src/function_lua.c | 5 ++++ src/script_lua.c | 12 ++++++--- src/script_lua.h | 1 + tests/unit/scripting.tcl | 53 +++++++++++++++++++++++++++++++--------- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/src/eval.c b/src/eval.c index 2561322f3d..870224938a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -27,6 +27,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * This file initializes the global LUA object and registers functions to call Valkey API from within the LUA language. + * It heavily invokes LUA's C API documented at https://www.lua.org/pil/24.html. There are 2 entrypoint functions in this file: + * 1. evalCommand() - Gets invoked everytime a user runs LUA script via eval command on Valkey. + * 2. scriptingInit() - initServer() function from server.c invokes this to initialize LUA at startup. + * It is also invoked between 2 eval invocations to reset Lua. + */ #include "server.h" #include "sha1.h" #include "rand.h" diff --git a/src/function_lua.c b/src/function_lua.c index 8b334fcd24..044f40bff3 100644 --- a/src/function_lua.c +++ b/src/function_lua.c @@ -437,6 +437,11 @@ int luaEngineInitEngine(void) { luaRegisterVersion(lua_engine_ctx->lua); luaSetErrorMetatable(lua_engine_ctx->lua); + lua_setfield(lua_engine_ctx->lua, -2, SERVER_API_NAME); + + /* Get the server object and also set it to the Redis API + * compatibility namespace. */ + lua_getfield(lua_engine_ctx->lua, -1, SERVER_API_NAME); lua_setfield(lua_engine_ctx->lua, -2, REDIS_API_NAME); luaSetErrorMetatable(lua_engine_ctx->lua); diff --git a/src/script_lua.c b/src/script_lua.c index 7b9d367d10..fbfc73eb9f 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -57,7 +57,8 @@ static char *libraries_allow_list[] = { /* Redis Lua API globals */ static char *redis_api_allow_list[] = { - "redis", + SERVER_API_NAME, + REDIS_API_NAME, "__redis__err__handler", /* error handler for eval, currently located on globals. Should move to registry. */ NULL, @@ -1504,9 +1505,14 @@ void luaRegisterRedisAPI(lua_State* lua) { lua_pushcfunction(lua,luaRedisAclCheckCmdPermissionsCommand); lua_settable(lua,-3); - /* Finally set the table as 'redis' global var. */ + /* Finally set the table as 'server' global var. + * We will also alias it to 'redis' global var for backwards compatibility. */ + lua_setglobal(lua,SERVER_API_NAME); + /* lua_getglobal invocation retrieves the 'server' variable value to the stack. + * lua_setglobal invocation uses the value from stack to set 'redis' global variable. + * This is not a deep copy but is enough for our purpose here. */ + lua_getglobal(lua,SERVER_API_NAME); lua_setglobal(lua,REDIS_API_NAME); - /* Replace math.random and math.randomseed with our implementations. */ lua_getglobal(lua,"math"); diff --git a/src/script_lua.h b/src/script_lua.h index fc665a1c65..07446725d3 100644 --- a/src/script_lua.h +++ b/src/script_lua.h @@ -57,6 +57,7 @@ #define REGISTRY_RUN_CTX_NAME "__RUN_CTX__" #define REGISTRY_SET_GLOBALS_PROTECTION_NAME "__GLOBAL_PROTECTION__" #define REDIS_API_NAME "redis" +#define SERVER_API_NAME "server" typedef struct errorInfo { sds msg; diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index f494e05db8..feef69122d 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -1,13 +1,38 @@ foreach is_eval {0 1} { +foreach script_compatibility_api {server redis} { + +# We run the tests using both the server APIs, e.g. server.call(), and redis APIs, e.g. redis.call(), +# in order to ensure compatibility. +if {$script_compatibility_api eq "server"} { + proc replace_script_redis_api_with_server {args} { + set new_string [regsub -all {redis\.} [lindex $args 0] {server.}] + return lreplace $args 0 0 $new_string + } + + proc get_script_api_name {} { + return "server" + } +} else { + proc replace_script_redis_api_with_server {args} { + return {*}$args + } + + proc get_script_api_name {} { + return "redis" + } +} if {$is_eval == 1} { proc run_script {args} { + set args [replace_script_redis_api_with_server $args] r eval {*}$args } proc run_script_ro {args} { + set args [replace_script_redis_api_with_server $args] r eval_ro {*}$args } proc run_script_on_connection {args} { + set args [replace_script_redis_api_with_server $args] [lindex $args 0] eval {*}[lrange $args 1 end] } proc kill_script {args} { @@ -15,7 +40,8 @@ if {$is_eval == 1} { } } else { proc run_script {args} { - r function load replace [format "#!lua name=test\nredis.register_function('test', function(KEYS, ARGV)\n %s \nend)" [lindex $args 0]] + set args [replace_script_redis_api_with_server $args] + r function load replace [format "#!lua name=test\n%s.register_function('test', function(KEYS, ARGV)\n %s \nend)" [get_script_api_name] [lindex $args 0]] if {[r readingraw] eq 1} { # read name assert_equal {test} [r read] @@ -23,7 +49,8 @@ if {$is_eval == 1} { r fcall test {*}[lrange $args 1 end] } proc run_script_ro {args} { - r function load replace [format "#!lua name=test\nredis.register_function{function_name='test', callback=function(KEYS, ARGV)\n %s \nend, flags={'no-writes'}}" [lindex $args 0]] + set args [replace_script_redis_api_with_server $args] + r function load replace [format "#!lua name=test\n%s.register_function{function_name='test', callback=function(KEYS, ARGV)\n %s \nend, flags={'no-writes'}}" [get_script_api_name] [lindex $args 0]] if {[r readingraw] eq 1} { # read name assert_equal {test} [r read] @@ -31,8 +58,9 @@ if {$is_eval == 1} { r fcall_ro test {*}[lrange $args 1 end] } proc run_script_on_connection {args} { + set args [replace_script_redis_api_with_server $args] set rd [lindex $args 0] - $rd function load replace [format "#!lua name=test\nredis.register_function('test', function(KEYS, ARGV)\n %s \nend)" [lindex $args 1]] + $rd function load replace [format "#!lua name=test\n%s.register_function('test', function(KEYS, ARGV)\n %s \nend)" [get_script_api_name] [lindex $args 1]] # read name $rd read $rd fcall test {*}[lrange $args 2 end] @@ -44,7 +72,7 @@ if {$is_eval == 1} { start_server {tags {"scripting"}} { - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { test {Script - disallow write on OOM} { r config set maxmemory 1 @@ -113,7 +141,7 @@ start_server {tags {"scripting"}} { run_script {return redis.call('get',KEYS[1])} 1 mykey } {myval} - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { # eval sha is only relevant for is_eval Lua test {EVALSHA - Can we call a SHA1 if already defined?} { r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey @@ -572,7 +600,7 @@ start_server {tags {"scripting"}} { set e } {ERR Write commands are not allowed from read-only scripts*} - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { # script command is only relevant for is_eval Lua test {SCRIPTING FLUSH - is able to clear the scripts cache?} { r set mykey myval @@ -712,7 +740,7 @@ start_server {tags {"scripting"}} { set res } {4 3 2 2 2} - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { # random handling is only relevant for is_eval Lua test {random numbers are random now} { set rand1 [r eval {return tostring(math.random())} 0] @@ -754,7 +782,7 @@ start_server {tags {"scripting"}} { r get x } {10000} - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { test {SPOP: We can call scripts rewriting client->argv from Lua} { set repl [attach_to_replication_stream] #this sadd operation is for external-cluster test. If myset doesn't exist, 'del myset' won't get propagated. @@ -1300,7 +1328,7 @@ start_server {tags {"scripting"}} { } } - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { test "Now use EVALSHA against the master, with both SHAs" { # The server should replicate successful and unsuccessful # commands as EVAL instead of EVALSHA. @@ -1336,7 +1364,7 @@ start_server {tags {"scripting"}} { set res } {a 1} - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { test "EVALSHA replication when first call is readonly" { r del x r eval {if tonumber(ARGV[1]) > 0 then redis.call('incr', KEYS[1]) end} 1 x 0 @@ -1440,7 +1468,7 @@ start_server {tags {"scripting repl external:skip"}} { } test "PRNG is seeded randomly for command replication" { - if {$is_eval eq 1} { + if {$is_eval eq 1 && $script_compatibility_api == "redis"} { # on is_eval Lua we need to call redis.replicate_commands() to get real randomization set a [ run_script { @@ -1485,7 +1513,7 @@ start_server {tags {"scripting repl external:skip"}} { } } -if {$is_eval eq 1} { +if {$is_eval eq 1 && $script_compatibility_api == "redis"} { start_server {tags {"scripting external:skip"}} { r script debug sync r eval {return 'hello'} 0 @@ -1876,6 +1904,7 @@ start_server {tags {"scripting needs:debug"}} { r debug set-disable-deny-scripts 0 } } ;# foreach is_eval +} ;# foreach script_compatibility_api # Scripting "shebang" notation tests From ba0c93cbdf81ba588b43e4af85127a342770ad6d Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Sun, 7 Apr 2024 00:41:53 +0800 Subject: [PATCH 66/98] Add redis symlinks at the same place as the installed binaries (#193) Adds a new make variable called `USE_REDIS_SYMLINKS`, with default value `yes`. If yes, then `make install` creates additional symlinks to the installed binaries: * `valkey-server` * `valkey-cli` * `valkey-benchmark` * `valkey-check-rdb` * `valkey-check-aof` * `valkey-sentinel` The names of the symlinks are the legacy redis binary names (`redis-server`, etc.). The purpose is to provide backward compatibility for scripts expecting the these filenames. The symlinks are installed in the same directory as the binaries (typically `/usr/local/bin/` or similar). Similarly, `make uninstall` removes these symlinks if `USE_REDIS_SYMLINKS` is `yes`. This is described in a note in README.md. Fixes #147 --------- Signed-off-by: Vitah Lin Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com> --- README.md | 5 +++++ src/Makefile | 37 ++++++++++++++++++++++++++++++++++++- src/server.c | 10 ++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7da887f2b3..67b65473e1 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,11 @@ In order to install Valkey binaries into /usr/local/bin, just use: You can use `make PREFIX=/some/other/directory install` if you wish to use a different destination. +_Note_: For compatibility with Redis, we create symlinks from the Redis names (`redis-server`, `redis-cli`, etc.) to the Valkey binaries installed by `make install`. +The symlinks are created in same directory as the Valkey binaries. +The symlinks are removed when using `make uninstall`. +The creation of the symlinks can be skipped by setting the makefile variable `USE_REDIS_SYMLINKS=no`. + `make install` will just install binaries in your system, but will not configure init scripts and configuration files in the appropriate place. This is not needed if you just want to play a bit with Valkey, but if you are installing diff --git a/src/Makefile b/src/Makefile index 0c70e8a22d..25ceae9a91 100644 --- a/src/Makefile +++ b/src/Makefile @@ -325,10 +325,33 @@ ifndef V @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2 @$(INSTALL) $(1) $(2) endef + + define INSTALL_REDIS_SYMLINK + @printf ' %b %b %b %b %b %b %b\n' \ + $(LINKCOLOR)INSTALL SYMLINK$(ENDCOLOR) \ + $(BINCOLOR)$(subst $(ENGINE_NAME),redis,$(1))$(ENDCOLOR) -\> $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2 + @ln -sf $(1) $(2)/$(subst $(ENGINE_NAME),redis,$(1)) + endef else define MAKE_INSTALL $(INSTALL) $(1) $(2) endef + + define INSTALL_REDIS_SYMLINK + ln -sf $(1) $(2)/$(subst $(ENGINE_NAME),redis,$(1)) + endef +endif + +# Determine install/unstall Redis symlinks for compatibility when +# installing/uninstalling Valkey binaries (defaulting to `yes`) +USE_REDIS_SYMLINKS?=yes +ifeq ($(USE_REDIS_SYMLINKS),yes) + MAYBE_INSTALL_REDIS_SYMLINK=$(INSTALL_REDIS_SYMLINK) + MAYBE_UNINSTALL_REDIS_SYMLINK=@rm -f $(1)/$(subst $(ENGINE_NAME),redis,$(2)) + FINAL_CFLAGS+= -DUSE_REDIS_SYMLINKS +else + MAYBE_INSTALL_REDIS_SYMLINK= + MAYBE_UNINSTALL_REDIS_SYMLINK= endif SERVER_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) @@ -529,6 +552,18 @@ install: all @ln -sf $(SERVER_NAME) $(INSTALL_BIN)/$(ENGINE_CHECK_RDB_NAME) @ln -sf $(SERVER_NAME) $(INSTALL_BIN)/$(ENGINE_CHECK_AOF_NAME) @ln -sf $(SERVER_NAME) $(INSTALL_BIN)/$(ENGINE_SENTINEL_NAME) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(SERVER_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_CLI_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_BENCHMARK_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_CHECK_RDB_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_CHECK_AOF_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_SENTINEL_NAME),$(INSTALL_BIN)) uninstall: - rm -f $(INSTALL_BIN)/{$(SERVER_NAME),$(ENGINE_BENCHMARK_NAME),$(ENGINE_CLI_NAME),$(ENGINE_CHECK_RDB_NAME),$(ENGINE_CHECK_AOF_NAME),$(ENGINE_SENTINEL_NAME)} + @rm -f $(INSTALL_BIN)/{$(SERVER_NAME),$(ENGINE_BENCHMARK_NAME),$(ENGINE_CLI_NAME),$(ENGINE_CHECK_RDB_NAME),$(ENGINE_CHECK_AOF_NAME),$(ENGINE_SENTINEL_NAME)} + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(SERVER_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CLI_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_BENCHMARK_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CHECK_RDB_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CHECK_AOF_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_SENTINEL_NAME)) \ No newline at end of file diff --git a/src/server.c b/src/server.c index accb0bdbdb..aa459994bb 100644 --- a/src/server.c +++ b/src/server.c @@ -7001,6 +7001,16 @@ int main(int argc, char **argv) { redis_check_rdb_main(argc,argv,NULL); else if (strstr(exec_name,"valkey-check-aof") != NULL) redis_check_aof_main(argc,argv); + + /* If enable USE_REDIS_SYMLINKS, valkey may install symlinks like + * redis-server -> valkey-server, redis-check-rdb -> valkey-check-rdb, + * redis-check-aof -> valkey-check-aof, etc. */ +#ifdef USE_REDIS_SYMLINKS + if (strstr(exec_name,"redis-check-rdb") != NULL) + redis_check_rdb_main(argc, argv, NULL); + else if (strstr(exec_name,"redis-check-aof") != NULL) + redis_check_aof_main(argc,argv); +#endif if (argc >= 2) { j = 1; /* First option to parse in argv[] */ From 717ec1e1440d94ef1ebe064addaffc4970d88c29 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Sun, 7 Apr 2024 03:50:56 +0700 Subject: [PATCH 67/98] Rename ValkeyModule_DefragModuleString to ValkeyModule_DefragValkeyModuleString (#243) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes: #242 --------- Signed-off-by: 0del Co-authored-by: Viktor Söderqvist --- src/module.c | 4 ++-- src/redismodule.h | 2 +- src/valkeymodule.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/module.c b/src/module.c index 044d5a6d80..ec8e605d54 100644 --- a/src/module.c +++ b/src/module.c @@ -13556,7 +13556,7 @@ void *VM_DefragAlloc(ValkeyModuleDefragCtx *ctx, void *ptr) { * by the module, will end up with a single reference (because the reference * on the Redis side is dropped as soon as the command callback returns). */ -ValkeyModuleString *VM_DefragModuleString(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) { +ValkeyModuleString *VM_DefragValkeyModuleString(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) { UNUSED(ctx); return activeDefragStringOb(str); } @@ -13998,7 +13998,7 @@ void moduleRegisterCoreAPI(void) { REGISTER_API(GetTypeMethodVersion); REGISTER_API(RegisterDefragFunc); REGISTER_API(DefragAlloc); - REGISTER_API(DefragModuleString); + REGISTER_API(DefragValkeyModuleString); REGISTER_API(DefragShouldStop); REGISTER_API(DefragCursorSet); REGISTER_API(DefragCursorGet); diff --git a/src/redismodule.h b/src/redismodule.h index f9ecaf5868..309ab312d3 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -680,7 +680,7 @@ #define RedisModule_GetCurrentCommandName ValkeyModule_GetCurrentCommandName #define RedisModule_RegisterDefragFunc ValkeyModule_RegisterDefragFunc #define RedisModule_DefragAlloc ValkeyModule_DefragAlloc -#define RedisModule_DefragRedisModuleString ValkeyModule_DefragModuleString +#define RedisModule_DefragRedisModuleString ValkeyModule_DefragValkeyModuleString #define RedisModule_DefragShouldStop ValkeyModule_DefragShouldStop #define RedisModule_DefragCursorSet ValkeyModule_DefragCursorSet #define RedisModule_DefragCursorGet ValkeyModule_DefragCursorGet diff --git a/src/valkeymodule.h b/src/valkeymodule.h index 3df3e733a1..104d0923d1 100644 --- a/src/valkeymodule.h +++ b/src/valkeymodule.h @@ -4,7 +4,7 @@ * This header file is forked from redismodule.h to reflect the new naming conventions adopted in Valkey. * * Key Changes: - * - Symbolic names have been changed from VALKEYMODULE_* to VALKEYMODULE_* to align with the + * - Symbolic names have been changed from containing RedisModule, REDISMODULE, etc. to ValkeyModule, VALKEYMODULE, etc. to align with the * new module naming convention. Developers must use these new symbolic names in their module * implementations. * - Terminology has been updated to be more inclusive: "slave" is now "replica", and "master" @@ -1300,7 +1300,7 @@ VALKEYMODULE_API int *(*ValkeyModule_GetCommandKeysWithFlags)(ValkeyModuleCtx *c VALKEYMODULE_API const char *(*ValkeyModule_GetCurrentCommandName)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; VALKEYMODULE_API int (*ValkeyModule_RegisterDefragFunc)(ValkeyModuleCtx *ctx, ValkeyModuleDefragFunc func) VALKEYMODULE_ATTR; VALKEYMODULE_API void *(*ValkeyModule_DefragAlloc)(ValkeyModuleDefragCtx *ctx, void *ptr) VALKEYMODULE_ATTR; -VALKEYMODULE_API ValkeyModuleString *(*ValkeyModule_DefragModuleString)(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString *(*ValkeyModule_DefragValkeyModuleString)(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; VALKEYMODULE_API int (*ValkeyModule_DefragShouldStop)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; VALKEYMODULE_API int (*ValkeyModule_DefragCursorSet)(ValkeyModuleDefragCtx *ctx, unsigned long cursor) VALKEYMODULE_ATTR; VALKEYMODULE_API int (*ValkeyModule_DefragCursorGet)(ValkeyModuleDefragCtx *ctx, unsigned long *cursor) VALKEYMODULE_ATTR; @@ -1666,7 +1666,7 @@ static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, in VALKEYMODULE_GET_API(GetCurrentCommandName); VALKEYMODULE_GET_API(RegisterDefragFunc); VALKEYMODULE_GET_API(DefragAlloc); - VALKEYMODULE_GET_API(DefragModuleString); + VALKEYMODULE_GET_API(DefragValkeyModuleString); VALKEYMODULE_GET_API(DefragShouldStop); VALKEYMODULE_GET_API(DefragCursorSet); VALKEYMODULE_GET_API(DefragCursorGet); From 9f03dfc1f637aef983118ada00ca3cd5c9829402 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:07:51 -0700 Subject: [PATCH 68/98] Fix two typos that were flagged in the 7.2 build (#248) These were flagged on the 7.2 build system, which is using the old spell check. I think we should consider re-adding it as it missed some typos. Relevant: https://github.com/valkey-io/valkey/pull/72 Signed-off-by: Madelyn Olson --- src/Makefile | 2 +- src/eval.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 25ceae9a91..ad22fd8fad 100644 --- a/src/Makefile +++ b/src/Makefile @@ -342,7 +342,7 @@ else endef endif -# Determine install/unstall Redis symlinks for compatibility when +# Determine install/uninstall Redis symlinks for compatibility when # installing/uninstalling Valkey binaries (defaulting to `yes`) USE_REDIS_SYMLINKS?=yes ifeq ($(USE_REDIS_SYMLINKS),yes) diff --git a/src/eval.c b/src/eval.c index 870224938a..6542246803 100644 --- a/src/eval.c +++ b/src/eval.c @@ -30,7 +30,7 @@ /* * This file initializes the global LUA object and registers functions to call Valkey API from within the LUA language. * It heavily invokes LUA's C API documented at https://www.lua.org/pil/24.html. There are 2 entrypoint functions in this file: - * 1. evalCommand() - Gets invoked everytime a user runs LUA script via eval command on Valkey. + * 1. evalCommand() - Gets invoked every time a user runs LUA script via eval command on Valkey. * 2. scriptingInit() - initServer() function from server.c invokes this to initialize LUA at startup. * It is also invoked between 2 eval invocations to reset Lua. */ From 1b47daff095840c5c9f8b308148ce3143a2110fb Mon Sep 17 00:00:00 2001 From: Arpit Pandey Date: Mon, 8 Apr 2024 03:19:14 +0530 Subject: [PATCH 69/98] Fix: Typo clock_getting -> clock_gettime (#244) typo in comment monotonic.c file:- Changed: faster than calling 'clock_getting' (POSIX) To: faster than calling 'clock_gettime' (POSIX) Signed-off-by: Arpit Pandey --- src/monotonic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monotonic.c b/src/monotonic.c index e55b5eb0c0..a78d9d5f9e 100644 --- a/src/monotonic.c +++ b/src/monotonic.c @@ -13,7 +13,7 @@ static char monotonic_info_string[32]; /* Using the processor clock (aka TSC on x86) can provide improved performance * throughout Redis wherever the monotonic clock is used. The processor clock - * is significantly faster than calling 'clock_getting' (POSIX). While this is + * is significantly faster than calling 'clock_gettime' (POSIX). While this is * generally safe on modern systems, this link provides additional information * about use of the x86 TSC: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage * From d26d596b3e44f344fe4ea0da9e5154c15d6632dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Mon, 8 Apr 2024 02:28:02 +0200 Subject: [PATCH 70/98] Log branding (#252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Small changes to the log messages printed during startup and shutdown, for Valkey branding. SERVER_NAME is replaced by verbatim "Valkey" in one place, because SERVER_NAME expands to "valkey" in lowercase. (Should we introduce another macro that expands to "Valkey"?) Signed-off-by: Viktor Söderqvist --- src/server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server.c b/src/server.c index aa459994bb..756039a071 100644 --- a/src/server.c +++ b/src/server.c @@ -4526,7 +4526,7 @@ int finishShutdown(void) { serverLog(LL_WARNING,"%s is now ready to exit, bye bye...", - server.sentinel_mode ? "Sentinel" : "Redis"); + server.sentinel_mode ? "Sentinel" : "Valkey"); return C_OK; error: @@ -7164,8 +7164,8 @@ int main(int argc, char **argv) { int background = server.daemonize && !server.supervised; if (background) daemonize(); - serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo"); - serverLog(LL_NOTICE, SERVER_NAME " version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", + serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo"); + serverLog(LL_NOTICE, "Valkey version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", VALKEY_VERSION, (sizeof(long) == 8) ? 64 : 32, serverGitSHA1(), @@ -7173,7 +7173,7 @@ int main(int argc, char **argv) { (int)getpid()); if (argc == 1) { - serverLog(LL_WARNING, "Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/redis.conf", argv[0]); + serverLog(LL_WARNING, "Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/valkey.conf", argv[0]); } else { serverLog(LL_NOTICE, "Configuration loaded"); } From 6411629c617e3e8800fb083938bd9883a3a9db33 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Sun, 7 Apr 2024 17:30:38 -0700 Subject: [PATCH 71/98] Madelyn's attempt as a logo (#251) Apply new logo at startup. It is one character wider and 2 characters taller than the original Redis logo. --------- Signed-off-by: Madelyn Olson --- src/asciilogo.h | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/asciilogo.h b/src/asciilogo.h index b291ca76bb..d41f8a4c74 100644 --- a/src/asciilogo.h +++ b/src/asciilogo.h @@ -28,20 +28,22 @@ */ const char *ascii_logo = -" ___ ___ \n" -" ( ) ( ) \n" -" ___ ___ .---. | | | | ___ .--. ___ ___ \n" -"( )( ) / .-, \\ | | | | ( ) / \\ ( )( ) Valkey %s (%s/%d) %s bit \n" -" | | | | (__) ; | | | | | ' / | .-. ; | | | | \n" -" | | | | .'` | | | | |,' / | | | | | | | | Running in %s mode \n" -" | | | | / .'| | | | | . '. | |/ | | ' | | Port: %d \n" -" | | | | | / | | | | | | `. \\ | ' _.' ' `-' | PID: %ld \n" -" ' ' ; ' ; | ; | | | | | \\ \\ | .'.-. `.__. | \n" -" \\ `' / ' `-' | | | | | \\ . ' `-' / ___ | | \n" -" \\__/ `.__.'_. (___) (___ ) (___) `.__.' ( )' | https://valkey.io\n" -" ; `-' ' \n" -" .__.' \n" -" \n" -" \n\n"; - - +" .+^+. \n" +" .+#########+. \n" +" .+########+########+. Valkey %s (%s/%d) %s bit\n" +" .+########+' '+########+. \n" +" .########+' .+. '+########. Running in %s mode\n" +" |####+' .+#######+. '+####| Port: %d\n" +" |###| .+###############+. |###| PID: %ld \n" +" |###| |#####*'' ''*#####| |###| \n" +" |###| |####' .-. '####| |###| \n" +" |###| |###( (@@@) )###| |###| https://valkey.io \n" +" |###| |####. '-' .####| |###| \n" +" |###| |#####*. .*#####| |###| \n" +" |###| '+#####| |#####+' |###| \n" +" |####+. +##| |#+' .+####| \n" +" '#######+ |##| .+########' \n" +" '+###| |##| .+########+' \n" +" '| |####+########+' \n" +" +#########+' \n" +" '+v+' \n\n"; From d92dc78cb8116d9afa816a978094d98879f69065 Mon Sep 17 00:00:00 2001 From: Bany <53461381+0del@users.noreply.github.com> Date: Mon, 8 Apr 2024 22:56:39 +0700 Subject: [PATCH 72/98] Update ValkeyModuleEvent_MasterLinkChange to ValkeyModuleEvent_PrimaryLinkChange (#262) Update ValkeyModuleEvent_MasterLinkChange to ValkeyModuleEvent_PrimaryLinkChange Signed-off-by: 0del --- src/module.c | 2 +- src/redismodule.h | 2 +- src/valkeymodule.h | 2 +- tests/modules/hooks.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/module.c b/src/module.c index ec8e605d54..281b1ee903 100644 --- a/src/module.c +++ b/src/module.c @@ -11511,7 +11511,7 @@ static uint64_t moduleEventVersions[] = { * * int32_t hz; // Approximate number of events per second. * - * * ValkeyModuleEvent_MasterLinkChange + * * ValkeyModuleEvent_PrimaryLinkChange * * This is called for replicas in order to notify when the * replication link becomes functional (up) with our master, diff --git a/src/redismodule.h b/src/redismodule.h index 309ab312d3..9c3d06d69d 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -712,7 +712,7 @@ #define RedisModuleEvent_Shutdown ValkeyModuleEvent_Shutdown #define RedisModuleEvent_ReplicaChange ValkeyModuleEvent_ReplicaChange #define RedisModuleEvent_CronLoop ValkeyModuleEvent_CronLoop -#define RedisModuleEvent_MasterLinkChange ValkeyModuleEvent_MasterLinkChange +#define RedisModuleEvent_PrimaryLinkChange ValkeyModuleEvent_PrimaryLinkChange #define RedisModuleEvent_ModuleChange ValkeyModuleEvent_ModuleChange #define RedisModuleEvent_LoadingProgress ValkeyModuleEvent_LoadingProgress #define RedisModuleEvent_SwapDB ValkeyModuleEvent_SwapDB diff --git a/src/valkeymodule.h b/src/valkeymodule.h index 104d0923d1..18ee75415a 100644 --- a/src/valkeymodule.h +++ b/src/valkeymodule.h @@ -583,7 +583,7 @@ static const ValkeyModuleEvent VALKEYMODULE_EVENT_CRON_LOOP, 1 }, - ValkeyModuleEvent_MasterLinkChange = { + ValkeyModuleEvent_PrimaryLinkChange = { VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, 1 }, diff --git a/tests/modules/hooks.c b/tests/modules/hooks.c index fc357d1445..e91dd9bb51 100644 --- a/tests/modules/hooks.c +++ b/tests/modules/hooks.c @@ -422,7 +422,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_ReplicaChange, replicationChangeCallback); RedisModule_SubscribeToServerEvent(ctx, - RedisModuleEvent_MasterLinkChange, rasterLinkChangeCallback); + RedisModuleEvent_PrimaryLinkChange, rasterLinkChangeCallback); /* persistence related hooks */ RedisModule_SubscribeToServerEvent(ctx, From ebfb44062982d29fc031e20c916be68c127f5ddc Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Mon, 8 Apr 2024 09:01:30 -0700 Subject: [PATCH 73/98] Pass extensions to node if extension processing is handled by it (#52) Ref: https://github.com/redis/redis/pull/12760 ### Description #### Fixes compatibilty of PlaceholderKV cluster (7.2 - extensions enabled by default) with older Redis cluster (< 7.0 - extensions not handled) . With some of the extensions enabled by default in 7.2 version, new nodes running 7.2 and above start sending out larger clusterbus message payload including the ping extensions. This caused an incompatibility with node running engine versions < 7.0. Old nodes (< 7.0) would receive the payload from new nodes (> 7.2) would observe a payload length (totlen) > (estlen) and would perform an early exit and won't process the message. This fix introduces a flag `extensions_supported` on the clusterMsg indicating the sender node can handle extensions parsing. Once, a receiver nodes receives a message with this flag set to 1, it would update clusterNode new field extensions_supported and start sending out extensions if it has any. This PR also introduces a DEBUG sub command to enable/disable cluster message extensions `process-clustermsg-extensions` feature. Note: A successful `PING`/`PONG` is required as a sender for a given node to be marked as `extensions_supported` and then extensions message will be sent to it. This could cause a slight delay in receiving the extensions message(s). ### Testing TCL test verifying the cluster state is healthy irrespective of enabling/disabling cluster message extensions feature. --------- Signed-off-by: Harkrishn Patro --- src/cluster_legacy.c | 20 +++++++++++++----- src/cluster_legacy.h | 2 ++ tests/unit/cluster/hostnames.tcl | 35 ++++++++++++++++++++++---------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 5874433d7d..2e93eda9cd 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -2598,9 +2598,7 @@ uint32_t writePingExt(clusterMsg *hdr, int gossipcount) { extensions++; if (hdr != NULL) { - if (extensions != 0) { - hdr->mflags[0] |= CLUSTERMSG_FLAG0_EXT_DATA; - } + hdr->mflags[0] |= CLUSTERMSG_FLAG0_EXT_DATA; hdr->extensions = htons(extensions); } @@ -2791,6 +2789,10 @@ int clusterProcessPacket(clusterLink *link) { sender = getNodeFromLinkAndMsg(link, hdr); + if (sender && (hdr->mflags[0] & CLUSTERMSG_FLAG0_EXT_DATA)) { + sender->flags |= CLUSTER_NODE_EXTENSIONS_SUPPORTED; + } + /* Update the last time we saw any data from this node. We * use this in order to avoid detecting a timeout from a node that * is just sending a lot of data in the cluster bus, for instance @@ -3633,7 +3635,9 @@ void clusterSendPing(clusterLink *link, int type) { * to put inside the packet. */ estlen = sizeof(clusterMsg) - sizeof(union clusterMsgData); estlen += (sizeof(clusterMsgDataGossip)*(wanted + pfail_wanted)); - estlen += writePingExt(NULL, 0); + if (link->node && nodeSupportsExtensions(link->node)) { + estlen += writePingExt(NULL, 0); + } /* Note: clusterBuildMessageHdr() expects the buffer to be always at least * sizeof(clusterMsg) or more. */ if (estlen < (int)sizeof(clusterMsg)) estlen = sizeof(clusterMsg); @@ -3703,7 +3707,13 @@ void clusterSendPing(clusterLink *link, int type) { /* Compute the actual total length and send! */ uint32_t totlen = 0; - totlen += writePingExt(hdr, gossipcount); + + if (link->node && nodeSupportsExtensions(link->node)) { + totlen += writePingExt(hdr, gossipcount); + } else { + serverLog(LL_DEBUG, "Unable to send extensions data, however setting ext data flag to true"); + hdr->mflags[0] |= CLUSTERMSG_FLAG0_EXT_DATA; + } totlen += sizeof(clusterMsg)-sizeof(union clusterMsgData); totlen += (sizeof(clusterMsgDataGossip)*gossipcount); serverAssert(gossipcount < USHRT_MAX); diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index a857184ab3..fc2ba80d19 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -51,6 +51,7 @@ typedef struct clusterLink { #define CLUSTER_NODE_MEET 128 /* Send a MEET message to this node */ #define CLUSTER_NODE_MIGRATE_TO 256 /* Master eligible for replica migration. */ #define CLUSTER_NODE_NOFAILOVER 512 /* Slave will not try to failover. */ +#define CLUSTER_NODE_EXTENSIONS_SUPPORTED 1024 /* This node supports extensions. */ #define CLUSTER_NODE_NULL_NAME "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" #define nodeIsSlave(n) ((n)->flags & CLUSTER_NODE_SLAVE) @@ -59,6 +60,7 @@ typedef struct clusterLink { #define nodeTimedOut(n) ((n)->flags & CLUSTER_NODE_PFAIL) #define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL) #define nodeCantFailover(n) ((n)->flags & CLUSTER_NODE_NOFAILOVER) +#define nodeSupportsExtensions(n) ((n)->flags & CLUSTER_NODE_EXTENSIONS_SUPPORTED) /* This structure represent elements of node->fail_reports. */ typedef struct clusterNodeFailReport { diff --git a/tests/unit/cluster/hostnames.tcl b/tests/unit/cluster/hostnames.tcl index f318240626..f08c9cfa84 100644 --- a/tests/unit/cluster/hostnames.tcl +++ b/tests/unit/cluster/hostnames.tcl @@ -116,10 +116,11 @@ test "Verify the nodes configured with prefer hostname only show hostname for ne # Have everyone forget node 6 and isolate it from the cluster. isolate_node 6 - # Set hostnames for the masters, now that the node is isolated - R 0 config set cluster-announce-hostname "shard-1.com" - R 1 config set cluster-announce-hostname "shard-2.com" - R 2 config set cluster-announce-hostname "shard-3.com" + set primaries 3 + for {set j 0} {$j < $primaries} {incr j} { + # Set hostnames for the masters, now that the node is isolated + R $j config set cluster-announce-hostname "shard-$j.com" + } # Prevent Node 0 and Node 6 from properly meeting, # they'll hang in the handshake phase. This allows us to @@ -149,9 +150,17 @@ test "Verify the nodes configured with prefer hostname only show hostname for ne } else { fail "Node did not learn about the 2 shards it can talk to" } - set slot_result [R 6 CLUSTER SLOTS] - assert_equal [lindex [get_slot_field $slot_result 0 2 3] 1] "shard-2.com" - assert_equal [lindex [get_slot_field $slot_result 1 2 3] 1] "shard-3.com" + wait_for_condition 50 100 { + [lindex [get_slot_field [R 6 CLUSTER SLOTS] 0 2 3] 1] eq "shard-1.com" + } else { + fail "hostname for shard-1 didn't reach node 6" + } + + wait_for_condition 50 100 { + [lindex [get_slot_field [R 6 CLUSTER SLOTS] 1 2 3] 1] eq "shard-2.com" + } else { + fail "hostname for shard-2 didn't reach node 6" + } # Also make sure we know about the isolated master, we # just can't reach it. @@ -170,10 +179,14 @@ test "Verify the nodes configured with prefer hostname only show hostname for ne } else { fail "Node did not learn about the 2 shards it can talk to" } - set slot_result [R 6 CLUSTER SLOTS] - assert_equal [lindex [get_slot_field $slot_result 0 2 3] 1] "shard-1.com" - assert_equal [lindex [get_slot_field $slot_result 1 2 3] 1] "shard-2.com" - assert_equal [lindex [get_slot_field $slot_result 2 2 3] 1] "shard-3.com" + + for {set j 0} {$j < $primaries} {incr j} { + wait_for_condition 50 100 { + [lindex [get_slot_field [R 6 CLUSTER SLOTS] $j 2 3] 1] eq "shard-$j.com" + } else { + fail "hostname information for shard-$j didn't reach node 6" + } + } } test "Test restart will keep hostname information" { From 750e94cad342f3a8b58ed9660891059ec928f159 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:09:27 -0700 Subject: [PATCH 74/98] Update crash wording to include our repo (#263) Update the wording in the crash log to point to Valkey repo instead of Redis repo. Signed-off-by: Madelyn Olson --- src/debug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/debug.c b/src/debug.c index 02133c5c5d..b688ac898f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2382,10 +2382,10 @@ void bugReportEnd(int killViaSignal, int sig) { serverLogRawFromHandler(LL_WARNING|LL_RAW, "\n=== REDIS BUG REPORT END. Make sure to include from START to END. ===\n\n" " Please report the crash by opening an issue on github:\n\n" -" http://github.com/redis/redis/issues\n\n" -" If a Redis module was involved, please open in the module's repo instead.\n\n" -" Suspect RAM error? Use redis-server --test-memory to verify it.\n\n" -" Some other issues could be detected by redis-server --check-system\n" +" http://github.com/valkey-io/valkey/issues\n\n" +" If a module was involved, please open in the module's repo instead.\n\n" +" Suspect RAM error? Use valkey-server --test-memory to verify it.\n\n" +" Some other issues could be detected by valkey-server --check-system\n" ); /* free(messages); Don't call free() with possibly corrupted memory. */ From 5bccd7b8003c6d3eb4c429bb91e6a5ca4b1a654e Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Mon, 8 Apr 2024 14:37:56 -0400 Subject: [PATCH 75/98] Rename systemd files and content to valkey from redis (#234) Changed systemd file names and content of them to valkey. Signed-off-by: Shivshankar-Reddy --- utils/systemd-redis_multiple_servers@.service | 37 ------------------- .../systemd-valkey_multiple_servers@.service | 37 +++++++++++++++++++ ....service => systemd-valkey_server.service} | 22 +++++------ 3 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 utils/systemd-redis_multiple_servers@.service create mode 100644 utils/systemd-valkey_multiple_servers@.service rename utils/{systemd-redis_server.service => systemd-valkey_server.service} (65%) diff --git a/utils/systemd-redis_multiple_servers@.service b/utils/systemd-redis_multiple_servers@.service deleted file mode 100644 index 108ccfc64b..0000000000 --- a/utils/systemd-redis_multiple_servers@.service +++ /dev/null @@ -1,37 +0,0 @@ -# example systemd template service unit file for multiple redis-servers -# -# You can use this file as a blueprint for your actual template service unit -# file, if you intend to run multiple independent redis-server instances in -# parallel using systemd's "template unit files" feature. If you do, you will -# want to choose a better basename for your service unit by renaming this file -# when copying it. -# -# Please take a look at the provided "systemd-redis_server.service" example -# service unit file, too, if you choose to use this approach at managing -# multiple redis-server instances via systemd. - -[Unit] -Description=Redis data structure server - instance %i -Documentation=https://redis.io/documentation -# This template unit assumes your redis-server configuration file(s) -# to live at /etc/redis/redis_server_.conf -AssertPathExists=/etc/redis/redis_server_%i.conf -#Before=your_application.service another_example_application.service -#AssertPathExists=/var/lib/redis - -[Service] -ExecStart=/usr/local/bin/redis-server /etc/redis/redis_server_%i.conf -LimitNOFILE=10032 -NoNewPrivileges=yes -#OOMScoreAdjust=-900 -#PrivateTmp=yes -Type=notify -TimeoutStartSec=infinity -TimeoutStopSec=infinity -UMask=0077 -#User=redis -#Group=redis -#WorkingDirectory=/var/lib/redis - -[Install] -WantedBy=multi-user.target diff --git a/utils/systemd-valkey_multiple_servers@.service b/utils/systemd-valkey_multiple_servers@.service new file mode 100644 index 0000000000..2d6f4e8982 --- /dev/null +++ b/utils/systemd-valkey_multiple_servers@.service @@ -0,0 +1,37 @@ +# example systemd template service unit file for multiple valkey-servers +# +# You can use this file as a blueprint for your actual template service unit +# file, if you intend to run multiple independent valkey-server instances in +# parallel using systemd's "template unit files" feature. If you do, you will +# want to choose a better basename for your service unit by renaming this file +# when copying it. +# +# Please take a look at the provided "systemd-valkey_server.service" example +# service unit file, too, if you choose to use this approach at managing +# multiple valkey-server instances via systemd. + +[Unit] +Description=Valkey data structure server - instance %i +Documentation=https://github.com/valkey-io/valkey-doc +# This template unit assumes your valkey-server configuration file(s) +# to live at /etc/valkey/valkey_server_.conf +AssertPathExists=/etc/valkey/valkey_server_%i.conf +#Before=your_application.service another_example_application.service +#AssertPathExists=/var/lib/valkey + +[Service] +ExecStart=/usr/local/bin/valkey-server /etc/valkey/valkey_server_%i.conf +LimitNOFILE=10032 +NoNewPrivileges=yes +#OOMScoreAdjust=-900 +#PrivateTmp=yes +Type=notify +TimeoutStartSec=infinity +TimeoutStopSec=infinity +UMask=0077 +#User=valkey +#Group=valkey +#WorkingDirectory=/var/lib/valkey + +[Install] +WantedBy=multi-user.target diff --git a/utils/systemd-redis_server.service b/utils/systemd-valkey_server.service similarity index 65% rename from utils/systemd-redis_server.service rename to utils/systemd-valkey_server.service index 15400b439e..0842105186 100644 --- a/utils/systemd-redis_server.service +++ b/utils/systemd-valkey_server.service @@ -1,13 +1,13 @@ -# example systemd service unit file for redis-server +# example systemd service unit file for valkey-server # -# In order to use this as a template for providing a redis service in your -# environment, _at the very least_ make sure to adapt the redis configuration +# In order to use this as a template for providing a valkey service in your +# environment, _at the very least_ make sure to adapt the valkey configuration # file you intend to use as needed (make sure to set "supervised systemd"), and # to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's # "[Service]" section to fit your needs. # # Some properties, such as User= and Group=, are highly desirable for virtually -# all deployments of redis, but cannot be provided in a manner that fits all +# all deployments of valkey, but cannot be provided in a manner that fits all # expectable environments. Some of these properties have been commented out in # this example service unit file, but you are highly encouraged to set them to # fit your needs. @@ -16,16 +16,16 @@ # more information. [Unit] -Description=Redis data structure server -Documentation=https://redis.io/documentation +Description=Valkey data structure server +Documentation=https://github.com/valkey-io/valkey-doc #Before=your_application.service another_example_application.service -#AssertPathExists=/var/lib/redis +#AssertPathExists=/var/lib/valkey Wants=network-online.target After=network-online.target [Service] ExecStart=/usr/local/bin/valkey-server --supervised systemd --daemonize no -## Alternatively, have redis-server load a configuration file: +## Alternatively, have valkey-server load a configuration file: #ExecStart=/usr/local/bin/valkey-server /path/to/your/valkey.conf LimitNOFILE=10032 NoNewPrivileges=yes @@ -35,9 +35,9 @@ Type=notify TimeoutStartSec=infinity TimeoutStopSec=infinity UMask=0077 -#User=redis -#Group=redis -#WorkingDirectory=/var/lib/redis +#User=valkey +#Group=valkey +#WorkingDirectory=/var/lib/valkey [Install] WantedBy=multi-user.target From c2ebe9ebbdc7e45d73b2734d4c0f08633c766c9e Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Mon, 8 Apr 2024 17:18:45 -0700 Subject: [PATCH 76/98] Add sharded-pubsub tcl test to test_helper all test set (#267) Add sharded-pubsub to the supported TCL tests. Signed-off-by: Harkrishn Patro --- tests/test_helper.tcl | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 6d9ca6299a..1c79cbbec1 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -105,6 +105,7 @@ set ::all_tests { unit/cluster/links unit/cluster/cluster-response-tls unit/cluster/failure-marking + unit/cluster/sharded-pubsub } # Index to the next test to run in the ::all_tests list. set ::next_test 0 From e59dd41e42765e88bc481928448aac03221f5240 Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Mon, 8 Apr 2024 19:58:23 -0700 Subject: [PATCH 77/98] Maintain determinstic ordering of replica(s) in CLUSTER SLOTS response (#265) Sort `clusterNode.slaves` while adding a new replica to the cluster on basis of `name`. This will enable deterministic ordering of replica(s) information in `CLUSTER SLOTS` response. Before this change: ``` 127.0.0.1:6380> CLUSTER SLOTS 1) 1) (integer) 0 2) (integer) 16383 3) 1) "127.0.0.1" 2) (integer) 6379 3) "fc72609a620c62d073a31eed9ddde5104c1fa302" 4) (empty array) 4) 1) "127.0.0.1" 2) (integer) 6381 3) "fac84bbf2ffc5cfcdebc92c06b8ead9c3cba4051" 4) (empty array) 5) 1) "127.0.0.1" 2) (integer) 6380 3) "b1249d394326f1485df0b895f2fd38e141aa5056" 4) (empty array) ``` After this change: ``` 127.0.0.1:6380> CLUSTER SLOTS 1) 1) (integer) 0 2) (integer) 16383 3) 1) "127.0.0.1" 2) (integer) 6379 3) "fc72609a620c62d073a31eed9ddde5104c1fa302" 4) (empty array) 4) 1) "127.0.0.1" 2) (integer) 6380 3) "b1249d394326f1485df0b895f2fd38e141aa5056" 4) (empty array) 5) 1) "127.0.0.1" 2) (integer) 6381 3) "fac84bbf2ffc5cfcdebc92c06b8ead9c3cba4051" 4) (empty array) ``` Signed-off-by: Harkrishn Patro --- src/cluster_legacy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 2e93eda9cd..3e2850b176 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -1450,6 +1450,10 @@ int clusterNodeFailureReportsCount(clusterNode *node) { return listLength(node->fail_reports); } +static int clusterNodeNameComparator(const void *node1, const void *node2) { + return strncasecmp((*(clusterNode **)node1)->name, (*(clusterNode **)node2)->name, CLUSTER_NAMELEN); +} + int clusterNodeRemoveSlave(clusterNode *master, clusterNode *slave) { int j; @@ -1479,6 +1483,7 @@ int clusterNodeAddSlave(clusterNode *master, clusterNode *slave) { sizeof(clusterNode*)*(master->numslaves+1)); master->slaves[master->numslaves] = slave; master->numslaves++; + qsort(master->slaves, master->numslaves, sizeof(clusterNode *), clusterNodeNameComparator); master->flags |= CLUSTER_NODE_MIGRATE_TO; return C_OK; } From d89ef06ce5c377e5bcba5703ac138ccdfffb89e4 Mon Sep 17 00:00:00 2001 From: VoletiRam <90425341+VoletiRam@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:03:56 -0700 Subject: [PATCH 78/98] Wait for cluster fully online in cluster_config_consistent (#272) Wait for cluster to be in a fully consistent and online state in `cluster_config_consistent`. We expect the `start_server` to create the desired primaries and replicas before the start of the tests. With the current setup, the replicas may not complete the sync with primaries and can be in loading state. In some cases, the role of replicas can still be master with the delay of propagation of replicate command. The tests can show flaky behavior in such cases. Add a check that verifies the nodes health status 'online' for the cluster consistency. Leverage the deterministic order of `CLUSTER SLOTS` to consider the cluster as consistent along with the nodes health status. --------- Signed-off-by: Harkrishn Patro Signed-off-by: Ram Prasad Voleti Co-authored-by: Harkrishn Patro Co-authored-by: Ram Prasad Voleti --- tests/cluster/cluster.tcl | 15 ++++++++++++++- tests/support/cluster_util.tcl | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl index 9931eac849..83168f0918 100644 --- a/tests/cluster/cluster.tcl +++ b/tests/cluster/cluster.tcl @@ -182,8 +182,21 @@ proc cluster_write_test {id} { } # Check if cluster configuration is consistent. +# All the nodes in the cluster should show same slots configuration and have health +# state "online" to be considered as consistent. proc cluster_config_consistent {} { for {set j 0} {$j < $::cluster_master_nodes + $::cluster_replica_nodes} {incr j} { + # Check if all the nodes are online + set shards_cfg [R $j CLUSTER SHARDS] + foreach shard_cfg $shards_cfg { + set nodes [dict get $shard_cfg nodes] + foreach node $nodes { + if {[dict get $node health] ne "online"} { + return 0 + } + } + } + if {$j == 0} { set base_cfg [R $j cluster slots] } else { @@ -199,7 +212,7 @@ proc cluster_config_consistent {} { # Wait for cluster configuration to propagate and be consistent across nodes. proc wait_for_cluster_propagation {} { - wait_for_condition 50 100 { + wait_for_condition 1000 50 { [cluster_config_consistent] eq 1 } else { fail "cluster config did not reach a consistent state" diff --git a/tests/support/cluster_util.tcl b/tests/support/cluster_util.tcl index 5160466474..d89a5a384d 100644 --- a/tests/support/cluster_util.tcl +++ b/tests/support/cluster_util.tcl @@ -1,8 +1,21 @@ # Cluster helper functions # Check if cluster configuration is consistent. +# All the nodes in the cluster should show same slots configuration and have health +# state "online" to be considered as consistent. proc cluster_config_consistent {} { for {set j 0} {$j < [llength $::servers]} {incr j} { + # Check if all the nodes are online + set shards_cfg [R $j CLUSTER SHARDS] + foreach shard_cfg $shards_cfg { + set nodes [dict get $shard_cfg nodes] + foreach node $nodes { + if {[dict get $node health] ne "online"} { + return 0 + } + } + } + if {$j == 0} { set base_cfg [R $j cluster slots] } else { @@ -27,7 +40,7 @@ proc cluster_size_consistent {cluster_size} { # Wait for cluster configuration to propagate and be consistent across nodes. proc wait_for_cluster_propagation {} { - wait_for_condition 50 100 { + wait_for_condition 1000 50 { [cluster_config_consistent] eq 1 } else { fail "cluster config did not reach a consistent state" From 1aa13decf6ed15b803e63a5730f7f9dc84329022 Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Mon, 8 Apr 2024 21:20:10 -0700 Subject: [PATCH 79/98] Remove single node cluster validation check from benchmark (#266) Allow redis-benchmark to run against single shard clusters. Signed-off-by: Harkrishn Patro --- src/valkey-benchmark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index 1a7b9f6c56..bfc0760927 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -1787,7 +1787,7 @@ int main(int argc, char **argv) { } exit(1); } - if (config.cluster_node_count <= 1) { + if (config.cluster_node_count == 0) { fprintf(stderr, "Invalid cluster: %d node(s).\n", config.cluster_node_count); exit(1); From df5db0627f3976d2c5fb71358cb6655b4581b614 Mon Sep 17 00:00:00 2001 From: Jacob Murphy Date: Tue, 9 Apr 2024 01:24:03 -0700 Subject: [PATCH 80/98] Remove trademarked language in code comments (#223) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This includes comments used for module API documentation. * Strategy for replacement: Regex search: `(//|/\*| \*|#).* ("|\()?(r|R)edis( |\. |'|\n|,|-|\)|")(?!nor the names of its contributors)(?!Ltd.)(?!Labs)(?!Contributors.)` * Don't edit copyright comments * Replace "Redis version X.X" -> "Redis OSS version X.X" to distinguish from newly licensed repository * Replace "Redis Object" -> "Object" * Exclude markdown for now * Don't edit Lua scripting comments referring to redis.X API * Replace "Redis Protocol" -> "RESP" * Replace redis-benchmark, -cli, -server, -check-aof/rdb with "valkey-" prefix * Most other places, I use best judgement to either remove "Redis", or replace with "the server" or "server" Fixes #148 --------- Signed-off-by: Jacob Murphy Signed-off-by: Viktor Söderqvist --- deps/Makefile | 2 +- src/acl.c | 8 +- src/ae.c | 2 +- src/anet.c | 4 +- src/aof.c | 38 +- src/atomicvar.h | 4 +- src/bio.c | 6 +- src/bitops.c | 4 +- src/blocked.c | 4 +- src/call_reply.c | 2 +- src/cli_commands.h | 4 +- src/cluster.c | 12 +- src/cluster.h | 6 +- src/cluster_legacy.c | 28 +- src/cluster_legacy.h | 8 +- src/commands.def | 2 +- src/config.c | 4 +- src/config.h | 2 +- src/connection.h | 6 +- src/crc16_slottable.h | 6 +- src/db.c | 26 +- src/debug.c | 8 +- src/dict.c | 2 +- src/endianconv.c | 2 +- src/eval.c | 26 +- src/evict.c | 8 +- src/expire.c | 4 +- src/functions.c | 2 +- src/functions.h | 4 +- src/geo.c | 4 +- src/hyperloglog.c | 20 +- src/kvstore.c | 2 +- src/latency.c | 4 +- src/lazyfree.c | 4 +- src/listpack.c | 2 +- src/localtime.c | 6 +- src/lolwut.c | 4 +- src/lolwut5.c | 4 +- src/lolwut6.c | 2 +- src/module.c | 360 +++++++++--------- src/modules/helloacl.c | 4 +- src/modules/helloblock.c | 4 +- src/modules/hellocluster.c | 6 +- src/modules/hellodict.c | 6 +- src/modules/hellohook.c | 4 +- src/modules/hellotimer.c | 4 +- src/modules/hellotype.c | 4 +- src/modules/helloworld.c | 16 +- src/monotonic.c | 2 +- src/networking.c | 32 +- src/notify.c | 4 +- src/object.c | 14 +- src/pqsort.c | 2 +- src/pqsort.h | 2 +- src/pubsub.c | 4 +- src/rax.h | 2 +- src/rdb.c | 30 +- src/release.c | 2 +- src/replication.c | 26 +- src/resp_parser.c | 2 +- src/rio.c | 2 +- src/script.c | 4 +- src/script.h | 6 +- src/script_lua.c | 40 +- src/script_lua.h | 4 +- src/sentinel.c | 46 +-- src/server.c | 92 ++--- src/server.h | 50 +-- src/serverassert.h | 4 +- src/slowlog.c | 6 +- src/socket.c | 2 +- src/sort.c | 2 +- src/syncio.c | 2 +- src/syscheck.c | 4 +- src/t_hash.c | 2 +- src/t_list.c | 2 +- src/t_set.c | 2 +- src/t_stream.c | 2 +- src/t_string.c | 2 +- src/t_zset.c | 6 +- src/tls.c | 4 +- src/tracking.c | 18 +- src/unix.c | 2 +- src/util.c | 8 +- src/valkey-benchmark.c | 4 +- src/valkey-check-aof.c | 6 +- src/valkey-check-rdb.c | 6 +- src/valkey-cli.c | 40 +- src/version.h | 2 +- src/zipmap.c | 4 +- src/zmalloc.c | 4 +- src/zmalloc.h | 4 +- tests/assets/default.conf | 2 +- tests/assets/test_cli_hint_suite.txt | 2 +- tests/cluster/run.tcl | 2 +- tests/cluster/tests/04-resharding.tcl | 6 +- tests/cluster/tests/10-manual-failover.tcl | 4 +- tests/cluster/tests/20-half-migrated-slot.tcl | 2 +- .../cluster/tests/21-many-slot-migration.tcl | 2 +- tests/cluster/tests/includes/utils.tcl | 2 +- tests/helpers/fake_redis_node.tcl | 2 +- tests/instances.tcl | 12 +- tests/integration/aof-multi-part.tcl | 10 +- tests/integration/aof.tcl | 2 +- tests/integration/corrupt-dump-fuzzer.tcl | 2 +- tests/integration/logging.tcl | 14 +- tests/integration/psync2-pingoff.tcl | 2 +- tests/integration/psync2-reg.tcl | 2 +- tests/integration/psync2.tcl | 2 +- tests/integration/rdb.tcl | 2 +- tests/integration/valkey-benchmark.tcl | 2 +- tests/integration/valkey-cli.tcl | 2 +- tests/modules/aclcheck.c | 6 +- tests/modules/auth.c | 4 +- tests/modules/basics.c | 2 +- tests/modules/blockedclient.c | 14 +- tests/modules/blockonkeys.c | 2 +- tests/modules/cmdintrospection.c | 2 +- tests/modules/datatype2.c | 4 +- tests/modules/hooks.c | 4 +- tests/modules/keyspace_events.c | 4 +- tests/modules/postnotifications.c | 4 +- tests/modules/test_lazyfree.c | 2 +- tests/modules/usercall.c | 4 +- tests/sentinel/tests/10-replica-priority.tcl | 2 +- tests/support/cluster.tcl | 12 +- tests/support/redis.tcl | 2 +- tests/support/response_transformers.tcl | 2 +- tests/support/util.tcl | 14 +- tests/test_helper.tcl | 12 +- tests/unit/acl.tcl | 2 +- tests/unit/bitfield.tcl | 4 +- tests/unit/bitops.tcl | 2 +- tests/unit/client-eviction.tcl | 4 +- tests/unit/cluster/cli.tcl | 8 +- tests/unit/cluster/links.tcl | 2 +- tests/unit/expire.tcl | 4 +- tests/unit/geo.tcl | 4 +- tests/unit/hyperloglog.tcl | 2 +- tests/unit/introspection.tcl | 4 +- tests/unit/maxmemory.tcl | 4 +- tests/unit/moduleapi/async_rm_call.tcl | 2 +- tests/unit/moduleapi/auth.tcl | 2 +- tests/unit/moduleapi/blockedclient.tcl | 2 +- tests/unit/moduleapi/cluster.tcl | 2 +- tests/unit/moduleapi/defrag.tcl | 2 +- tests/unit/moduleapi/misc.tcl | 2 +- tests/unit/moduleapi/moduleauth.tcl | 6 +- tests/unit/moduleapi/rdbloadsave.tcl | 4 +- tests/unit/multi.tcl | 2 +- tests/unit/obuf-limits.tcl | 8 +- tests/unit/scan.tcl | 6 +- tests/unit/scripting.tcl | 14 +- tests/unit/sort.tcl | 2 +- tests/unit/tracking.tcl | 2 +- tests/unit/type/stream.tcl | 2 +- tests/unit/type/string.tcl | 2 +- tests/unit/type/zset.tcl | 4 +- utils/generate-command-code.py | 2 +- utils/hyperloglog/hll-err.rb | 2 +- utils/hyperloglog/hll-gnuplot-graph.rb | 4 +- utils/install_server.sh | 18 +- utils/lru/lfu-simulation.c | 2 +- utils/redis-copy.rb | 2 +- utils/redis_init_script | 2 +- utils/req-res-log-validator.py | 2 +- utils/speed-regression.tcl | 4 +- utils/tracking_collisions.c | 2 +- 168 files changed, 757 insertions(+), 757 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 3bf0363d5c..67b7d41026 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -1,4 +1,4 @@ -# Redis dependency Makefile +# Dependency Makefile uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not') diff --git a/src/acl.c b/src/acl.c index f0668a4ecd..d9577b2124 100644 --- a/src/acl.c +++ b/src/acl.c @@ -168,7 +168,7 @@ typedef struct { * execute this command. * * If the bit for a given command is NOT set and the command has - * allowed first-args, Redis will also check allowed_firstargs in order to + * allowed first-args, the server will also check allowed_firstargs in order to * understand if the command can be executed. */ uint64_t allowed_commands[USER_COMMAND_BITS_COUNT/64]; /* allowed_firstargs is used by ACL rules to block access to a command unless a @@ -502,7 +502,7 @@ void ACLFreeUserAndKillClients(user *u) { if (c->user == u) { /* We'll free the connection asynchronously, so * in theory to set a different user is not needed. - * However if there are bugs in Redis, soon or later + * However if there are bugs in the server, soon or later * this may result in some security hole: it's much * more defensive to set the default user and put * it in non authenticated mode. */ @@ -1023,7 +1023,7 @@ aclSelector *aclCreateSelectorFromOpSet(const char *opset, size_t opsetlen) { * +@ Allow the execution of all the commands in such category * with valid categories are like @admin, @set, @sortedset, ... * and so forth, see the full list in the server.c file where - * the Redis command table is described and defined. + * the command table is described and defined. * The special category @all means all the commands, but currently * present in the server, and that will be loaded in the future * via modules. @@ -3204,7 +3204,7 @@ void addReplyCommandCategories(client *c, struct serverCommand *cmd) { } /* AUTH - * AUTH (Redis >= 6.0 form) + * AUTH (Redis OSS >= 6.0 form) * * When the user is omitted it means that we are trying to authenticate * against the default user. */ diff --git a/src/ae.c b/src/ae.c index 839d23b51d..cc67f2580e 100644 --- a/src/ae.c +++ b/src/ae.c @@ -258,7 +258,7 @@ int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id) * If there are no timers, -1 is returned. * * Note that's O(N) since time events are unsorted. - * Possible optimizations (not needed by Redis so far, but...): + * Possible optimizations (not needed so far, but...): * 1) Insert the event in order, so that the nearest is just the head. * Much better but still insertion or deletion of timers is O(N). * 2) Use a skiplist to have this operation as O(1) and insertion as O(log(N)). diff --git a/src/anet.c b/src/anet.c index e4f9ecf37a..0a05fb5624 100644 --- a/src/anet.c +++ b/src/anet.c @@ -372,7 +372,7 @@ int anetResolve(char *err, char *host, char *ipbuf, size_t ipbuf_len, static int anetSetReuseAddr(char *err, int fd) { int yes = 1; - /* Make sure connection-intensive things like the redis benchmark + /* Make sure connection-intensive things like the benchmark tool * will be able to close/open sockets a zillion of times */ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) { anetSetError(err, "setsockopt SO_REUSEADDR: %s", strerror(errno)); @@ -388,7 +388,7 @@ static int anetCreateSocket(char *err, int domain) { return ANET_ERR; } - /* Make sure connection-intensive things like the redis benchmark + /* Make sure connection-intensive things like the benchmark tool * will be able to close/open sockets a zillion of times */ if (anetSetReuseAddr(err,s) == ANET_ERR) { close(s); diff --git a/src/aof.c b/src/aof.c index ab24770b9a..a6a89c931b 100644 --- a/src/aof.c +++ b/src/aof.c @@ -59,11 +59,11 @@ void aof_background_fsync_and_close(int fd); * * Append-only files consist of three types: * - * BASE: Represents a Redis snapshot from the time of last AOF rewrite. The manifest + * BASE: Represents a server snapshot from the time of last AOF rewrite. The manifest * file contains at most a single BASE file, which will always be the first file in the * list. * - * INCR: Represents all write commands executed by Redis following the last successful + * INCR: Represents all write commands executed by the server following the last successful * AOF rewrite. In some cases it is possible to have several ordered INCR files. For * example: * - During an on-going AOF rewrite @@ -119,7 +119,7 @@ aofInfo *aofInfoDup(aofInfo *orig) { /* Format aofInfo as a string and it will be a line in the manifest. * - * When update this format, make sure to update redis-check-aof as well. */ + * When update this format, make sure to update valkey-check-aof as well. */ sds aofInfoFormat(sds buf, aofInfo *ai) { sds filename_repr = NULL; @@ -222,10 +222,10 @@ sds getAofManifestAsString(aofManifest *am) { } /* Load the manifest information from the disk to `server.aof_manifest` - * when the Redis server start. + * when the server starts. * * During loading, this function does strict error checking and will abort - * the entire Redis server process on error (I/O error, invalid format, etc.) + * the entire server process on error (I/O error, invalid format, etc.) * * If the AOF directory or manifest file do not exist, this will be ignored * in order to support seamless upgrades from previous versions which did not @@ -253,7 +253,7 @@ void aofLoadManifestFromDisk(void) { sdsfree(am_filepath); } -/* Generic manifest loading function, used in `aofLoadManifestFromDisk` and redis-check-aof tool. */ +/* Generic manifest loading function, used in `aofLoadManifestFromDisk` and valkey-check-aof tool. */ #define MANIFEST_MAX_LINE 1024 aofManifest *aofLoadManifestFromFile(sds am_filepath) { const char *err = NULL; @@ -609,7 +609,7 @@ int persistAofManifest(aofManifest *am) { return ret; } -/* Called in `loadAppendOnlyFiles` when we upgrade from a old version redis. +/* Called in `loadAppendOnlyFiles` when we upgrade from a old version of the server. * * 1) Create AOF directory use 'server.aof_dirname' as the name. * 2) Use 'server.aof_filename' to construct a BASE type aofInfo and add it to @@ -617,7 +617,7 @@ int persistAofManifest(aofManifest *am) { * 3) Move the old AOF file (server.aof_filename) to AOF directory. * * If any of the above steps fails or crash occurs, this will not cause any - * problems, and redis will retry the upgrade process when it restarts. + * problems, and the server will retry the upgrade process when it restarts. */ void aofUpgradePrepare(aofManifest *am) { serverAssert(!aofFileExist(server.aof_filename)); @@ -704,13 +704,13 @@ void aofDelTempIncrAofFile(void) { return; } -/* Called after `loadDataFromDisk` when redis start. If `server.aof_state` is +/* Called after `loadDataFromDisk` when the server starts. If `server.aof_state` is * 'AOF_ON', It will do three things: - * 1. Force create a BASE file when redis starts with an empty dataset + * 1. Force create a BASE file when the server starts with an empty dataset * 2. Open the last opened INCR type AOF for writing, If not, create a new one * 3. Synchronously update the manifest file to the disk * - * If any of the above steps fails, the redis process will exit. + * If any of the above steps fails, the server process will exit. */ void aofOpenIfNeededOnServerStart(void) { if (server.aof_state != AOF_ON) { @@ -856,7 +856,7 @@ int openNewIncrAofForAppend(void) { /* Whether to limit the execution of Background AOF rewrite. * - * At present, if AOFRW fails, redis will automatically retry. If it continues + * At present, if AOFRW fails, the server will automatically retry. If it continues * to fail, we may get a lot of very small INCR files. so we need an AOFRW * limiting measure. * @@ -1371,7 +1371,7 @@ void feedAppendOnlyFile(int dictid, robj **argv, int argc) { * AOF loading * ------------------------------------------------------------------------- */ -/* In Redis commands are always executed in the context of a client, so in +/* Commands are always executed in the context of a client, so in * order to load the append only file we need to create a fake client. */ struct client *createAOFClient(void) { struct client *c = createClient(NULL); @@ -1390,7 +1390,7 @@ struct client *createAOFClient(void) { c->flags = CLIENT_DENY_BLOCKING; /* We set the fake client as a slave waiting for the synchronization - * so that Redis will not try to send replies to this client. */ + * so that the server will not try to send replies to this client. */ c->replstate = SLAVE_STATE_WAIT_BGSAVE_START; return c; } @@ -1664,7 +1664,7 @@ int loadAppendOnlyFiles(aofManifest *am) { int total_num, aof_num = 0, last_file; /* If the 'server.aof_filename' file exists in dir, we may be starting - * from an old redis version. We will use enter upgrade mode in three situations. + * from an old server version. We will use enter upgrade mode in three situations. * * 1. If the 'server.aof_dirname' directory not exist * 2. If the 'server.aof_dirname' directory exists but the manifest file is missing @@ -1954,7 +1954,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) { } /* Write either the key or the value of the currently selected item of a hash. - * The 'hi' argument passes a valid Redis hash iterator. + * The 'hi' argument passes a valid hash iterator. * The 'what' filed specifies if to write a key or a value and can be * either OBJ_HASH_KEY or OBJ_HASH_VALUE. * @@ -2208,7 +2208,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) { } /* Call the module type callback in order to rewrite a data type - * that is exported by a module and is not handled by Redis itself. + * that is exported by a module and is not handled by the server itself. * The function returns 0 on error, 1 on success. */ int rewriteModuleObject(rio *r, robj *key, robj *o, int dbid) { ValkeyModuleIO io; @@ -2347,7 +2347,7 @@ int rewriteAppendOnlyFileRio(rio *aof) { * "filename". Used both by REWRITEAOF and BGREWRITEAOF. * * In order to minimize the number of commands needed in the rewritten - * log Redis uses variadic commands when possible, such as RPUSH, SADD + * log, the server uses variadic commands when possible, such as RPUSH, SADD * and ZADD. However at max AOF_REWRITE_ITEMS_PER_CMD items per time * are inserted using a single command. */ int rewriteAppendOnlyFile(char *filename) { @@ -2419,7 +2419,7 @@ int rewriteAppendOnlyFile(char *filename) { /* This is how rewriting of the append only file in background works: * * 1) The user calls BGREWRITEAOF - * 2) Redis calls this function, that forks(): + * 2) The server calls this function, that forks(): * 2a) the child rewrite the append only file in a temp file. * 2b) the parent open a new INCR AOF file to continue writing. * 3) When the child finished '2a' exists. diff --git a/src/atomicvar.h b/src/atomicvar.h index b506c5d29e..17d1c15a6d 100644 --- a/src/atomicvar.h +++ b/src/atomicvar.h @@ -83,13 +83,13 @@ /* Define serverAtomic for atomic variable. */ #define serverAtomic -/* To test Redis with Helgrind (a Valgrind tool) it is useful to define +/* To test the server with Helgrind (a Valgrind tool) it is useful to define * the following macro, so that __sync macros are used: those can be detected * by Helgrind (even if they are less efficient) so that no false positive * is reported. */ // #define __ATOMIC_VAR_FORCE_SYNC_MACROS -/* There will be many false positives if we test Redis with Helgrind, since +/* There will be many false positives if we test the server with Helgrind, since * Helgrind can't understand we have imposed ordering on the program, so * we use macros in helgrind.h to tell Helgrind inter-thread happens-before * relationship explicitly for avoiding false positives. diff --git a/src/bio.c b/src/bio.c index da62222426..c6b4d77c0e 100644 --- a/src/bio.c +++ b/src/bio.c @@ -1,4 +1,4 @@ -/* Background I/O service for Redis. +/* Background I/O service for the server. * * This file implements operations that we need to perform in the background. * Currently there is only a single operation, that is a background close(2) @@ -8,7 +8,7 @@ * * In the future we'll either continue implementing new things we need or * we'll switch to libeio. However there are probably long term uses for this - * file as we may want to put here Redis specific background tasks (for instance + * file as we may want to put here server specific background tasks (for instance * it is not impossible that we'll need a non blocking FLUSHDB/FLUSHALL * implementation). * @@ -323,7 +323,7 @@ void bioDrainWorker(int job_type) { /* Kill the running bio threads in an unclean way. This function should be * used only when it's critical to stop the threads for some reason. - * Currently Redis does this only on crash (for instance on SIGSEGV) in order + * Currently the server does this only on crash (for instance on SIGSEGV) in order * to perform a fast memory check without other threads messing with memory. */ void bioKillThreads(void) { int err; diff --git a/src/bitops.c b/src/bitops.c index 5b97c033aa..611ab931b4 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -406,7 +406,7 @@ void printBits(unsigned char *p, unsigned long count) { /* This helper function used by GETBIT / SETBIT parses the bit offset argument * making sure an error is returned if it is negative or if it overflows - * Redis 512 MB limit for the string value or more (server.proto_max_bulk_len). + * the server's 512 MB limit for the string value or more (server.proto_max_bulk_len). * * If the 'hash' argument is true, and 'bits is positive, then the command * will also parse bit offsets prefixed by "#". In such a case the offset @@ -443,7 +443,7 @@ int getBitOffsetFromArgument(client *c, robj *o, uint64_t *offset, int hash, int /* This helper function for BITFIELD parses a bitfield type in the form * where sign is 'u' or 'i' for unsigned and signed, and * the bits is a value between 1 and 64. However 64 bits unsigned integers - * are reported as an error because of current limitations of Redis protocol + * are reported as an error because of current limitations of RESP * to return unsigned integer values greater than INT64_MAX. * * On error C_ERR is returned and an error is sent to the client. */ diff --git a/src/blocked.c b/src/blocked.c index aeac106706..ad815a9b6c 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -292,7 +292,7 @@ void disconnectAllBlockedClients(void) { } } -/* This function should be called by Redis every time a single command, +/* This function should be called by the server every time a single command, * a MULTI/EXEC block, or a Lua script, terminated its execution after * being called by a client. It handles serving clients blocked in all scenarios * where a specific key access requires to block until that key is available. @@ -310,7 +310,7 @@ void disconnectAllBlockedClients(void) { * do client side, indeed!). Because mismatching clients (blocking for * a different type compared to the current key type) are moved in the * other side of the linked list. However as long as the key starts to - * be used only for a single type, like virtually any Redis application will + * be used only for a single type, like virtually any application will * do, the function is already fair. */ void handleClientsBlockedOnKeys(void) { diff --git a/src/call_reply.c b/src/call_reply.c index 0afaf4469e..9e910f50c6 100644 --- a/src/call_reply.c +++ b/src/call_reply.c @@ -525,7 +525,7 @@ list *callReplyDeferredErrorList(CallReply *rep) { * callReplyGetPrivateData(). * * NOTE: The parser used for parsing the reply and producing CallReply is - * designed to handle valid replies created by Redis itself. IT IS NOT + * designed to handle valid replies created by the server itself. IT IS NOT * DESIGNED TO HANDLE USER INPUT and using it to parse invalid replies is * unsafe. */ diff --git a/src/cli_commands.h b/src/cli_commands.h index 4642272eb4..5669d2cf4b 100644 --- a/src/cli_commands.h +++ b/src/cli_commands.h @@ -1,6 +1,6 @@ -/* This file is used by redis-cli in place of server.h when including commands.c +/* This file is used by valkey-cli in place of server.h when including commands.c * It contains alternative structs which omit the parts of the commands table - * that are not suitable for redis-cli, e.g. the command proc. */ + * that are not suitable for valkey-cli, e.g. the command proc. */ #ifndef VALKEY_CLI_COMMANDS_H #define VALKEY_CLI_COMMANDS_H diff --git a/src/cluster.c b/src/cluster.c index ca002a17bb..99c02cd86d 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -30,7 +30,7 @@ /* * cluster.c contains the common parts of a clustering * implementation, the parts that are shared between - * any implementation of Redis clustering. + * any implementation of clustering. */ #include "server.h" @@ -142,7 +142,7 @@ void createDumpPayload(rio *payload, robj *o, robj *key, int dbid) { payload->io.buffer.ptr = sdscatlen(payload->io.buffer.ptr,&crc,8); } -/* Verify that the RDB version of the dump payload matches the one of this Redis +/* Verify that the RDB version of the dump payload matches the one of this * instance and that the checksum is ok. * If the DUMP payload looks valid C_OK is returned, otherwise C_ERR * is returned. If rdbver_ptr is not NULL, its populated with the value read @@ -173,7 +173,7 @@ int verifyDumpPayload(unsigned char *p, size_t len, uint16_t *rdbver_ptr) { } /* DUMP keyname - * DUMP is actually not used by Redis Cluster but it is the obvious + * DUMP is actually not used by Cluster but it is the obvious * complement of RESTORE and can be useful for different applications. */ void dumpCommand(client *c) { robj *o; @@ -687,7 +687,7 @@ void migrateCommand(client *c) { if (!copy) { /* Translate MIGRATE as DEL for replication/AOF. Note that we do * this only for the keys for which we received an acknowledgement - * from the receiving Redis server, by using the del_idx index. */ + * from the receiving server, by using the del_idx index. */ if (del_idx > 1) { newargv[0] = createStringObject("DEL",3); /* Note that the following call takes ownership of newargv. */ @@ -1007,7 +1007,7 @@ clusterNode *getNodeByQuery(client *c, struct serverCommand *cmd, robj **argv, i /* Set error code optimistically for the base case. */ if (error_code) *error_code = CLUSTER_REDIR_NONE; - /* Modules can turn off Redis Cluster redirection: this is useful + /* Modules can turn off Cluster redirection: this is useful * when writing a module that implements a completely different * distributed system. */ @@ -1446,7 +1446,7 @@ void clusterCommandSlots(client * c) { /* The ASKING command is required after a -ASK redirection. * The client should issue ASKING before to actually send the command to - * the target instance. See the Redis Cluster specification for more + * the target instance. See the Cluster specification for more * information. */ void askingCommand(client *c) { if (server.cluster_enabled == 0) { diff --git a/src/cluster.h b/src/cluster.h index 463b4940d9..a7211615dd 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -2,7 +2,7 @@ #define __CLUSTER_H /*----------------------------------------------------------------------------- - * Redis cluster exported API. + * Cluster exported API. *----------------------------------------------------------------------------*/ #define CLUSTER_SLOT_MASK_BITS 14 /* Number of bits used for slot id. */ @@ -25,9 +25,9 @@ typedef struct _clusterNode clusterNode; struct clusterState; -/* Flags that a module can set in order to prevent certain Redis Cluster +/* Flags that a module can set in order to prevent certain Cluster * features to be enabled. Useful when implementing a different distributed - * system on top of Redis Cluster message bus, using modules. */ + * system on top of Cluster message bus, using modules. */ #define CLUSTER_MODULE_FLAG_NONE 0 #define CLUSTER_MODULE_FLAG_NO_FAILOVER (1<<1) #define CLUSTER_MODULE_FLAG_NO_REDIRECTION (1<<2) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 3e2850b176..01c531aaa0 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -29,7 +29,7 @@ /* * cluster_legacy.c contains the implementation of the cluster API that is - * specific to the standard, Redis cluster-bus based clustering mechanism. + * specific to the standard, cluster-bus based clustering mechanism. */ #include "server.h" @@ -169,7 +169,7 @@ dictType clusterSdsToListType = { NULL /* allow to expand */ }; -/* Aux fields are introduced in Redis 7.2 to support the persistence +/* Aux fields were introduced in Redis OSS 7.2 to support the persistence * of various important node properties, such as shard id, in nodes.conf. * Aux fields take an explicit format of name=value pairs and have no * intrinsic order among them. Aux fields are always grouped together @@ -349,7 +349,7 @@ int clusterLoadConfig(char *filename) { /* Parse the file. Note that single lines of the cluster config file can * be really long as they include all the hash slots of the node. - * This means in the worst possible case, half of the Redis slots will be + * This means in the worst possible case, half of the slots will be * present in a single line, possibly in importing or migrating state, so * together with the node ID of the sender/receiver. * @@ -372,7 +372,7 @@ int clusterLoadConfig(char *filename) { if (argv == NULL) goto fmterr; /* Handle the special "vars" line. Don't pretend it is the last - * line even if it actually is when generated by Redis. */ + * line even if it actually is when generated by the server. */ if (strcasecmp(argv[0],"vars") == 0) { if (!(argc % 2)) goto fmterr; for (j = 1; j < argc; j += 2) { @@ -583,7 +583,7 @@ int clusterLoadConfig(char *filename) { } else if (auxFieldHandlers[af_shard_id].isPresent(n) == 0) { /* n is a primary but it does not have a persisted shard_id. * This happens if we are loading a nodes.conf generated by - * an older version of Redis. We should manually update the + * an older version of the server. We should manually update the * shard membership in this case */ clusterAddNodeToShard(n->shard_id, n); } @@ -1591,7 +1591,7 @@ clusterNode *clusterLookupNode(const char *name, int length) { * Note that the list returned is not computed on the fly * via slaveof; rather, it is maintained permanently to * track the shard membership and its life cycle is tied - * to this Redis process. Therefore, the caller must not + * to this process. Therefore, the caller must not * release the list. */ list *clusterGetNodesInMyShard(clusterNode *node) { sds s = sdsnewlen(node->shard_id, CLUSTER_NAMELEN); @@ -1685,7 +1685,7 @@ uint64_t clusterGetMaxEpoch(void) { * * Important note: this function violates the principle that config epochs * should be generated with consensus and should be unique across the cluster. - * However Redis Cluster uses this auto-generated new config epochs in two + * However the cluster uses this auto-generated new config epochs in two * cases: * * 1) When slots are closed after importing. Otherwise resharding would be @@ -1694,7 +1694,7 @@ uint64_t clusterGetMaxEpoch(void) { * failover its master even if there is not master majority able to * create a new configuration epoch. * - * Redis Cluster will not explode using this function, even in the case of + * The cluster will not explode using this function, even in the case of * a collision between this node and another node, generating the same * configuration epoch unilaterally, because the config epoch conflict * resolution algorithm will eventually move colliding nodes to different @@ -1795,7 +1795,7 @@ void clusterHandleConfigEpochCollision(clusterNode *sender) { * about the node we want to remove, we don't re-add it before some time. * * Currently the CLUSTER_BLACKLIST_TTL is set to 1 minute, this means - * that redis-cli has 60 seconds to send CLUSTER FORGET messages to nodes + * that valkey-cli has 60 seconds to send CLUSTER FORGET messages to nodes * in the cluster without dealing with the problem of other nodes re-adding * back the node to nodes we already sent the FORGET command to. * @@ -2361,7 +2361,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc } /* The slot is in importing state, it should be modified only - * manually via redis-cli (example: a resharding is in progress + * manually via valkey-cli (example: a resharding is in progress * and the migrating side slot was already closed and is advertising * a new config. We still want the slot to be closed manually). */ if (server.cluster->importing_slots_from[j]) continue; @@ -2406,7 +2406,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc } /* After updating the slots configuration, don't do any actual change - * in the state of the server if a module disabled Redis Cluster + * in the state of the server if a module disabled Cluster * keys redirections. */ if (server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_REDIRECTION) return; @@ -3732,7 +3732,7 @@ void clusterSendPing(clusterLink *link, int type) { /* Send a PONG packet to every connected node that's not in handshake state * and for which we have a valid link. * - * In Redis Cluster pongs are not used just for failure detection, but also + * In Cluster mode, pongs are not used just for failure detection, but also * to carry important configuration information. So broadcasting a pong is * useful when something changes in the configuration and we want to make * the cluster aware ASAP (for instance after a slave promotion). @@ -3971,7 +3971,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { int j; /* IF we are not a master serving at least 1 slot, we don't have the - * right to vote, as the cluster size in Redis Cluster is the number + * right to vote, as the cluster size is the number * of masters serving at least one slot, and quorum is the cluster * size + 1 */ if (nodeIsSlave(myself) || myself->numslots == 0) return; @@ -5155,7 +5155,7 @@ void clusterUpdateState(void) { * B) If according to our config other nodes are already in charge for * this slots, we set the slots as IMPORTING from our point of view * in order to justify we have those slots, and in order to make - * redis-cli aware of the issue, so that it can try to fix it. + * valkey-cli aware of the issue, so that it can try to fix it. * 2) If we find data in a DB different than DB0 we return C_ERR to * signal the caller it should quit the server with an error message * or take other actions. diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index fc2ba80d19..9caf07bae3 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -68,7 +68,7 @@ typedef struct clusterNodeFailReport { mstime_t time; /* Time of the last report from this node. */ } clusterNodeFailReport; -/* Redis cluster messages header */ +/* Cluster messages header */ /* Message types. * @@ -206,7 +206,7 @@ union clusterMsgData { #define CLUSTER_PROTO_VER 1 /* Cluster bus protocol version. */ typedef struct { - char sig[4]; /* Signature "RCmb" (Redis Cluster message bus). */ + char sig[4]; /* Signature "RCmb" (Cluster message bus). */ uint32_t totlen; /* Total length of this message */ uint16_t ver; /* Protocol version, currently set to 1. */ uint16_t port; /* Primary port number (TCP or TLS). */ @@ -233,8 +233,8 @@ typedef struct { union clusterMsgData data; } clusterMsg; -/* clusterMsg defines the gossip wire protocol exchanged among Redis cluster - * members, which can be running different versions of redis-server bits, +/* clusterMsg defines the gossip wire protocol exchanged among cluster + * members, which can be running different versions of server bits, * especially during cluster rolling upgrades. * * Therefore, fields in this struct should remain at the same offset from diff --git a/src/commands.def b/src/commands.def index 7007568b61..bd6ed38153 100644 --- a/src/commands.def +++ b/src/commands.def @@ -3,7 +3,7 @@ /* We have fabulous commands from * the fantastic - * Redis Command Table! */ + * Command Table! */ /* Must match serverCommandGroup */ const char *COMMAND_GROUP_STR[] = { diff --git a/src/config.c b/src/config.c index 6b7d22969c..588a35cf86 100644 --- a/src/config.c +++ b/src/config.c @@ -1919,7 +1919,7 @@ static int sdsConfigSet(standardConfig *config, sds *argv, int argc, const char /* if prev and new configuration are not equal, set the new one */ if (new != prev && (new == NULL || prev == NULL || sdscmp(prev, new))) { /* If MODULE_CONFIG flag is set, then free temporary prev getModuleStringConfig returned. - * Otherwise, free the actual previous config value Redis held (Same action, different reasons) */ + * Otherwise, free the actual previous config value the server held (Same action, different reasons) */ sdsfree(prev); if (config->flags & MODULE_CONFIG) { @@ -2585,7 +2585,7 @@ int updateRequirePass(const char **err) { /* The old "requirepass" directive just translates to setting * a password to the default user. The only thing we do * additionally is to remember the cleartext password in this - * case, for backward compatibility with Redis <= 5. */ + * case, for backward compatibility. */ ACLUpdateDefaultUserPassword(server.requirepass); return 1; } diff --git a/src/config.h b/src/config.h index 9e2db5ac6c..e550da00f0 100644 --- a/src/config.h +++ b/src/config.h @@ -225,7 +225,7 @@ void setproctitle(const char *fmt, ...); /* Sometimes after including an OS-specific header that defines the * endianness we end with __BYTE_ORDER but not with BYTE_ORDER that is what - * the Redis code uses. In this case let's define everything without the + * the server code uses. In this case let's define everything without the * underscores. */ #ifndef BYTE_ORDER #ifdef __BYTE_ORDER diff --git a/src/connection.h b/src/connection.h index ac48214237..f50cd89d1c 100644 --- a/src/connection.h +++ b/src/connection.h @@ -290,7 +290,7 @@ static inline int connAddr(connection *conn, char *ip, size_t ip_len, int *port, /* Format an IP,port pair into something easy to parse. If IP is IPv6 * (matches for ":"), the ip is surrounded by []. IP and port are just - * separated by colons. This the standard to display addresses within Redis. */ + * separated by colons. This the standard to display addresses within the server. */ static inline int formatAddr(char *buf, size_t buf_len, char *ip, int port) { return snprintf(buf, buf_len, strchr(ip,':') ? "[%s]:%d" : "%s:%d", ip, port); @@ -378,10 +378,10 @@ static inline sds connGetPeerCert(connection *conn) { return NULL; } -/* Initialize the redis connection framework */ +/* Initialize the connection framework */ int connTypeInitialize(void); -/* Register a connection type into redis connection framework */ +/* Register a connection type into the connection framework */ int connTypeRegister(ConnectionType *ct); /* Lookup a connection type by type name */ diff --git a/src/crc16_slottable.h b/src/crc16_slottable.h index f25e2412e8..84e2aa0280 100644 --- a/src/crc16_slottable.h +++ b/src/crc16_slottable.h @@ -1,11 +1,11 @@ #ifndef _CRC16_TABLE_H__ #define _CRC16_TABLE_H__ -/* A table of the shortest possible alphanumeric string that is mapped by redis' crc16 - * to any given redis cluster slot. +/* A table of the shortest possible alphanumeric string that is mapped by crc16 + * to any given cluster slot. * * The array indexes are slot numbers, so that given a desired slot, this string is guaranteed - * to make redis cluster route a request to the shard holding this slot + * to make the cluster route a request to the shard holding this slot */ typedef char crc16_alphastring[4]; diff --git a/src/db.c b/src/db.c index 886f27c0b9..17e74f5881 100644 --- a/src/db.c +++ b/src/db.c @@ -343,7 +343,7 @@ void setKey(client *c, serverDb *db, robj *key, robj *val, int flags) { if (!(flags & SETKEY_NO_SIGNAL)) signalModifiedKey(c,db,key); } -/* Return a random key, in form of a Redis object. +/* Return a random key, in form of an Object. * If there are no keys, NULL is returned. * * The function makes sure to return keys not already expired. */ @@ -427,7 +427,7 @@ int dbAsyncDelete(serverDb *db, robj *key) { return dbGenericDelete(db, key, 1, DB_FLAG_KEY_DELETED); } -/* This is a wrapper whose behavior depends on the Redis lazy free +/* This is a wrapper whose behavior depends on the server lazy free * configuration. Deletes the key synchronously or asynchronously. */ int dbDelete(serverDb *db, robj *key) { return dbGenericDelete(db, key, server.lazyfree_lazy_server_del, DB_FLAG_KEY_DELETED); @@ -507,11 +507,11 @@ long long emptyDbStructure(serverDb *dbarray, int dbnum, int async, } /* Remove all data (keys and functions) from all the databases in a - * Redis server. If callback is given the function is called from + * server. If callback is given the function is called from * time to time to signal that work is in progress. * * The dbnum can be -1 if all the DBs should be flushed, or the specified - * DB number if we want to flush only a single Redis database number. + * DB number if we want to flush only a single database number. * * Flags are be EMPTYDB_NO_FLAGS if no special flags are specified or * EMPTYDB_ASYNC if we want the memory to be freed in a different thread @@ -542,7 +542,7 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { * there. */ signalFlushedDb(dbnum, async); - /* Empty redis database structure. */ + /* Empty the database structure. */ removed = emptyDbStructure(server.db, dbnum, async, callback); if (dbnum == -1) flushSlaveKeysWithExpireList(); @@ -695,7 +695,7 @@ void flushAllDataAndResetRDB(int flags) { /* FLUSHDB [ASYNC] * - * Flushes the currently SELECTed Redis DB. */ + * Flushes the currently SELECTed DB. */ void flushdbCommand(client *c) { int flags; @@ -885,7 +885,7 @@ void scanCallback(void *privdata, const dictEntry *de) { serverAssert(!((data->type != LLONG_MAX) && o)); /* Filter an element if it isn't the type we want. */ - /* TODO: uncomment in redis 8.0 + /* TODO: uncomment in version 8.0 if (!o && data->type != LLONG_MAX) { robj *rval = dictGetVal(de); if (!objectTypeCompare(rval, data->type)) return; @@ -1030,7 +1030,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long long cursor) { typename = c->argv[i+1]->ptr; type = getObjectTypeByName(typename); if (type == LLONG_MAX) { - /* TODO: uncomment in redis 8.0 + /* TODO: uncomment in version 8.0 addReplyErrorFormat(c, "unknown type name '%s'", typename); return; */ } @@ -1185,7 +1185,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long long cursor) { sds key = listNodeValue(ln); initStaticStringObject(kobj, key); /* Filter an element if it isn't the type we want. */ - /* TODO: remove this in redis 8.0 */ + /* TODO: remove this in version 8.0 */ if (typename) { robj* typecheck = lookupKeyReadWithFlags(c->db, &kobj, LOOKUP_NOTOUCH|LOOKUP_NONOTIFY); if (!typecheck || !objectTypeCompare(typecheck, type)) { @@ -1565,7 +1565,7 @@ void scanDatabaseForDeletedKeys(serverDb *emptied, serverDb *replaced_with) { * the new database even if already connected. Note that the client * structure c->db points to a given DB, so we need to be smarter and * swap the underlying referenced structures, otherwise we would need - * to fix all the references to the Redis DB structure. + * to fix all the references to the DB structure. * * Returns C_ERR if at least one of the DB ids are out of range, otherwise * C_OK is returned. */ @@ -2109,7 +2109,7 @@ int getKeysUsingKeySpecs(struct serverCommand *cmd, robj **argv, int argc, int s * length of the array is returned by reference into *numkeys. * * Along with the position, this command also returns the flags that are - * associated with how Redis will access the key. + * associated with how the server will access the key. * * 'cmd' must be point to the corresponding entry into the serverCommand * table, according to the command name in argv[0]. */ @@ -2146,7 +2146,7 @@ int doesCommandHaveKeys(struct serverCommand *cmd) { (getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY); /* has at least one key-spec not marked as NOT_KEY */ } -/* A simplified channel spec table that contains all of the redis commands +/* A simplified channel spec table that contains all of the commands * and which channels they have and how they are accessed. */ typedef struct ChannelSpecs { serverCommandProc *proc; /* Command procedure to match against */ @@ -2193,7 +2193,7 @@ int doesCommandHaveChannelsWithFlags(struct serverCommand *cmd, int flags) { * length of the array is returned by reference into *numkeys. * * Along with the position, this command also returns the flags that are - * associated with how Redis will access the channel. + * associated with how the server will access the channel. * * 'cmd' must be point to the corresponding entry into the serverCommand * table, according to the command name in argv[0]. */ diff --git a/src/debug.c b/src/debug.c index b688ac898f..5566aadb52 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1789,9 +1789,9 @@ void logRegisters(ucontext_t *uc) { #endif /* HAVE_BACKTRACE */ -/* Return a file descriptor to write directly to the Redis log with the +/* Return a file descriptor to write directly to the server log with the * write(2) syscall, that can be used in critical sections of the code - * where the rest of Redis can't be trusted (for example during the memory + * where the rest of server can't be trusted (for example during the memory * test) or when an API call requires a raw fd. * * Close it with closeDirectLogFiledes(). */ @@ -2023,7 +2023,7 @@ void logModulesInfo(void) { } /* Log information about the "current" client, that is, the client that is - * currently being served by Redis. May be NULL if Redis is not serving a + * currently being served by the server. May be NULL if the server is not serving a * client right now. */ void logCurrentClient(client *cc, const char *title) { if (cc == NULL) return; @@ -2149,7 +2149,7 @@ static void killMainThread(void) { /* Kill the running threads (other than current) in an unclean way. This function * should be used only when it's critical to stop the threads for some reason. - * Currently Redis does this only on crash (for instance on SIGSEGV) in order + * Currently the server does this only on crash (for instance on SIGSEGV) in order * to perform a fast memory check without other threads messing with memory. */ void killThreads(void) { killMainThread(); diff --git a/src/dict.c b/src/dict.c index d2767939bc..dcde86845e 100644 --- a/src/dict.c +++ b/src/dict.c @@ -50,7 +50,7 @@ /* Using dictSetResizeEnabled() we make possible to disable * resizing and rehashing of the hash table as needed. This is very important - * for Redis, as we use copy-on-write and don't want to move too much memory + * for us, as we use copy-on-write and don't want to move too much memory * around when there is a child performing saving operations. * * Note that even when dict_can_resize is set to DICT_RESIZE_AVOID, not all diff --git a/src/endianconv.c b/src/endianconv.c index 9344c39ad6..212bdcb522 100644 --- a/src/endianconv.c +++ b/src/endianconv.c @@ -4,7 +4,7 @@ * defined into endianconv.h, this way we define everything is a non-operation * if the arch is already little endian. * - * Redis tries to encode everything as little endian (but a few things that need + * The server tries to encode everything as little endian (but a few things that need * to be backward compatible are still in big endian) because most of the * production environments are little endian, and we have a lot of conversions * in a few places because ziplists, intsets, zipmaps, need to be endian-neutral diff --git a/src/eval.c b/src/eval.c index 6542246803..587fb3b7af 100644 --- a/src/eval.c +++ b/src/eval.c @@ -80,7 +80,7 @@ dictType shaScriptObjectDictType = { /* Lua context */ struct luaCtx { lua_State *lua; /* The Lua interpreter. We use just one for all clients */ - client *lua_client; /* The "fake client" to query Redis from Lua */ + client *lua_client; /* The "fake client" to query the server from Lua */ dict *lua_scripts; /* A dictionary of SHA1 -> Lua scripts */ list *lua_scripts_lru_list; /* A list of SHA1, first in first out LRU eviction. */ unsigned long long lua_scripts_mem; /* Cached scripts' memory + oh */ @@ -94,7 +94,7 @@ struct ldbState { int active; /* Are we debugging EVAL right now? */ int forked; /* Is this a fork()ed debugging session? */ list *logs; /* List of messages to send to the client. */ - list *traces; /* Messages about Redis commands executed since last stop.*/ + list *traces; /* Messages about commands executed since last stop.*/ list *children; /* All forked debugging sessions pids. */ int bp[LDB_BREAKPOINTS_MAX]; /* An array of breakpoints line numbers. */ int bpcount; /* Number of valid entries inside bp. */ @@ -184,7 +184,7 @@ int luaRedisReplicateCommandsCommand(lua_State *lua) { * This function is called the first time at server startup with * the 'setup' argument set to 1. * - * It can be called again multiple times during the lifetime of the Redis + * It can be called again multiple times during the lifetime of the * process, with 'setup' set to 0, and following a scriptingRelease() call, * in order to reset the Lua scripting environment. * @@ -252,7 +252,7 @@ void scriptingInit(int setup) { lua_pcall(lua,0,0,0); } - /* Create the (non connected) client that we use to execute Redis commands + /* Create the (non connected) client that we use to execute server commands * inside the Lua interpreter. * Note: there is no need to create it again when this function is called * by scriptingReset(). */ @@ -285,7 +285,7 @@ void freeLuaScriptsSync(dict *lua_scripts, list *lua_scripts_lru_list, lua_State * using libc. libc may take a bit longer to return the memory to the OS, * so after lua_close, we call malloc_trim try to purge it earlier. * - * We do that only when Redis itself does not use libc. When Lua and Redis + * We do that only when the server itself does not use libc. When Lua and the server * use different allocators, one won't use the fragmentation holes of the * other, and released memory can take a long time until it is returned to * the OS. */ @@ -763,7 +763,7 @@ unsigned long evalScriptsMemory(void) { } /* --------------------------------------------------------------------------- - * LDB: Redis Lua debugging facilities + * LDB: Lua debugging facilities * ------------------------------------------------------------------------- */ /* Initialize Lua debugger data structures. */ @@ -860,7 +860,7 @@ void ldbSendLogs(void) { /* Start a debugging session before calling EVAL implementation. * The technique we use is to capture the client socket file descriptor, * in order to perform direct I/O with it from within Lua hooks. This - * way we don't have to re-enter Redis in order to handle I/O. + * way we don't have to re-enter the server in order to handle I/O. * * The function returns 1 if the caller should proceed to call EVAL, * and 0 if instead the caller should abort the operation (this happens @@ -1053,7 +1053,7 @@ sds *ldbReplParseCommand(int *argcp, char** err) { sds copy = sdsdup(ldb.cbuf); char *p = copy; - /* This Redis protocol parser is a joke... just the simplest thing that + /* This RESP parser is a joke... just the simplest thing that * works in this context. It is also very forgiving regarding broken * protocol. */ @@ -1244,7 +1244,7 @@ char *ldbRedisProtocolToHuman_Null(sds *o, char *reply); char *ldbRedisProtocolToHuman_Bool(sds *o, char *reply); char *ldbRedisProtocolToHuman_Double(sds *o, char *reply); -/* Get Redis protocol from 'reply' and appends it in human readable form to +/* Get RESP from 'reply' and appends it in human readable form to * the passed SDS string 'o'. * * Note that the SDS string is passed by reference (pointer of pointer to @@ -1267,7 +1267,7 @@ char *ldbRedisProtocolToHuman(sds *o, char *reply) { } /* The following functions are helpers for ldbRedisProtocolToHuman(), each - * take care of a given Redis return type. */ + * take care of a given RESP return type. */ char *ldbRedisProtocolToHuman_Int(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); @@ -1372,7 +1372,7 @@ char *ldbRedisProtocolToHuman_Double(sds *o, char *reply) { return p+2; } -/* Log a Redis reply as debugger output, in a human readable format. +/* Log a RESP reply as debugger output, in a human readable format. * If the resulting string is longer than 'len' plus a few more chars * used as prefix, it gets truncated. */ void ldbLogRedisReply(char *reply) { @@ -1515,9 +1515,9 @@ void ldbEval(lua_State *lua, sds *argv, int argc) { lua_pop(lua,1); } -/* Implement the debugger "redis" command. We use a trick in order to make +/* Implement the debugger "server" command. We use a trick in order to make * the implementation very simple: we just call the Lua redis.call() command - * implementation, with ldb.step enabled, so as a side effect the Redis command + * implementation, with ldb.step enabled, so as a side effect the command * and its reply are logged. */ void ldbRedis(lua_State *lua, sds *argv, int argc) { int j; diff --git a/src/evict.c b/src/evict.c index be8cfad75f..7b4937303c 100644 --- a/src/evict.c +++ b/src/evict.c @@ -102,7 +102,7 @@ unsigned long long estimateObjectIdleTime(robj *o) { /* LRU approximation algorithm * - * Redis uses an approximation of the LRU algorithm that runs in constant + * The server uses an approximation of the LRU algorithm that runs in constant * memory. Every time there is a key to expire, we sample N keys (with * N very small, usually in around 5) to populate a pool of best keys to * evict of M keys (the pool size is defined by EVPOOL_SIZE). @@ -436,7 +436,7 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev } /* Return 1 if used memory is more than maxmemory after allocating more memory, - * return 0 if not. Redis may reject user's requests or evict some keys if used + * return 0 if not. The server may reject user's requests or evict some keys if used * memory exceeds maxmemory, especially, when we allocate huge memory at once. */ int overMaxmemoryAfterAlloc(size_t moremem) { if (!server.maxmemory) return 0; /* No limit. */ @@ -517,10 +517,10 @@ static unsigned long evictionTimeLimitUs(void) { /* Check that memory usage is within the current "maxmemory" limit. If over * "maxmemory", attempt to free memory by evicting data (if it's safe to do so). * - * It's possible for Redis to suddenly be significantly over the "maxmemory" + * It's possible for the server to suddenly be significantly over the "maxmemory" * setting. This can happen if there is a large allocation (like a hash table * resize) or even if the "maxmemory" setting is manually adjusted. Because of - * this, it's important to evict for a managed period of time - otherwise Redis + * this, it's important to evict for a managed period of time - otherwise the server * would become unresponsive while evicting. * * The goal of this function is to improve the memory situation - not to diff --git a/src/expire.c b/src/expire.c index 4f0868d715..97b59a7871 100644 --- a/src/expire.c +++ b/src/expire.c @@ -46,7 +46,7 @@ static double avg_ttl_factor[16] = {0.98, 0.9604, 0.941192, 0.922368, 0.903921, /* Helper function for the activeExpireCycle() function. * This function will try to expire the key that is stored in the hash table - * entry 'de' of the 'expires' hash table of a Redis database. + * entry 'de' of the 'expires' hash table of a database. * * If the key is found to be expired, it is removed from the database and * 1 is returned. Otherwise no operation is performed and 0 is returned. @@ -259,7 +259,7 @@ void activeExpireCycle(int type) { /* Continue to expire if at the end of the cycle there are still * a big percentage of keys to expire, compared to the number of keys * we scanned. The percentage, stored in config_cycle_acceptable_stale - * is not fixed, but depends on the Redis configured "expire effort". */ + * is not fixed, but depends on the configured "expire effort". */ do { unsigned long num; iteration++; diff --git a/src/functions.c b/src/functions.c index bee5ce232b..b914288551 100644 --- a/src/functions.c +++ b/src/functions.c @@ -404,7 +404,7 @@ static int libraryJoin(functionsLibCtx *functions_lib_ctx_dst, functionsLibCtx * /* Register an engine, should be called once by the engine on startup and give the following: * * - engine_name - name of the engine to register - * - engine_ctx - the engine ctx that should be used by Redis to interact with the engine */ + * - engine_ctx - the engine ctx that should be used by the server to interact with the engine */ int functionsRegisterEngine(const char *engine_name, engine *engine) { sds engine_name_sds = sdsnew(engine_name); if (dictFetchValue(engines, engine_name_sds)) { diff --git a/src/functions.h b/src/functions.h index 5228560859..54712d0daf 100644 --- a/src/functions.h +++ b/src/functions.h @@ -31,7 +31,7 @@ #define __FUNCTIONS_H_ /* - * functions.c unit provides the Redis Functions API: + * functions.c unit provides the Functions API: * * FUNCTION LOAD * * FUNCTION LIST * * FUNCTION CALL (FCALL and FCALL_RO) @@ -68,7 +68,7 @@ typedef struct engine { int (*create)(void *engine_ctx, functionLibInfo *li, sds code, size_t timeout, sds *err); /* Invoking a function, r_ctx is an opaque object (from engine POV). - * The r_ctx should be used by the engine to interaction with Redis, + * The r_ctx should be used by the engine to interaction with the server, * such interaction could be running commands, set resp, or set * replication mode */ diff --git a/src/geo.c b/src/geo.c index 1004193e03..19266dce92 100644 --- a/src/geo.c +++ b/src/geo.c @@ -34,7 +34,7 @@ #include "pqsort.h" /* Things exported from t_zset.c only for geo.c, since it is the only other - * part of Redis that requires close zset introspection. */ + * part of the server that requires close zset introspection. */ unsigned char *zzlFirstInRange(unsigned char *zl, zrangespec *range); int zslValueLteMax(double value, zrangespec *spec); @@ -246,7 +246,7 @@ int geoWithinShape(GeoShape *shape, double score, double *xy, double *distance) return C_OK; } -/* Query a Redis sorted set to extract all the elements between 'min' and +/* Query a sorted set to extract all the elements between 'min' and * 'max', appending them into the array of geoPoint structures 'geoArray'. * The command returns the number of elements added to the array. * diff --git a/src/hyperloglog.c b/src/hyperloglog.c index 4f6f1eb454..beb5b179ac 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -1,5 +1,5 @@ -/* hyperloglog.c - Redis HyperLogLog probabilistic cardinality approximation. - * This file implements the algorithm and the exported Redis commands. +/* hyperloglog.c - HyperLogLog probabilistic cardinality approximation. + * This file implements the algorithm and the exported commands. * * Copyright (c) 2014, Salvatore Sanfilippo * All rights reserved. @@ -34,14 +34,14 @@ #include #include -/* The Redis HyperLogLog implementation is based on the following ideas: +/* The HyperLogLog implementation is based on the following ideas: * * * The use of a 64 bit hash function as proposed in [1], in order to estimate * cardinalities larger than 10^9, at the cost of just 1 additional bit per * register. * * The use of 16384 6-bit registers for a great level of accuracy, using * a total of 12k per key. - * * The use of the Redis string data type. No new type is introduced. + * * The use of the string data type. No new type is introduced. * * No attempt is made to compress the data structure as in [1]. Also the * algorithm used is the original HyperLogLog Algorithm as in [2], with * the only difference that a 64 bit hash function is used, so no correction @@ -53,7 +53,7 @@ * [2] P. Flajolet, Éric Fusy, O. Gandouet, and F. Meunier. Hyperloglog: The * analysis of a near-optimal cardinality estimation algorithm. * - * Redis uses two representations: + * We use two representations: * * 1) A "dense" representation where every entry is represented by * a 6-bit integer. @@ -88,7 +88,7 @@ * Dense representation * === * - * The dense representation used by Redis is the following: + * The dense representation is the following: * * +--------+--------+--------+------// //--+ * |11000000|22221111|33333322|55444444 .... | @@ -391,7 +391,7 @@ static char *invalid_hll_err = "-INVALIDOBJ Corrupted HLL object detected"; /* ========================= HyperLogLog algorithm ========================= */ /* Our hash function is MurmurHash2, 64 bit version. - * It was modified for Redis in order to provide the same result in + * It was modified in order to provide the same result in * big and little endian archs (endian neutral). */ REDIS_NO_SANITIZE("alignment") uint64_t MurmurHash64A (const void * key, int len, unsigned int seed) { @@ -520,7 +520,7 @@ int hllDenseAdd(uint8_t *registers, unsigned char *ele, size_t elesize) { void hllDenseRegHisto(uint8_t *registers, int* reghisto) { int j; - /* Redis default is to use 16384 registers 6 bits each. The code works + /* Default is to use 16384 registers 6 bits each. The code works * with other values by modifying the defines, but for our target value * we take a faster path with unrolled loops. */ if (HLL_REGISTERS == 16384 && HLL_BITS == 6) { @@ -1271,7 +1271,7 @@ void pfcountCommand(client *c) { * The user specified a single key. Either return the cached value * or compute one and update the cache. * - * Since a HLL is a regular Redis string type value, updating the cache does + * Since a HLL is a regular string type value, updating the cache does * modify the value. We do a lookupKeyRead anyway since this is flagged as a * read-only command. The difference is that with lookupKeyWrite, a * logically expired key on a replica is deleted, while with lookupKeyRead @@ -1315,7 +1315,7 @@ void pfcountCommand(client *c) { hdr->card[6] = (card >> 48) & 0xff; hdr->card[7] = (card >> 56) & 0xff; /* This is considered a read-only command even if the cached value - * may be modified and given that the HLL is a Redis string + * may be modified and given that the HLL is a string * we need to propagate the change. */ signalModifiedKey(c,c->db,c->argv[1]); server.dirty++; diff --git a/src/kvstore.c b/src/kvstore.c index acfe62bb85..b3b166a0aa 100644 --- a/src/kvstore.c +++ b/src/kvstore.c @@ -4,7 +4,7 @@ * The purpose of this KV store is to have easy access to all keys that belong * in the same dict (i.e. are in the same dict-index) * - * For example, when Redis is running in cluster mode, we use kvstore to save + * For example, when the server is running in cluster mode, we use kvstore to save * all keys that map to the same hash-slot in a separate dict within the kvstore * struct. * This enables us to easily access all keys that map to a specific hash-slot. diff --git a/src/latency.c b/src/latency.c index b5ec6e3823..d900011c8f 100644 --- a/src/latency.c +++ b/src/latency.c @@ -1,5 +1,5 @@ /* The latency monitor allows to easily observe the sources of latency - * in a Redis instance using the LATENCY command. Different latency + * in an instance using the LATENCY command. Different latency * sources are monitored, like disk I/O, execution of commands, fork * system call, and so forth. * @@ -198,7 +198,7 @@ void analyzeLatencyForEvent(char *event, struct latencyStats *ls) { if (ls->samples) ls->mad = sum / ls->samples; } -/* Create a human readable report of latency events for this Redis instance. */ +/* Create a human readable report of latency events for this instance. */ sds createLatencyReport(void) { sds report = sdsempty(); int advise_better_vm = 0; /* Better virtual machines. */ diff --git a/src/lazyfree.c b/src/lazyfree.c index 4733d8f99a..22fa2dc863 100644 --- a/src/lazyfree.c +++ b/src/lazyfree.c @@ -172,7 +172,7 @@ void freeObjAsync(robj *key, robj *obj, int dbid) { size_t free_effort = lazyfreeGetFreeEffort(key,obj,dbid); /* Note that if the object is shared, to reclaim it now it is not * possible. This rarely happens, however sometimes the implementation - * of parts of the Redis core may call incrRefCount() to protect + * of parts of the server core may call incrRefCount() to protect * objects, and then call dbDelete(). */ if (free_effort > LAZYFREE_THRESHOLD && obj->refcount == 1) { atomicIncr(lazyfree_objects,1); @@ -182,7 +182,7 @@ void freeObjAsync(robj *key, robj *obj, int dbid) { } } -/* Empty a Redis DB asynchronously. What the function does actually is to +/* Empty a DB asynchronously. What the function does actually is to * create a new empty set of hash tables and scheduling the old ones for * lazy freeing. */ void emptyDbAsync(serverDb *db) { diff --git a/src/listpack.c b/src/listpack.c index 27becc9faa..8816a663cb 100644 --- a/src/listpack.c +++ b/src/listpack.c @@ -165,7 +165,7 @@ int lpSafeToAdd(unsigned char* lp, size_t add) { * * ----------------------------------------------------------------------------- * - * Credits: this function was adapted from the Redis source code, file + * Credits: this function was adapted from the Redis OSS source code, file * "utils.c", function string2ll(), and is copyright: * * Copyright(C) 2011, Pieter Noordhuis diff --git a/src/localtime.c b/src/localtime.c index 1cefdfa88c..da2d6c9d09 100644 --- a/src/localtime.c +++ b/src/localtime.c @@ -31,9 +31,9 @@ /* This is a safe version of localtime() which contains no locks and is * fork() friendly. Even the _r version of localtime() cannot be used safely - * in Redis. Another thread may be calling localtime() while the main thread + * in the server. Another thread may be calling localtime() while the main thread * forks(). Later when the child process calls localtime() again, for instance - * in order to log something to the Redis log, it may deadlock: in the copy + * in order to log something to the server log, it may deadlock: in the copy * of the address space of the forked process the lock will never be released. * * This function takes the timezone 'tz' as argument, and the 'dst' flag is @@ -47,7 +47,7 @@ * should be refreshed at safe times. * * Note that this function does not work for dates < 1/1/1970, it is solely - * designed to work with what time(NULL) may return, and to support Redis + * designed to work with what time(NULL) may return, and to support server * logging of the dates, it's not really a complete implementation. */ static int is_leap_year(time_t year) { if (year % 4) return 0; /* A year not divisible by 4 is not leap. */ diff --git a/src/lolwut.c b/src/lolwut.c index eca98cf18e..268353898d 100644 --- a/src/lolwut.c +++ b/src/lolwut.c @@ -30,7 +30,7 @@ * * This file implements the LOLWUT command. The command should do something * fun and interesting, and should be replaced by a new implementation at - * each new version of Redis. + * each new version of the server. */ #include "server.h" @@ -41,7 +41,7 @@ void lolwut5Command(client *c); void lolwut6Command(client *c); /* The default target for LOLWUT if no matching version was found. - * This is what unstable versions of Redis will display. */ + * This is what unstable versions of the server will display. */ void lolwutUnstableCommand(client *c) { sds rendered = sdsnew("Redis ver. "); rendered = sdscat(rendered,VALKEY_VERSION); diff --git a/src/lolwut5.c b/src/lolwut5.c index d293e77d97..b7d4c77d71 100644 --- a/src/lolwut5.c +++ b/src/lolwut5.c @@ -30,7 +30,7 @@ * * This file implements the LOLWUT command. The command should do something * fun and interesting, and should be replaced by a new implementation at - * each new version of Redis. + * each new version of the server. */ #include "server.h" @@ -61,7 +61,7 @@ void lwTranslatePixelsGroup(int byte, char *output) { output[2] = 0x80 | (code & 0x3F); /* 10-xxxxxx */ } -/* Schotter, the output of LOLWUT of Redis 5, is a computer graphic art piece +/* Schotter, the output of LOLWUT of Redis OSS 5, is a computer graphic art piece * generated by Georg Nees in the 60s. It explores the relationship between * caos and order. * diff --git a/src/lolwut6.c b/src/lolwut6.c index 440dba9660..4e59c68703 100644 --- a/src/lolwut6.c +++ b/src/lolwut6.c @@ -30,7 +30,7 @@ * * This file implements the LOLWUT command. The command should do something * fun and interesting, and should be replaced by a new implementation at - * each new version of Redis. + * each new version of the server. * * Thanks to Michele Hiki Falcone for the original image that inspired * the image, part of his game, Plaguemon. diff --git a/src/module.c b/src/module.c index 281b1ee903..d43feba28f 100644 --- a/src/module.c +++ b/src/module.c @@ -31,7 +31,7 @@ * Modules API documentation information * * The comments in this file are used to generate the API documentation on the - * Redis website. + * website. * * Each function starting with VM_ and preceded by a block comment is included * in the API documentation. To hide a VM_ function, put a blank line between @@ -69,7 +69,7 @@ /* -------------------------------------------------------------------------- * Private data structures used by the modules system. Those are data - * structures that are never exposed to Redis Modules, if not as void + * structures that are never exposed to Modules, if not as void * pointers that have an API the module can call with them) * -------------------------------------------------------------------------- */ @@ -109,7 +109,7 @@ struct AutoMemEntry { #define VALKEYMODULE_AM_DICT 4 #define VALKEYMODULE_AM_INFO 5 -/* The pool allocator block. Redis Modules can allocate memory via this special +/* The pool allocator block. Modules can allocate memory via this special * allocator that will automatically release it all once the callback returns. * This means that it can only be used for ephemeral allocations. However * there are two advantages for modules to use this API: @@ -132,7 +132,7 @@ typedef struct ValkeyModulePoolAllocBlock { char memory[]; } ValkeyModulePoolAllocBlock; -/* This structure represents the context in which Redis modules operate. +/* This structure represents the context in which modules operate. * Most APIs module can access, get a pointer to the context, so that the API * implementation can hold state across calls, or remember what to free after * the call and so forth. @@ -187,7 +187,7 @@ typedef struct ValkeyModuleCtx ValkeyModuleCtx; #define VALKEYMODULE_CTX_COMMAND (1<<9) /* Context created to serve a command from call() or AOF (which calls cmd->proc directly) */ -/* This represents a Redis key opened with VM_OpenKey(). */ +/* This represents a key opened with VM_OpenKey(). */ struct ValkeyModuleKey { ValkeyModuleCtx *ctx; serverDb *db; @@ -229,7 +229,7 @@ struct ValkeyModuleKey { #define VALKEYMODULE_ZSET_RANGE_POS 3 /* Function pointer type of a function representing a command inside - * a Redis module. */ + * a module. */ struct ValkeyModuleBlockedClient; typedef int (*ValkeyModuleCmdFunc) (ValkeyModuleCtx *ctx, void **argv, int argc); typedef int (*ValkeyModuleAuthCallback)(ValkeyModuleCtx *ctx, void *username, void *password, ValkeyModuleString **err); @@ -399,15 +399,15 @@ typedef struct ValkeyModuleServerInfoData { #define VALKEYMODULE_ARGV_DRY_RUN (1<<10) #define VALKEYMODULE_ARGV_ALLOW_BLOCK (1<<11) -/* Determine whether Redis should signalModifiedKey implicitly. +/* Determine whether the server should signalModifiedKey implicitly. * In case 'ctx' has no 'module' member (and therefore no module->options), - * we assume default behavior, that is, Redis signals. + * we assume default behavior, that is, the server signals. * (see VM_GetThreadSafeContext) */ #define SHOULD_SIGNAL_MODIFIED_KEYS(ctx) \ ((ctx)->module? !((ctx)->module->options & VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) : 1) /* Server events hooks data structures and defines: this modules API - * allow modules to subscribe to certain events in Redis, such as + * allow modules to subscribe to certain events in the server, such as * the start and end of an RDB or AOF save, the change of role in replication, * and similar other events. */ @@ -419,13 +419,13 @@ typedef struct ValkeyModuleEventListener { list *ValkeyModule_EventListeners; /* Global list of all the active events. */ -/* Data structures related to the redis module users */ +/* Data structures related to the module users */ /* This is the object returned by VM_CreateModuleUser(). The module API is * able to create users, set ACLs to such users, and later authenticate * clients using such newly created users. */ typedef struct ValkeyModuleUser { - user *user; /* Reference to the real redis user */ + user *user; /* Reference to the real user */ int free_user; /* Indicates that user should also be freed when this object is freed */ } ValkeyModuleUser; @@ -439,7 +439,7 @@ typedef struct ValkeyModuleKeyOptCtx { as `copy2`, 'from_dbid' and 'to_dbid' are both valid. */ } ValkeyModuleKeyOptCtx; -/* Data structures related to redis module configurations */ +/* Data structures related to module configurations */ /* The function signatures for module config get callbacks. These are identical to the ones exposed in valkeymodule.h. */ typedef ValkeyModuleString * (*ValkeyModuleConfigGetStringFunc)(const char *name, void *privdata); typedef long long (*ValkeyModuleConfigGetNumericFunc)(const char *name, void *privdata); @@ -513,13 +513,13 @@ int moduleVerifyResourceName(const char *name); /* -------------------------------------------------------------------------- * ## Heap allocation raw functions * - * Memory allocated with these functions are taken into account by Redis key - * eviction algorithms and are reported in Redis memory usage information. + * Memory allocated with these functions are taken into account by key + * eviction algorithms and are reported in memory usage information. * -------------------------------------------------------------------------- */ /* Use like malloc(). Memory allocated with this function is reported in - * Redis INFO memory, used for keys eviction according to maxmemory settings - * and in general is taken into account as memory allocated by Redis. + * INFO memory, used for keys eviction according to maxmemory settings + * and in general is taken into account as memory allocated by the server. * You should avoid using malloc(). * This function panics if unable to allocate enough memory. */ void *VM_Alloc(size_t bytes) { @@ -540,8 +540,8 @@ void *VM_TryAlloc(size_t bytes) { } /* Use like calloc(). Memory allocated with this function is reported in - * Redis INFO memory, used for keys eviction according to maxmemory settings - * and in general is taken into account as memory allocated by Redis. + * INFO memory, used for keys eviction according to maxmemory settings + * and in general is taken into account as memory allocated by the server. * You should avoid using calloc() directly. */ void *VM_Calloc(size_t nmemb, size_t size) { return zcalloc_usable(nmemb*size,NULL); @@ -848,7 +848,7 @@ void moduleFreeContext(ValkeyModuleCtx *ctx) { } static CallReply *moduleParseReply(client *c, ValkeyModuleCtx *ctx) { - /* Convert the result of the Redis command into a module reply. */ + /* Convert the result of the command into a module reply. */ sds proto = sdsnewlen(c->buf,c->bufpos); c->bufpos = 0; while(listLength(c->reply)) { @@ -923,7 +923,7 @@ void moduleCreateContext(ValkeyModuleCtx *out_ctx, ValkeyModule *module, int ctx } } -/* This Redis command binds the normal Redis command invocation with commands +/* This command binds the normal command invocation with commands * exported by modules. */ void ValkeyModuleCommandDispatcher(client *c) { ValkeyModuleCommand *cp = c->cmd->module_cmd; @@ -940,7 +940,7 @@ void ValkeyModuleCommandDispatcher(client *c) { * the client argument vectors: sometimes this will result in the SDS * string having unused space at the end. Later if a module takes ownership * of the RedisString, such space will be wasted forever. Inside the - * Redis core this is not a problem because tryObjectEncoding() is called + * server core this is not a problem because tryObjectEncoding() is called * before storing strings in the key space. Here we need to do it * for the module. */ for (int i = 0; i < c->argc; i++) { @@ -999,7 +999,7 @@ int moduleGetCommandChannelsViaAPI(struct serverCommand *cmd, robj **argv, int a /* -------------------------------------------------------------------------- * ## Commands API * - * These functions are used to implement custom Redis commands. + * These functions are used to implement custom commands. * * For examples, see https://redis.io/topics/modules-intro. * -------------------------------------------------------------------------- */ @@ -1076,8 +1076,8 @@ int VM_IsChannelsPositionRequest(ValkeyModuleCtx *ctx) { * * VALKEYMODULE_CMD_CHANNEL_PUBLISH: This command will publish to this channel. * * VALKEYMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any * channel specified by the pattern. This is the same access - * used by the PSUBSCRIBE and PUNSUBSCRIBE commands available - * in Redis. Not intended to be used with PUBLISH permissions. + * used by the PSUBSCRIBE and PUNSUBSCRIBE commands. + * Not intended to be used with PUBLISH permissions. * * The following is an example of how it could be used: * @@ -1134,7 +1134,7 @@ int isCommandNameValid(const char *name) { } /* Helper for VM_CreateCommand(). Turns a string representing command - * flags into the command flags used by the Redis core. + * flags into the command flags used by the server core. * * It returns the set of flags, or -1 if unknown flags are found. */ int64_t commandFlagsFromString(char *s) { @@ -1172,7 +1172,7 @@ int64_t commandFlagsFromString(char *s) { ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds declared_name, sds fullname, ValkeyModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep); -/* Register a new command in the Redis server, that will be handled by +/* Register a new command in the server, that will be handled by * calling the function pointer 'cmdfunc' using the ValkeyModule calling * convention. * @@ -1213,7 +1213,7 @@ ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds d * * **"pubsub"**: The command publishes things on Pub/Sub channels. * * **"random"**: The command may have different outputs even starting * from the same input arguments and key values. - * Starting from Redis 7.0 this flag has been deprecated. + * Starting from Redis OSS 7.0 this flag has been deprecated. * Declaring a command as "random" can be done using * command tips, see https://redis.io/topics/command-tips. * * **"allow-stale"**: The command is allowed to run on slaves that don't @@ -1230,7 +1230,7 @@ ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds d * * **"getkeys-api"**: The command implements the interface to return * the arguments that are keys. Used when start/stop/step * is not enough because of the command syntax. - * * **"no-cluster"**: The command should not register in Redis Cluster + * * **"no-cluster"**: The command should not register in Cluster * since is not designed to work with it because, for * example, is unable to report the position of the * keys, programmatically creates key names, or any @@ -1249,7 +1249,7 @@ ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds d * the arguments that are channels. * * The last three parameters specify which arguments of the new command are - * Redis keys. See https://redis.io/commands/command for more information. + * keys. See https://valkey.io/commands/command for more information. * * * `firstkey`: One-based index of the first argument that's a key. * Position 0 is always the command name itself. @@ -1267,7 +1267,7 @@ ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds d * only be used to find keys that exist at constant indices. * For non-trivial key arguments, you may pass 0,0,0 and use * ValkeyModule_SetCommandInfo to set key specs using a more advanced scheme and use - * ValkeyModule_SetCommandACLCategories to set Redis ACL categories of the commands. */ + * ValkeyModule_SetCommandACLCategories to set ACL categories of the commands. */ int VM_CreateCommand(ValkeyModuleCtx *ctx, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!ctx->module->onload) return VALKEYMODULE_ERR; @@ -1307,7 +1307,7 @@ ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds d /* Create a command "proxy", which is a structure that is referenced * in the command table, so that the generic command that works as - * binding between modules and Redis, can know what function to call + * binding between modules and the server, can know what function to call * and what the module is. */ cp = zcalloc(sizeof(*cp)); cp->module = module; @@ -1518,7 +1518,7 @@ int matchAclCategoryFlag(char *flag, int64_t *acl_categories_flags) { } /* Helper for VM_SetCommandACLCategories(). Turns a string representing acl category - * flags into the acl category flags used by Redis ACL which allows users to access + * flags into the acl category flags used by the server ACL which allows users to access * the module commands by acl categories. * * It returns the set of acl flags, or -1 if unknown flags are found. */ @@ -1584,7 +1584,7 @@ int VM_SetCommandACLCategories(ValkeyModuleCommand *command, const char *aclflag * * All fields except `version` are optional. Explanation of the fields: * - * - `version`: This field enables compatibility with different Redis versions. + * - `version`: This field enables compatibility with different server versions. * Always set this field to VALKEYMODULE_COMMAND_INFO_VERSION. * * - `summary`: A short description of the command (optional). @@ -1592,7 +1592,7 @@ int VM_SetCommandACLCategories(ValkeyModuleCommand *command, const char *aclflag * - `complexity`: Complexity description (optional). * * - `since`: The version where the command was introduced (optional). - * Note: The version specified should be the module's, not Redis version. + * Note: The version specified should be the module's, not the server version. * * - `history`: An array of ValkeyModuleCommandHistoryEntry (optional), which is * a struct with the following fields: @@ -1609,7 +1609,7 @@ int VM_SetCommandACLCategories(ValkeyModuleCommand *command, const char *aclflag * * - `arity`: Number of arguments, including the command name itself. A positive * number specifies an exact number of arguments and a negative number - * specifies a minimum number of arguments, so use -N to say >= N. Redis + * specifies a minimum number of arguments, so use -N to say >= N. The server * validates a call before passing it to a module, so this can replace an * arity check inside the module command implementation. A value of 0 (or an * omitted arity field) is equivalent to -2 if the command has sub commands @@ -1626,7 +1626,7 @@ int VM_SetCommandACLCategories(ValkeyModuleCommand *command, const char *aclflag * * Key-specs cause the triplet (firstkey, lastkey, keystep) given in * VM_CreateCommand to be recomputed, but it is still useful to provide - * these three parameters in VM_CreateCommand, to better support old Redis + * these three parameters in VM_CreateCommand, to better support old server * versions where VM_SetCommandInfo is not available. * * Note that key-specs don't fully replace the "getkeys-api" (see @@ -2283,7 +2283,7 @@ void moduleListFree(void *config) { void VM_SetModuleAttribs(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) { /* Called by VM_Init() to setup the `ctx->module` structure. * - * This is an internal function, Redis modules developers don't need + * This is an internal function, module developers don't need * to use it. */ ValkeyModule *module; @@ -2376,21 +2376,21 @@ int VM_BlockedClientMeasureTimeEnd(ValkeyModuleBlockedClient *bc) { return VALKEYMODULE_OK; } -/* This API allows modules to let Redis process background tasks, and some +/* This API allows modules to let the server process background tasks, and some * commands during long blocking execution of a module command. * The module can call this API periodically. * The flags is a bit mask of these: * * - `VALKEYMODULE_YIELD_FLAG_NONE`: No special flags, can perform some background * operations, but not process client commands. - * - `VALKEYMODULE_YIELD_FLAG_CLIENTS`: Redis can also process client commands. + * - `VALKEYMODULE_YIELD_FLAG_CLIENTS`: The server can also process client commands. * * The `busy_reply` argument is optional, and can be used to control the verbose * error string after the `-BUSY` error code. * - * When the `VALKEYMODULE_YIELD_FLAG_CLIENTS` is used, Redis will only start + * When the `VALKEYMODULE_YIELD_FLAG_CLIENTS` is used, the server will only start * processing client commands after the time defined by the - * `busy-reply-threshold` config, in which case Redis will start rejecting most + * `busy-reply-threshold` config, in which case the server will start rejecting most * commands with `-BUSY` error, but allow the ones marked with the `allow-busy` * flag to be executed. * This API can also be used in thread safe context (while locked), and during @@ -2407,10 +2407,10 @@ void VM_Yield(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) { long long now = getMonotonicUs(); if (now >= ctx->next_yield_time) { /* In loading mode, there's no need to handle busy_module_yield_reply, - * and busy_module_yield_flags, since redis is anyway rejecting all + * and busy_module_yield_flags, since the server is anyway rejecting all * commands with -LOADING. */ if (server.loading) { - /* Let redis process events */ + /* Let the server process events */ processEventsWhileBlocked(); } else { const char *prev_busy_module_yield_reply = server.busy_module_yield_reply; @@ -2425,7 +2425,7 @@ void VM_Yield(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) { if (flags & VALKEYMODULE_YIELD_FLAG_CLIENTS) server.busy_module_yield_flags |= BUSY_MODULE_YIELD_CLIENTS; - /* Let redis process events */ + /* Let the server process events */ if (!pthread_equal(server.main_thread_id, pthread_self())) { /* If we are not in the main thread, we defer event loop processing to the main thread * after the main thread enters acquiring GIL state in order to protect the event @@ -2482,11 +2482,11 @@ void VM_Yield(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) { * * VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD: * Setting this flag indicates module awareness of diskless async replication (repl-diskless-load=swapdb) - * and that redis could be serving reads during replication instead of blocking with LOADING status. + * and that the server could be serving reads during replication instead of blocking with LOADING status. * * VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS: * Declare that the module wants to get nested key-space notifications. - * By default, Redis will not fire key-space notifications that happened inside + * By default, the server will not fire key-space notifications that happened inside * a key-space notification callback. This flag allows to change this behavior * and fire nested key-space notifications. Notice: if enabled, the module * should protected itself from infinite recursion. */ @@ -2516,7 +2516,7 @@ int VM_SignalModifiedKey(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) { * that wants to use automatic memory. * * When enabled, automatic memory management tracks and automatically frees - * keys, call replies and Redis string objects once the command returns. In most + * keys, call replies and RedisModuleString objects once the command returns. In most * cases this eliminates the need of calling the following functions: * * 1. ValkeyModule_CloseKey() @@ -2725,7 +2725,7 @@ ValkeyModuleString *VM_CreateStringFromStreamID(ValkeyModuleCtx *ctx, const Valk return o; } -/* Free a module string object obtained with one of the Redis modules API calls +/* Free a module string object obtained with one of the module API calls * that return new string objects. * * It is possible to call this function even when automatic memory management @@ -2984,11 +2984,11 @@ int VM_StringAppendBuffer(ValkeyModuleCtx *ctx, ValkeyModuleString *str, const c * string in a module command before the string is potentially available * to other threads is generally safe. * - * Currently, Redis may also automatically trim retained strings when a + * Currently, the server may also automatically trim retained strings when a * module command returns. However, doing this explicitly should still be * a preferred option: * - * 1. Future versions of Redis may abandon auto-trimming. + * 1. Future versions of the server may abandon auto-trimming. * 2. Auto-trimming as currently implemented is *not thread safe*. * A background thread manipulating a recently retained string may end up * in a race condition with the auto-trim, which could result with @@ -3452,7 +3452,7 @@ int VM_ReplyWithBool(ValkeyModuleCtx *ctx, int b) { return VALKEYMODULE_OK; } -/* Reply exactly what a Redis command returned us with ValkeyModule_Call(). +/* Reply exactly what a command returned us with ValkeyModule_Call(). * This function is useful when we use ValkeyModule_Call() in order to * execute some command, as we want to reply to the client exactly the * same reply we obtained by the command. @@ -3565,8 +3565,8 @@ int VM_ReplyWithLongDouble(ValkeyModuleCtx *ctx, long double ld) { * #### Note about calling this function from a thread safe context: * * Normally when you call this function from the callback implementing a - * module command, or any other callback provided by the Redis Module API, - * Redis will accumulate all the calls to this function in the context of + * module command, or any other callback provided by the Module API, + * The server will accumulate all the calls to this function in the context of * the callback, and will propagate all the commands wrapped in a MULTI/EXEC * transaction. However when calling this function from a threaded safe context * that can live an undefined amount of time, and can be locked/unlocked in @@ -3838,7 +3838,7 @@ int VM_GetSelectedDb(ValkeyModuleCtx *ctx) { /* Return the current context's flags. The flags provide information on the * current request context (whether the client is a Lua script or in a MULTI), - * and about the Redis instance in general, i.e replication and persistence. + * and about the instance in general, i.e replication and persistence. * * It is possible to call this function even with a NULL context, however * in this case the following flags will not be reported: @@ -3854,15 +3854,15 @@ int VM_GetSelectedDb(ValkeyModuleCtx *ctx) { * * VALKEYMODULE_CTX_FLAGS_REPLICATED: The command was sent over the replication * link by the MASTER * - * * VALKEYMODULE_CTX_FLAGS_PRIMARY: The Redis instance is a primary + * * VALKEYMODULE_CTX_FLAGS_PRIMARY: The instance is a primary * - * * VALKEYMODULE_CTX_FLAGS_REPLICA: The Redis instance is a replica + * * VALKEYMODULE_CTX_FLAGS_REPLICA: The instance is a replica * - * * VALKEYMODULE_CTX_FLAGS_READONLY: The Redis instance is read-only + * * VALKEYMODULE_CTX_FLAGS_READONLY: The instance is read-only * - * * VALKEYMODULE_CTX_FLAGS_CLUSTER: The Redis instance is in cluster mode + * * VALKEYMODULE_CTX_FLAGS_CLUSTER: The instance is in cluster mode * - * * VALKEYMODULE_CTX_FLAGS_AOF: The Redis instance has AOF enabled + * * VALKEYMODULE_CTX_FLAGS_AOF: The instance has AOF enabled * * * VALKEYMODULE_CTX_FLAGS_RDB: The instance has RDB enabled * @@ -3871,7 +3871,7 @@ int VM_GetSelectedDb(ValkeyModuleCtx *ctx) { * * VALKEYMODULE_CTX_FLAGS_EVICT: Maxmemory is set and has an eviction * policy that may delete keys * - * * VALKEYMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the + * * VALKEYMODULE_CTX_FLAGS_OOM: The server is out of memory according to the * maxmemory setting. * * * VALKEYMODULE_CTX_FLAGS_OOM_WARNING: Less than 25% of memory remains before @@ -3897,13 +3897,13 @@ int VM_GetSelectedDb(ValkeyModuleCtx *ctx) { * * VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY: The next EXEC will fail due to dirty * CAS (touched keys). * - * * VALKEYMODULE_CTX_FLAGS_IS_CHILD: Redis is currently running inside + * * VALKEYMODULE_CTX_FLAGS_IS_CHILD: The server is currently running inside * background child process. * * * VALKEYMODULE_CTX_FLAGS_RESP3: Indicate the that client attached to this * context is using RESP3. * - * * VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP: The Redis instance is starting + * * VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP: The instance is starting */ int VM_GetContextFlags(ValkeyModuleCtx *ctx) { int flags = 0; @@ -3989,7 +3989,7 @@ int VM_GetContextFlags(ValkeyModuleCtx *ctx) { if (hasActiveChildProcess()) flags |= VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD; if (server.in_fork_child) flags |= VALKEYMODULE_CTX_FLAGS_IS_CHILD; - /* Non-empty server.loadmodule_queue means that Redis is starting. */ + /* Non-empty server.loadmodule_queue means that the server is starting. */ if (listLength(server.loadmodule_queue) > 0) flags |= VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP; @@ -3997,7 +3997,7 @@ int VM_GetContextFlags(ValkeyModuleCtx *ctx) { } /* Returns true if a client sent the CLIENT PAUSE command to the server or - * if Redis Cluster does a manual failover, pausing the clients. + * if the Cluster does a manual failover, pausing the clients. * This is needed when we have a master with replicas, and want to write, * without adding further data to the replication channel, that the replicas * replication offset, match the one of the master. When this happens, it is @@ -4024,7 +4024,7 @@ int VM_AvoidReplicaTraffic(void) { * is out of range. * * Note that the client will retain the currently selected DB even after - * the Redis command implemented by the module calling this function + * the command implemented by the module calling this function * returns. * * If the module command wishes to change something in a different DB and @@ -4066,7 +4066,7 @@ static void moduleInitKeyTypeSpecific(ValkeyModuleKey *key) { } } -/* Return a handle representing a Redis key, so that it is possible +/* Return a handle representing a key, so that it is possible * to call other APIs with the key handle as argument to perform * operations on the key. * @@ -4116,7 +4116,7 @@ ValkeyModuleKey *VM_OpenKey(ValkeyModuleCtx *ctx, robj *keyname, int mode) { /** * Returns the full OpenKey modes mask, using the return value * the module can check if a certain set of OpenKey modes are supported - * by the redis server version in use. + * by the server version in use. * Example: * * int supportedMode = VM_GetOpenKeyModesAll(); @@ -4524,7 +4524,7 @@ int moduleListIteratorSeek(ValkeyModuleKey *key, long index, int mode) { * - ENOTSUP if the key is of another type than list. * - EBADF if the key is not opened for writing. * - * Note: Before Redis 7.0, `errno` was not set by this function. */ + * Note: Before Redis OSS 7.0, `errno` was not set by this function. */ int VM_ListPush(ValkeyModuleKey *key, int where, ValkeyModuleString *ele) { if (!key || !ele) { errno = EINVAL; @@ -4558,7 +4558,7 @@ int VM_ListPush(ValkeyModuleKey *key, int where, ValkeyModuleString *ele) { * - ENOTSUP if the key is empty or of another type than list. * - EBADF if the key is not opened for writing. * - * Note: Before Redis 7.0, `errno` was not set by this function. */ + * Note: Before Redis OSS 7.0, `errno` was not set by this function. */ ValkeyModuleString *VM_ListPop(ValkeyModuleKey *key, int where) { if (!key) { errno = EINVAL; @@ -4976,7 +4976,7 @@ int VM_ZsetLastInScoreRange(ValkeyModuleKey *key, double min, double max, int mi * VALKEYMODULE_ERR. * * Note that this function takes 'min' and 'max' in the same form of the - * Redis ZRANGEBYLEX command. */ + * ZRANGEBYLEX command. */ int zsetInitLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max, int first) { if (!key->value || key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; @@ -5225,7 +5225,7 @@ int VM_ZsetRangePrev(ValkeyModuleKey *key) { * strings instead of ValkeyModuleString objects. * VALKEYMODULE_HASH_COUNT_ALL: Include the number of inserted fields in the * returned number, in addition to the number of - * updated and deleted fields. (Added in Redis + * updated and deleted fields. (Added in Redis OSS * 6.2.) * * Unless NX is specified, the command overwrites the old field value with @@ -5245,7 +5245,7 @@ int VM_ZsetRangePrev(ValkeyModuleKey *key) { * flag VALKEYMODULE_HASH_COUNT_ALL is set, inserted fields not previously * existing in the hash are also counted. * - * If the return value is zero, `errno` is set (since Redis 6.2) as follows: + * If the return value is zero, `errno` is set (since Redis OSS 6.2) as follows: * * - EINVAL if any unknown flags are set or if key is NULL. * - ENOTSUP if the key is associated with a non Hash value. @@ -5256,8 +5256,8 @@ int VM_ZsetRangePrev(ValkeyModuleKey *key) { * back due to the NX and XX flags. * * NOTICE: The return value semantics of this function are very different - * between Redis 6.2 and older versions. Modules that use it should determine - * the Redis version and handle it accordingly. + * between Redis OSS 6.2 and older versions. Modules that use it should determine + * the server version and handle it accordingly. */ int VM_HashSet(ValkeyModuleKey *key, int flags, ...) { va_list ap; @@ -5891,9 +5891,9 @@ long long VM_StreamTrimByID(ValkeyModuleKey *key, int flags, ValkeyModuleStreamI } /* -------------------------------------------------------------------------- - * ## Calling Redis commands from modules + * ## Calling commands from modules * - * VM_Call() sends a command to Redis. The remaining functions handle the reply. + * VM_Call() sends a command to the server. The remaining functions handle the reply. * -------------------------------------------------------------------------- */ @@ -6043,7 +6043,7 @@ void VM_CallReplyPromiseSetUnblockHandler(ValkeyModuleCallReply *reply, ValkeyMo * If the execution was aborted successfully, it is promised that the unblock handler will not be called. * That said, it is possible that the abort operation will successes but the operation will still continue. * This can happened if, for example, a module implements some blocking command and does not respect the - * disconnect callback. For pure Redis commands this can not happened.*/ + * disconnect callback. For server-provided commands this can not happened.*/ int VM_CallReplyPromiseAbort(ValkeyModuleCallReply *reply, void **private_data) { ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); if (!promise->c) return VALKEYMODULE_ERR; /* Promise can not be aborted, either already aborted or already finished. */ @@ -6197,9 +6197,9 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int return NULL; } -/* Exported API to call any Redis command from modules. +/* Exported API to call any command from modules. * - * * **cmdname**: The Redis command to call. + * * **cmdname**: The command to call. * * **fmt**: A format specifier string for the command's arguments. Each * of the arguments should be specified by a valid type specification. The * format specifier can also contain the modifiers `!`, `A`, `3` and `R` which @@ -6211,7 +6211,7 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * * `l` -- The argument is a `long long` integer. * * `s` -- The argument is a ValkeyModuleString. * * `v` -- The argument(s) is a vector of ValkeyModuleString. - * * `!` -- Sends the Redis command and its arguments to replicas and AOF. + * * `!` -- Sends the command and its arguments to replicas and AOF. * * `A` -- Suppress AOF propagation, send only to replicas (requires `!`). * * `R` -- Suppress replicas propagation, send only to AOF (requires `!`). * * `3` -- Return a RESP3 reply. This will change the command reply. @@ -6229,7 +6229,7 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * the command to run as the determined user, so that any future user * dependent activity, such as ACL checks within scripts will proceed as * expected. - * Otherwise, the command will run as the Redis unrestricted user. + * Otherwise, the command will run as the unrestricted user. * * `S` -- Run the command in a script mode, this means that it will raise * an error if a command which are not allowed inside a script * (flagged with the `deny-script` flag) is invoked (like SHUTDOWN). @@ -6252,7 +6252,7 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * The module can use this reply object to set a handler which will be called when * the command gets unblocked using ValkeyModule_CallReplyPromiseSetUnblockHandler. * The handler must be set immediately after the command invocation (without releasing - * the Redis lock in between). If the handler is not set, the blocking command will + * the lock in between). If the handler is not set, the blocking command will * still continue its execution but the reply will be ignored (fire and forget), * notice that this is dangerous in case of role change, as explained below. * The module can use ValkeyModule_CallReplyPromiseAbort to abort the command invocation @@ -6260,21 +6260,21 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * details). It is also the module's responsibility to abort the execution on role change, either by using * server event (to get notified when the instance becomes a replica) or relying on the disconnect * callback of the original client. Failing to do so can result in a write operation on a replica. - * Unlike other call replies, promise call reply **must** be freed while the Redis GIL is locked. + * Unlike other call replies, promise call reply **must** be freed while the GIL is locked. * Notice that on unblocking, the only promise is that the unblock handler will be called, * If the blocking VM_Call caused the module to also block some real client (using VM_BlockClient), * it is the module responsibility to unblock this client on the unblock handler. * On the unblock handler it is only allowed to perform the following: - * * Calling additional Redis commands using VM_Call + * * Calling additional commands using VM_Call * * Open keys using VM_OpenKey * * Replicate data to the replica or AOF * - * Specifically, it is not allowed to call any Redis module API which are client related such as: + * Specifically, it is not allowed to call any module API which are client related such as: * * VM_Reply* API's * * VM_BlockClient * * VM_GetCurrentUserName * - * * **...**: The actual arguments to the Redis command. + * * **...**: The actual arguments to the command. * * On success a ValkeyModuleCallReply object is returned, otherwise * NULL is returned and errno is set to the following values: @@ -6511,7 +6511,7 @@ ValkeyModuleCallReply *VM_Call(ValkeyModuleCtx *ctx, const char *cmdname, const } } - /* If this is a Redis Cluster node, we need to make sure the module is not + /* If this is a Cluster node, we need to make sure the module is not * trying to access non-local keys, with the exception of commands * received from our master. */ if (server.cluster_enabled && !mustObeyClient(ctx->client)) { @@ -6616,8 +6616,8 @@ const char *VM_CallReplyProto(ValkeyModuleCallReply *reply, size_t *len) { * ## Modules data types * * When String DMA or using existing data structures is not enough, it is - * possible to create new data types from scratch and export them to - * Redis. The module must provide a set of callbacks for handling the + * possible to create new data types from scratch. + * The module must provide a set of callbacks for handling the * new values exported (for example in order to provide RDB saving/loading, * AOF rewrite, and so forth). In this section we define this API. * -------------------------------------------------------------------------- */ @@ -6810,7 +6810,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * following. Please for in depth documentation check the modules API * documentation, especially https://redis.io/topics/modules-native-types. * - * * **name**: A 9 characters data type name that MUST be unique in the Redis + * * **name**: A 9 characters data type name that MUST be unique in the * Modules ecosystem. Be creative... and there will be no collisions. Use * the charset A-Z a-z 9-0, plus the two "-_" characters. A good * idea is to use, for example `-`. For example @@ -6870,7 +6870,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * freeing the value. for example: how many pointers are gonna be freed. Note that if it * returns 0, we'll always do an async free. * * **unlink**: A callback function pointer that used to notifies the module that the key has - * been removed from the DB by redis, and may soon be freed by a background thread. Note that + * been removed from the DB by the server, and may soon be freed by a background thread. Note that * it won't be called on FLUSHALL/FLUSHDB (both sync and async), and the module can use the * ValkeyModuleEvent_FlushDB to hook into that. * * **copy**: A callback function pointer that is used to make a copy of the specified key. @@ -6914,7 +6914,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * If ValkeyModule_CreateDataType() is called outside of ValkeyModule_OnLoad() function, * there is already a module registering a type with the same name, * or if the module name or encver is invalid, NULL is returned. - * Otherwise the new type is registered into Redis, and a reference of + * Otherwise the new type is registered into the server, and a reference of * type ValkeyModuleType is returned: the caller of the function should store * this reference into a global variable to make future use of it in the * modules type API, since a single module may register multiple types. @@ -7390,11 +7390,11 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { * one element after the other, for all the elements that constitute a given * data structure. The function call must be followed by the call to * `ValkeyModule_DigestEndSequence` eventually, when all the elements that are - * always in a given order are added. See the Redis Modules data types - * documentation for more info. However this is a quick example that uses Redis - * data types as an example. + * always in a given order are added. See the Modules data types + * documentation for more info. However this is a quick example that uses the + * Set, Hash and List data types as an example. * - * To add a sequence of unordered elements (for example in the case of a Redis + * To add a sequence of unordered elements (for example in the case of a * Set), the pattern to use is: * * foreach element { @@ -7414,7 +7414,7 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { * } * * Because the key and value will be always in the above order, while instead - * the single key-value pairs, can appear in any position into a Redis hash. + * the single key-value pairs, can appear in any position into a hash. * * A list of ordered elements would be implemented with: * @@ -7447,13 +7447,13 @@ void VM_DigestEndSequence(ValkeyModuleDigest *md) { * * This call basically reuses the 'rdb_load' callback which module data types * implement in order to allow a module to arbitrarily serialize/de-serialize - * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. + * keys, similar to how the 'DUMP' and 'RESTORE' commands are implemented. * * Modules should generally use the VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS flag and * make sure the de-serialization code properly checks and handles IO errors * (freeing allocated buffers and returning a NULL). * - * If this is NOT done, Redis will handle corrupted (or just truncated) serialized + * If this is NOT done, the server will handle corrupted (or just truncated) serialized * data by producing an error message and terminating the process. */ void *VM_LoadDataTypeFromStringEncver(const ValkeyModuleString *str, const moduleType *mt, int encver) { @@ -7487,7 +7487,7 @@ void *VM_LoadDataTypeFromString(const ValkeyModuleString *str, const moduleType * * This call basically reuses the 'rdb_save' callback which module data types * implement in order to allow a module to arbitrarily serialize/de-serialize - * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. + * keys, similar to how the 'DUMP' and 'RESTORE' commands are implemented. */ ValkeyModuleString *VM_SaveDataTypeToString(ValkeyModuleCtx *ctx, void *data, const moduleType *mt) { rio payload; @@ -7526,7 +7526,7 @@ int VM_GetDbIdFromDigest(ValkeyModuleDigest *dig) { * is only called in the context of the aof_rewrite method of data types exported * by a module. The command works exactly like ValkeyModule_Call() in the way * the parameters are passed, but it does not return anything as the error - * handling is performed by Redis itself. */ + * handling is performed by the server itself. */ void VM_EmitAOF(ValkeyModuleIO *io, const char *cmdname, const char *fmt, ...) { if (io->error) return; struct serverCommand *cmd; @@ -7545,7 +7545,7 @@ void VM_EmitAOF(ValkeyModuleIO *io, const char *cmdname, const char *fmt, ...) { return; } - /* Emit the arguments into the AOF in Redis protocol format. */ + /* Emit the arguments into the AOF in RESP format. */ va_start(ap, fmt); argv = moduleCreateArgvFromUserFormat(cmdname,fmt,&argc,&flags,ap); va_end(ap); @@ -7636,7 +7636,7 @@ void moduleLogRaw(ValkeyModule *module, const char *levelstr, const char *fmt, v serverLogRaw(level,msg); } -/* Produces a log message to the standard Redis log, the format accepts +/* Produces a log message to the standard server log, the format accepts * printf-alike specifiers, while level is a string describing the log * level to use when emitting the log, and must be one of the following: * @@ -7673,13 +7673,13 @@ void VM_LogIOError(ValkeyModuleIO *io, const char *levelstr, const char *fmt, .. va_end(ap); } -/* Redis-like assert function. +/* Valkey assert function. * * The macro `ValkeyModule_Assert(expression)` is recommended, rather than * calling this function directly. * * A failed assertion will shut down the server and produce logging information - * that looks identical to information generated by Redis itself. + * that looks identical to information generated by the server itself. */ void VM__Assert(const char *estr, const char *file, int line) { _serverAssert(estr, file, line); @@ -7712,7 +7712,7 @@ int isModuleClientUnblocked(client *c) { * because the client is terminated, but is also called for cleanup when a * client is unblocked in a clean way after replaying. * - * What we do here is just to set the client to NULL in the redis module + * What we do here is just to set the client to NULL in the module * blocked client handle. This way if the client is terminated while there * is a pending threaded operation involving the blocked client, we'll know * that the client no longer exists and no reply callback should be called. @@ -8124,10 +8124,10 @@ void VM_BlockClientSetPrivateData(ValkeyModuleBlockedClient *blocked_client, voi } /* This call is similar to ValkeyModule_BlockClient(), however in this case we - * don't just block the client, but also ask Redis to unblock it automatically + * don't just block the client, but also ask the server to unblock it automatically * once certain keys become "ready", that is, contain more data. * - * Basically this is similar to what a typical Redis command usually does, + * Basically this is similar to what a typical command usually does, * like BLPOP or BZPOPMAX: the client blocks if it cannot be served ASAP, * and later when the key receives new data (a list push for instance), the * client is unblocked and served. @@ -8166,7 +8166,7 @@ void VM_BlockClientSetPrivateData(ValkeyModuleBlockedClient *blocked_client, voi * be accessible later in the reply callback. Normally when blocking with * ValkeyModule_BlockClient() the private data to reply to the client is * passed when calling ValkeyModule_UnblockClient() but here the unblocking - * is performed by Redis itself, so we need to have some private data before + * is performed by the server itself, so we need to have some private data before * hand. The private data is used to store any information about the specific * unblocking operation that you are implementing. Such information will be * freed using the free_privdata callback provided by the user. @@ -8225,7 +8225,7 @@ int moduleUnblockClientByHandle(ValkeyModuleBlockedClient *bc, void *privdata) { return VALKEYMODULE_OK; } -/* This API is used by the Redis core to unblock a client that was blocked +/* This API is used by the server core to unblock a client that was blocked * by a module. */ void moduleUnblockClient(client *c) { ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; @@ -8304,7 +8304,7 @@ void VM_SetDisconnectCallback(ValkeyModuleBlockedClient *bc, ValkeyModuleDisconn * * Clients end into this list because of calls to VM_UnblockClient(), * however it is possible that while the module was doing work for the - * blocked client, it was terminated by Redis (for timeout or other reasons). + * blocked client, it was terminated by the server (for timeout or other reasons). * When this happens the ValkeyModuleBlockedClient structure in the queue * will have the 'client' field set to NULL. */ void moduleHandleBlockedClients(void) { @@ -8506,8 +8506,8 @@ int VM_BlockedClientDisconnected(ValkeyModuleCtx *ctx) { * ## Thread Safe Contexts * -------------------------------------------------------------------------- */ -/* Return a context which can be used inside threads to make Redis context - * calls with certain modules APIs. If 'bc' is not NULL then the module will +/* Return a context which can be used inside threads to make calls requiring a + * context with certain modules APIs. If 'bc' is not NULL then the module will * be bound to a blocked client, and it will be possible to use the * `ValkeyModule_Reply*` family of functions to accumulate a reply for when the * client will be unblocked. Otherwise the thread safe context will be @@ -8698,9 +8698,9 @@ void moduleReleaseGIL(void) { * * `type` is the event type bit, that must match the mask given at registration * time. The event string is the actual command being executed, and key is the - * relevant Redis key. + * relevant key. * - * Notification callback gets executed with a redis context that can not be + * Notification callback gets executed with a context that can not be * used to send anything to the client, and has the db number where the event * occurred as its selected db number. * @@ -8708,11 +8708,11 @@ void moduleReleaseGIL(void) { * module notifications to work. * * Warning: the notification callbacks are performed in a synchronous manner, - * so notification callbacks must to be fast, or they would slow Redis down. + * so notification callbacks must to be fast, or they would slow the server down. * If you need to take long actions, use threads to offload them. * * Moreover, the fact that the notification is executed synchronously means - * that the notification code will be executed in the middle on Redis logic + * that the notification code will be executed in the middle of server logic * (commands logic, eviction, expire). Changing the key space while the logic * runs is dangerous and discouraged. In order to react to key space events with * write actions, please refer to `VM_AddPostNotificationJob`. @@ -8757,7 +8757,7 @@ void firePostExecutionUnitJobs(void) { /* When running inside a key space notification callback, it is dangerous and highly discouraged to perform any write * operation (See `VM_SubscribeToKeyspaceEvents`). In order to still perform write actions in this scenario, - * Redis provides `VM_AddPostNotificationJob` API. The API allows to register a job callback which Redis will call + * the server provides `VM_AddPostNotificationJob` API. The API allows to register a job callback which the server will call * when the following condition are promised to be fulfilled: * 1. It is safe to perform any write operation. * 2. The job will be called atomically along side the key space notification. @@ -8766,7 +8766,7 @@ void firePostExecutionUnitJobs(void) { * This raises a concerns of entering an infinite loops, we consider infinite loops * as a logical bug that need to be fixed in the module, an attempt to protect against * infinite loops by halting the execution could result in violation of the feature correctness - * and so Redis will make no attempt to protect the module from infinite loops. + * and so the server will make no attempt to protect the module from infinite loops. * * 'free_pd' can be NULL and in such case will not be used. * @@ -8978,8 +8978,8 @@ int VM_SendClusterMessage(ValkeyModuleCtx *ctx, const char *target_id, uint8_t t /* Return an array of string pointers, each string pointer points to a cluster * node ID of exactly VALKEYMODULE_NODE_ID_LEN bytes (without any null term). * The number of returned node IDs is stored into `*numnodes`. - * However if this function is called by a module not running an a Redis - * instance with Redis Cluster enabled, NULL is returned instead. + * However if this function is called by a module not running an an + * instance with Cluster enabled, NULL is returned instead. * * The IDs returned can be used with ValkeyModule_GetClusterNodeInfo() in order * to get more information about single node. @@ -9083,10 +9083,10 @@ int VM_GetClusterNodeInfo(ValkeyModuleCtx *ctx, const char *id, char *ip, char * return VALKEYMODULE_OK; } -/* Set Redis Cluster flags in order to change the normal behavior of - * Redis Cluster, especially with the goal of disabling certain functions. +/* Set Cluster flags in order to change the normal behavior of + * Cluster, especially with the goal of disabling certain functions. * This is useful for modules that use the Cluster API in order to create - * a different distributed system, but still want to use the Redis Cluster + * a different distributed system, but still want to use the Cluster * message bus. Flags that can be set: * * * CLUSTER_MODULE_FLAG_NO_FAILOVER @@ -9094,11 +9094,11 @@ int VM_GetClusterNodeInfo(ValkeyModuleCtx *ctx, const char *id, char *ip, char * * * With the following effects: * - * * NO_FAILOVER: prevent Redis Cluster slaves from failing over a dead master. + * * NO_FAILOVER: prevent Cluster slaves from failing over a dead master. * Also disables the replica migration feature. * * * NO_REDIRECTION: Every node will accept any key, without trying to perform - * partitioning according to the Redis Cluster algorithm. + * partitioning according to the Cluster algorithm. * Slots information will still be propagated across the * cluster, but without effect. */ void VM_SetClusterFlags(ValkeyModuleCtx *ctx, uint64_t flags) { @@ -9131,7 +9131,7 @@ const char *VM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { * module timers subsystem in order to process the next event. * * All the timers are stored into a radix tree, ordered by expire time, when - * the main Redis event loop timer callback is called, we try to process all + * the main server event loop timer callback is called, we try to process all * the timers already expired one after the other. Then we re-enter the event * loop registering a timer that will expire when the next to process module * timer will expire. @@ -9377,7 +9377,7 @@ static void eventLoopCbWritable(struct aeEventLoop *ae, int fd, void *user_data, * On success VALKEYMODULE_OK is returned, otherwise * VALKEYMODULE_ERR is returned and errno is set to the following values: * - * * ERANGE: `fd` is negative or higher than `maxclients` Redis config. + * * ERANGE: `fd` is negative or higher than `maxclients` server config. * * EINVAL: `callback` is NULL or `mask` value is invalid. * * `errno` might take other values in case of an internal error. @@ -9452,7 +9452,7 @@ int VM_EventLoopAdd(int fd, int mask, ValkeyModuleEventLoopFunc func, void *user * On success VALKEYMODULE_OK is returned, otherwise * VALKEYMODULE_ERR is returned and errno is set to the following values: * - * * ERANGE: `fd` is negative or higher than `maxclients` Redis config. + * * ERANGE: `fd` is negative or higher than `maxclients` server config. * * EINVAL: `mask` value is invalid. */ int VM_EventLoopDel(int fd, int mask) { @@ -9478,7 +9478,7 @@ int VM_EventLoopDel(int fd, int mask) { return VALKEYMODULE_OK; } -/* This function can be called from other threads to trigger callback on Redis +/* This function can be called from other threads to trigger callback on the server * main thread. On success VALKEYMODULE_OK is returned. If `func` is NULL * VALKEYMODULE_ERR is returned and errno is set to EINVAL. */ @@ -9529,7 +9529,7 @@ static void eventLoopHandleOneShotEvents(void) { /* -------------------------------------------------------------------------- * ## Modules ACL API * - * Implements a hook into the authentication and authorization within Redis. + * Implements a hook into the authentication and authorization within the server. * --------------------------------------------------------------------------*/ /* This function is called when a client's user has changed and invokes the @@ -9588,7 +9588,7 @@ static void moduleFreeAuthenticatedClients(ValkeyModule *module) { } } -/* Creates a Redis ACL user that the module can use to authenticate a client. +/* Creates an ACL user that the module can use to authenticate a client. * After obtaining the user, the module should set what such user can do * using the VM_SetUserACL() function. Once configured, the user * can be used in order to authenticate a connection, with the specified @@ -9600,7 +9600,7 @@ static void moduleFreeAuthenticatedClients(ValkeyModule *module) { * * Users created here are not checked for duplicated name, so it's up to * the module calling this function to take care of not creating users * with the same name. - * * The created user can be used to authenticate multiple Redis connections. + * * The created user can be used to authenticate multiple connections. * * The caller can later free the user using the function * VM_FreeModuleUser(). When this function is called, if there are @@ -9628,7 +9628,7 @@ int VM_FreeModuleUser(ValkeyModuleUser *user) { return VALKEYMODULE_OK; } -/* Sets the permissions of a user created through the redis module +/* Sets the permissions of a user created through the module * interface. The syntax is the same as ACL SETUSER, so refer to the * documentation in acl.c for more information. See VM_CreateModuleUser * for detailed usage. @@ -9640,7 +9640,7 @@ int VM_SetModuleUserACL(ValkeyModuleUser *user, const char* acl) { } /* Sets the permission of a user with a complete ACL string, such as one - * would use on the redis ACL SETUSER command line API. This differs from + * would use on the ACL SETUSER command line API. This differs from * VM_SetModuleUserACL, which only takes single ACL operations at a time. * * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on failure @@ -9895,7 +9895,7 @@ static int authenticateClientWithUser(ValkeyModuleCtx *ctx, user *user, ValkeyMo } -/* Authenticate the current context's user with the provided redis acl user. +/* Authenticate the current context's user with the provided acl user. * Returns VALKEYMODULE_ERR if the user is disabled. * * See authenticateClientWithUser for information about callback, client_id, @@ -9904,7 +9904,7 @@ int VM_AuthenticateClientWithUser(ValkeyModuleCtx *ctx, ValkeyModuleUser *module return authenticateClientWithUser(ctx, module_user->user, callback, privdata, client_id); } -/* Authenticate the current context's user with the provided redis acl user. +/* Authenticate the current context's user with the provided acl user. * Returns VALKEYMODULE_ERR if the user is disabled or the user does not exist. * * See authenticateClientWithUser for information about callback, client_id, @@ -10717,11 +10717,11 @@ int moduleUnregisterFilters(ValkeyModule *module) { /* Register a new command filter function. * - * Command filtering makes it possible for modules to extend Redis by plugging + * Command filtering makes it possible for modules to extend the server by plugging * into the execution flow of all commands. * - * A registered filter gets called before Redis executes *any* command. This - * includes both core Redis commands and commands registered by any module. The + * A registered filter gets called before the server executes *any* command. This + * includes both core server commands and commands registered by any module. The * filter applies in all execution paths including: * * 1. Invocation by a client. @@ -10732,21 +10732,21 @@ int moduleUnregisterFilters(ValkeyModule *module) { * The filter executes in a special filter context, which is different and more * limited than a ValkeyModuleCtx. Because the filter affects any command, it * must be implemented in a very efficient way to reduce the performance impact - * on Redis. All Redis Module API calls that require a valid context (such as + * on the server. All Module API calls that require a valid context (such as * `ValkeyModule_Call()`, `ValkeyModule_OpenKey()`, etc.) are not supported in a * filter context. * * The `ValkeyModuleCommandFilterCtx` can be used to inspect or modify the - * executed command and its arguments. As the filter executes before Redis + * executed command and its arguments. As the filter executes before the server * begins processing the command, any change will affect the way the command is - * processed. For example, a module can override Redis commands this way: + * processed. For example, a module can override server commands this way: * * 1. Register a `MODULE.SET` command which implements an extended version of - * the Redis `SET` command. + * the `SET` command. * 2. Register a command filter which detects invocation of `SET` on a specific * pattern of keys. Once detected, the filter will replace the first * argument from `SET` to `MODULE.SET`. - * 3. When filter execution is complete, Redis considers the new command name + * 3. When filter execution is complete, the server considers the new command name * and therefore executes the module's own command. * * Note that in the above use case, if `MODULE.SET` itself uses @@ -10847,7 +10847,7 @@ ValkeyModuleString *VM_CommandFilterArgGet(ValkeyModuleCommandFilterCtx *fctx, i } /* Modify the filtered command by inserting a new argument at the specified - * position. The specified ValkeyModuleString argument may be used by Redis + * position. The specified ValkeyModuleString argument may be used by the server * after the filter context is destroyed, so it must not be auto-memory * allocated, freed or used elsewhere. */ @@ -10871,7 +10871,7 @@ int VM_CommandFilterArgInsert(ValkeyModuleCommandFilterCtx *fctx, int pos, Valke } /* Modify the filtered command by replacing an existing argument with a new one. - * The specified ValkeyModuleString argument may be used by Redis after the + * The specified ValkeyModuleString argument may be used by the server after the * filter context is destroyed, so it must not be auto-memory allocated, freed * or used elsewhere. */ @@ -10946,7 +10946,7 @@ size_t VM_MallocSizeDict(ValkeyModuleDict* dict) { } /* Return the a number between 0 to 1 indicating the amount of memory - * currently used, relative to the Redis "maxmemory" configuration. + * currently used, relative to the server "maxmemory" configuration. * * * 0 - No memory limit configured. * * Between 0 and 1 - The percentage of the memory used normalized in 0-1 range. @@ -11018,7 +11018,7 @@ void VM_ScanCursorDestroy(ValkeyModuleScanCursor *cursor) { * void scan_callback(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, * ValkeyModuleKey *key, void *privdata); * - * - `ctx`: the redis module context provided to for the scan. + * - `ctx`: the module context provided to for the scan. * - `keyname`: owned by the caller and need to be retained if used after this * function. * - `key`: holds info on the key and value, it is provided as best effort, in @@ -11051,7 +11051,7 @@ void VM_ScanCursorDestroy(ValkeyModuleScanCursor *cursor) { * * It is also possible to restart an existing cursor using VM_ScanCursorRestart. * - * IMPORTANT: This API is very similar to the Redis SCAN command from the + * IMPORTANT: This API is very similar to the SCAN command from the * point of view of the guarantees it provides. This means that the API * may report duplicated keys, but guarantees to report at least one time * every key that was there from the start to the end of the scanning process. @@ -11060,7 +11060,7 @@ void VM_ScanCursorDestroy(ValkeyModuleScanCursor *cursor) { * that the internal state of the database may change. For instance it is safe * to delete or modify the current key, but may not be safe to delete any * other key. - * Moreover playing with the Redis keyspace while iterating may have the + * Moreover playing with the keyspace while iterating may have the * effect of returning more duplicates. A safe pattern is to store the keys * names you want to modify elsewhere, and perform the actions on the keys * later when the iteration is complete. However this can cost a lot of @@ -11116,7 +11116,7 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { * * void scan_callback(ValkeyModuleKey *key, ValkeyModuleString* field, ValkeyModuleString* value, void *privdata); * - * - key - the redis key context provided to for the scan. + * - key - the key context provided to for the scan. * - field - field name, owned by the caller and need to be retained if used * after this function. * - value - value string or NULL for set type, owned by the caller and need to @@ -11238,7 +11238,7 @@ int VM_ScanKey(ValkeyModuleKey *key, ValkeyModuleScanCursor *cursor, ValkeyModul /* Create a background child process with the current frozen snapshot of the * main process where you can do some processing in the background without * affecting / freezing the traffic and no need for threads and GIL locking. - * Note that Redis allows for only one concurrent fork. + * Note that the server allows for only one concurrent fork. * When the child wants to exit, it should call ValkeyModule_ExitFromChild. * If the parent wants to kill the child it should call ValkeyModule_KillForkChild * The done handler callback will be executed on the parent process when the @@ -11371,7 +11371,7 @@ static uint64_t moduleEventVersions[] = { * uint64_t subevent, * void *data); * - * The 'ctx' is a normal Redis module context that the callback can use in + * The 'ctx' is a normal module context that the callback can use in * order to call other modules APIs. The 'eid' is the event itself, this * is only useful in the case the module subscribed to multiple events: using * the 'id' field of this structure it is possible to check if the event @@ -11494,15 +11494,15 @@ static uint64_t moduleEventVersions[] = { * * `VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE` * * No additional information is available so far: future versions - * of Redis will have an API in order to enumerate the replicas + * of the server will have an API in order to enumerate the replicas * connected and their state. * * * ValkeyModuleEvent_CronLoop * - * This event is called every time Redis calls the serverCron() + * This event is called every time the server calls the serverCron() * function in order to do certain bookkeeping. Modules that are * required to do operations from time to time may use this callback. - * Normally Redis calls this function 10 times per second, but + * Normally the server calls this function 10 times per second, but * this changes depending on the "hz" configuration. * No sub events are available. * @@ -11567,12 +11567,12 @@ static uint64_t moduleEventVersions[] = { * * * ValkeyModuleEvent_ReplBackup * - * WARNING: Replication Backup events are deprecated since Redis 7.0 and are never fired. + * WARNING: Replication Backup events are deprecated since Redis OSS 7.0 and are never fired. * See ValkeyModuleEvent_ReplAsyncLoad for understanding how Async Replication Loading events * are now triggered when repl-diskless-load is set to swapdb. * * Called when repl-diskless-load config is set to swapdb, - * And redis needs to backup the current database for the + * And the server needs to backup the current database for the * possibility to be restored later. A module with global data and * maybe with aux_load and aux_save callbacks may need to use this * notification to backup / restore / discard its globals. @@ -11586,7 +11586,7 @@ static uint64_t moduleEventVersions[] = { * * Called when repl-diskless-load config is set to swapdb and a replication with a master of same * data set history (matching replication ID) occurs. - * In which case redis serves current data set while loading new database in memory from socket. + * In which case the server serves current data set while loading new database in memory from socket. * Modules must have declared they support this mechanism in order to activate it, through * VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD flag. * The following sub events are available: @@ -11736,7 +11736,7 @@ typedef struct KeyInfo { int mode; } KeyInfo; -/* This is called by the Redis internals every time we want to fire an +/* This is called by the server internals every time we want to fire an * event that can be intercepted by some module. The pointer 'data' is useful * in order to populate the event-specific structure when needed, in order * to return the structure with more information to the callback. @@ -11963,7 +11963,7 @@ int moduleRegisterApi(const char *funcname, void *funcptr) { moduleRegisterApi("ValkeyModule_" #name, (void *)(unsigned long)VM_ ## name);\ moduleRegisterApi("RedisModule_" #name, (void *)(unsigned long)VM_ ## name);\ -/* Global initialization at Redis startup. */ +/* Global initialization at server startup. */ void moduleRegisterCoreAPI(void); /* Currently, this function is just a placeholder for the module system @@ -12002,11 +12002,11 @@ void moduleInitModulesSystem(void) { moduleRegisterCoreAPI(); - /* Create a pipe for module threads to be able to wake up the redis main thread. + /* Create a pipe for module threads to be able to wake up the server main thread. * Make the pipe non blocking. This is just a best effort aware mechanism * and we do not want to block not in the read nor in the write half. * Enable close-on-exec flag on pipes in case of the fork-exec system calls in - * sentinels or redis servers. */ + * sentinels or servers. */ if (anetPipe(server.module_pipe, O_CLOEXEC|O_NONBLOCK, O_CLOEXEC|O_NONBLOCK) == -1) { serverLog(LL_WARNING, "Can't create the pipe for module threads: %s", strerror(errno)); @@ -12337,7 +12337,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa return C_ERR; } - /* Redis module loaded! Register it. */ + /* Module loaded! Register it. */ dictAdd(modules,ctx.module->name,ctx.module); ctx.module->blocked_clients = 0; ctx.module->handle = handle; @@ -12808,11 +12808,11 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { return new_flags; } -/* Create a string config that Redis users can interact with via the Redis config file, +/* Create a string config that users can interact with via the server config file, * `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. * * The actual config value is owned by the module, and the `getfn`, `setfn` and optional - * `applyfn` callbacks that are provided to Redis in order to access or manipulate the + * `applyfn` callbacks that are provided to the server in order to access or manipulate the * value. The `getfn` callback retrieves the value from the module, while the `setfn` * callback provides a value to be stored into the module config. * The optional `applyfn` callback is called after a `CONFIG SET` command modified one or @@ -12823,10 +12823,10 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * are identical, and the callback will only be run once. * Both the `setfn` and `applyfn` can return an error if the provided value is invalid or * cannot be used. - * The config also declares a type for the value that is validated by Redis and + * The config also declares a type for the value that is validated by the server and * provided to the module. The config system provides the following types: * - * * Redis String: Binary safe string data. + * * String: Binary safe string data. * * Enum: One of a finite number of string tokens, provided during registration. * * Numeric: 64 bit signed integer, which also supports min and max values. * * Bool: Yes or no value. @@ -12834,7 +12834,7 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * The `setfn` callback is expected to return VALKEYMODULE_OK when the value is successfully * applied. It can also return VALKEYMODULE_ERR if the value can't be applied, and the * *err pointer can be set with a ValkeyModuleString error message to provide to the client. - * This ValkeyModuleString will be freed by redis after returning from the set callback. + * This ValkeyModuleString will be freed by the server after returning from the set callback. * * All configs are registered with a name, a type, a default value, private data that is made * available in the callbacks, as well as several flags that modify the behavior of the config. @@ -12918,8 +12918,8 @@ int VM_RegisterBoolConfig(ValkeyModuleCtx *ctx, const char *name, int default_va * Create an enum config that server clients can interact with via the * `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. * Enum configs are a set of string tokens to corresponding integer values, where - * the string value is exposed to Redis clients but the value passed Redis and the - * module is the integer value. These values are defined in enum_values, an array + * the string value is exposed to clients but the inter value is passed to the server + * and the module. These values are defined in enum_values, an array * of null-terminated c strings, and int_vals, an array of enum values who has an * index partner in enum_values. * Example Implementation: @@ -13129,7 +13129,7 @@ int VM_RdbSave(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) { return VALKEYMODULE_OK; } -/* Redis MODULE command. +/* MODULE command. * * MODULE LIST * MODULE LOAD [args...] @@ -13268,7 +13268,7 @@ int VM_GetLFU(ValkeyModuleKey *key, long long *lfu_freq) { /** * Returns the full module options flags mask, using the return value * the module can check if a certain set of module options are supported - * by the redis server version in use. + * by the server version in use. * Example: * * int supportedFlags = VM_GetModuleOptionsAll(); @@ -13285,7 +13285,7 @@ int VM_GetModuleOptionsAll(void) { /** * Returns the full ContextFlags mask, using the return value * the module can check if a certain set of flags are supported - * by the redis server version in use. + * by the server version in use. * Example: * * int supportedFlags = VM_GetContextFlagsAll(); @@ -13302,7 +13302,7 @@ int VM_GetContextFlagsAll(void) { /** * Returns the full KeyspaceNotification mask, using the return value * the module can check if a certain set of flags are supported - * by the redis server version in use. + * by the server version in use. * Example: * * int supportedFlags = VM_GetKeyspaceNotificationFlagsAll(); @@ -13317,7 +13317,7 @@ int VM_GetKeyspaceNotificationFlagsAll(void) { } /** - * Return the redis version in format of 0x00MMmmpp. + * Return the server version in format of 0x00MMmmpp. * Example for 6.0.7 the return value will be 0x00060007. */ int VM_GetServerVersion(void) { @@ -13325,7 +13325,7 @@ int VM_GetServerVersion(void) { } /** - * Return the current redis-server runtime value of VALKEYMODULE_TYPE_METHOD_VERSION. + * Return the current server runtime value of VALKEYMODULE_TYPE_METHOD_VERSION. * You can use that when calling VM_CreateDataType to know which fields of * ValkeyModuleTypeMethods are gonna be supported and which will be ignored. */ @@ -13382,7 +13382,7 @@ int VM_ModuleTypeReplaceValue(ValkeyModuleKey *key, moduleType *mt, void *new_va * * ENOENT: Specified command does not exist. * * EINVAL: Invalid command arity specified. * - * NOTE: The returned array is not a Redis Module object so it does not + * NOTE: The returned array is not a Module object so it does not * get automatically freed even when auto-memory is used. The caller * must explicitly call VM_Free() to free it, same as the out_flags pointer if * used. @@ -13554,7 +13554,7 @@ void *VM_DefragAlloc(ValkeyModuleDefragCtx *ctx, void *ptr) { * Typically this means strings retained with VM_RetainString or VM_HoldString * may not be defragmentable. One exception is command argvs which, if retained * by the module, will end up with a single reference (because the reference - * on the Redis side is dropped as soon as the command callback returns). + * on the server side is dropped as soon as the command callback returns). */ ValkeyModuleString *VM_DefragValkeyModuleString(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) { UNUSED(ctx); diff --git a/src/modules/helloacl.c b/src/modules/helloacl.c index a7660afea3..282f1e6a84 100644 --- a/src/modules/helloacl.c +++ b/src/modules/helloacl.c @@ -154,8 +154,8 @@ int AuthAsyncCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, return VALKEYMODULE_OK; } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); diff --git a/src/modules/helloblock.c b/src/modules/helloblock.c index 8c036bead5..7fd79cd366 100644 --- a/src/modules/helloblock.c +++ b/src/modules/helloblock.c @@ -198,8 +198,8 @@ int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int ar return VALKEYMODULE_OK; } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); diff --git a/src/modules/hellocluster.c b/src/modules/hellocluster.c index 7a70332ada..e2c7ac57a8 100644 --- a/src/modules/hellocluster.c +++ b/src/modules/hellocluster.c @@ -86,8 +86,8 @@ void PongReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, cons type,VALKEYMODULE_NODE_ID_LEN,sender_id,(int)len, payload); } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); @@ -103,7 +103,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) ListCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; - /* Disable Redis Cluster sharding and redirections. This way every node + /* Disable Cluster sharding and redirections. This way every node * will be able to access every possible key, regardless of the hash slot. * This way the PING message handler will be able to increment a specific * variable. Normally you do that in order for the distributed system diff --git a/src/modules/hellodict.c b/src/modules/hellodict.c index 6a6420b7d3..98b69fd4ea 100644 --- a/src/modules/hellodict.c +++ b/src/modules/hellodict.c @@ -1,7 +1,7 @@ /* Hellodict -- An example of modules dictionary API * * This module implements a volatile key-value store on top of the - * dictionary exported by the Redis modules API. + * dictionary exported by the modules API. * * ----------------------------------------------------------------------------- * @@ -103,8 +103,8 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return VALKEYMODULE_OK; } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); diff --git a/src/modules/hellohook.c b/src/modules/hellohook.c index 4b675891a2..58e0995f66 100644 --- a/src/modules/hellohook.c +++ b/src/modules/hellohook.c @@ -75,8 +75,8 @@ void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void } } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); diff --git a/src/modules/hellotimer.c b/src/modules/hellotimer.c index d0ea4e14a9..ae76f084d7 100644 --- a/src/modules/hellotimer.c +++ b/src/modules/hellotimer.c @@ -58,8 +58,8 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int return RedisModule_ReplyWithSimpleString(ctx, "OK"); } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); diff --git a/src/modules/hellotype.c b/src/modules/hellotype.c index 31ca35f6f5..b0329c6dba 100644 --- a/src/modules/hellotype.c +++ b/src/modules/hellotype.c @@ -320,8 +320,8 @@ void HelloTypeDigest(RedisModuleDigest *md, void *value) { RedisModule_DigestEndSequence(md); } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index 658bcb3926..8ca9137328 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -1,4 +1,4 @@ -/* Helloworld module -- A few examples of the Redis Modules API in the form +/* Helloworld module -- A few examples of the Modules API in the form * of commands showing how to accomplish common tasks. * * This module does not do anything useful, if not for a few commands. The @@ -42,7 +42,7 @@ /* HELLO.SIMPLE is among the simplest commands you can implement. * It just returns the currently selected DB id, a functionality which is - * missing in Redis. The command uses two important API calls: one to + * missing in the server. The command uses two important API calls: one to * fetch the currently selected DB, the other in order to send the client * an integer reply as response. */ int HelloSimple_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { @@ -73,8 +73,8 @@ int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, } /* HELLO.PUSH.CALL implements RPUSH using an higher level approach, calling - * a Redis command instead of working with the key in a low level way. This - * approach is useful when you need to call Redis commands that are not + * a command instead of working with the key in a low level way. This + * approach is useful when you need to call commands that are not * available as low level APIs, or when you don't need the maximum speed * possible but instead prefer implementation simplicity. */ int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) @@ -106,7 +106,7 @@ int HelloPushCall2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i } /* HELLO.LIST.SUM.LEN returns the total length of all the items inside - * a Redis list, by using the high level Call() API. + * a list, by using the high level Call() API. * This command is an example of the array reply access. */ int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { @@ -492,7 +492,7 @@ int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a * This is an implementation of the infamous LEFTPAD function, that * was at the center of an issue with the npm modules system in March 2016. * - * LEFTPAD is a good example of using a Redis Modules API called + * LEFTPAD is a good example of using a Modules API called * "pool allocator", that was a famous way to allocate memory in yet another * open source project, the Apache web server. * @@ -540,8 +540,8 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int return VALKEYMODULE_OK; } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (RedisModule_Init(ctx,"helloworld",1,VALKEYMODULE_APIVER_1) == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; diff --git a/src/monotonic.c b/src/monotonic.c index a78d9d5f9e..d96bfb2b3b 100644 --- a/src/monotonic.c +++ b/src/monotonic.c @@ -12,7 +12,7 @@ static char monotonic_info_string[32]; /* Using the processor clock (aka TSC on x86) can provide improved performance - * throughout Redis wherever the monotonic clock is used. The processor clock + * throughout the server wherever the monotonic clock is used. The processor clock * is significantly faster than calling 'clock_gettime' (POSIX). While this is * generally safe on modern systems, this link provides additional information * about use of the x86 TSC: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage diff --git a/src/networking.c b/src/networking.c index fdfb9b3fda..2d94e532d0 100644 --- a/src/networking.c +++ b/src/networking.c @@ -466,7 +466,7 @@ void addReplySds(client *c, sds s) { * client buffer, trying the static buffer initially, and using the string * of objects if not possible. * - * It is efficient because does not create an SDS object nor an Redis object + * It is efficient because does not create an SDS object nor an Object * if not needed. The object will only be created by calling * _addReplyProtoToList() if we fail to extend the existing tail object * in the list of objects. */ @@ -476,7 +476,7 @@ void addReplyProto(client *c, const char *s, size_t len) { } /* Low level function called by the addReplyError...() functions. - * It emits the protocol for a Redis error, in the form: + * It emits the protocol for an error reply, in the form: * * -ERRORCODE Error Message * @@ -543,7 +543,7 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) { * * Where the master must propagate the first change even if the second * will produce an error. However it is useful to log such events since - * they are rare and may hint at errors in a script or a bug in Redis. */ + * they are rare and may hint at errors in a script or a bug in the server. */ int ctype = getClientType(c); if (ctype == CLIENT_TYPE_MASTER || ctype == CLIENT_TYPE_SLAVE || c->id == CLIENT_ID_AOF) { char *to, *from; @@ -1042,7 +1042,7 @@ void addReplyBulkLen(client *c, robj *obj) { addReplyLongLongWithPrefix(c,len,'$'); } -/* Add a Redis Object as a bulk reply */ +/* Add an Object as a bulk reply */ void addReplyBulk(client *c, robj *obj) { addReplyBulkLen(c,obj); addReply(c,obj); @@ -1121,7 +1121,7 @@ void addReplyVerbatim(client *c, const char *s, size_t len, const char *ext) { /* This function is similar to the addReplyHelp function but adds the * ability to pass in two arrays of strings. Some commands have * some additional subcommands based on the specific feature implementation - * Redis is compiled with (currently just clustering). This function allows + * the server is compiled with (currently just clustering). This function allows * to pass is the common subcommands in `help` and any implementation * specific subcommands in `extended_help`. */ @@ -1729,7 +1729,7 @@ void freeClient(client *c) { void freeClientAsync(client *c) { /* We need to handle concurrent access to the server.clients_to_close list * only in the freeClientAsync() function, since it's the only function that - * may access the list while Redis uses I/O threads. All the other accesses + * may access the list while the server uses I/O threads. All the other accesses * are in the context of the main thread while the other threads are * idle. */ if (c->flags & CLIENT_CLOSE_ASAP || c->flags & CLIENT_SCRIPT) return; @@ -2195,7 +2195,7 @@ int processInlineBuffer(client *c) { c->repl_ack_time = server.unixtime; /* Masters should never send us inline protocol to run actual - * commands. If this happens, it is likely due to a bug in Redis where + * commands. If this happens, it is likely due to a bug in the server where * we got some desynchronization in the protocol, for example * because of a PSYNC gone bad. * @@ -2219,7 +2219,7 @@ int processInlineBuffer(client *c) { c->argv_len_sum = 0; } - /* Create redis objects for all arguments. */ + /* Create an Object for all arguments. */ for (c->argc = 0, j = 0; j < argc; j++) { c->argv[c->argc] = createObject(OBJ_STRING,argv[j]); c->argc++; @@ -2654,7 +2654,7 @@ void readQueryFromClient(connection *conn) { * buffer contains exactly the SDS string representing the object, even * at the risk of requiring more read(2) calls. This way the function * processMultiBulkBuffer() can avoid copying buffers to create the - * Redis Object representing the argument. */ + * robj representing the argument. */ if (c->reqtype == PROTO_REQ_MULTIBULK && c->multibulklen && c->bulklen != -1 && c->bulklen >= PROTO_MBULK_BIG_ARG) { @@ -2747,7 +2747,7 @@ void readQueryFromClient(connection *conn) { beforeNextClient(c); } -/* A Redis "Address String" is a colon separated ip:port pair. +/* An "Address String" is a colon separated ip:port pair. * For IPv4 it's in the form x.y.z.k:port, example: "127.0.0.1:1234". * For IPv6 addresses we use [] around the IP part, like in "[::1]:1234". * For Unix sockets we use path:0, like in "/tmp/redis:0". @@ -3674,11 +3674,11 @@ void helloCommand(client *c) { /* This callback is bound to POST and "Host:" command names. Those are not * really commands, but are used in security attacks in order to talk to - * Redis instances via HTTP, with a technique called "cross protocol scripting" - * which exploits the fact that services like Redis will discard invalid + * instances via HTTP, with a technique called "cross protocol scripting" + * which exploits the fact that services like this server will discard invalid * HTTP headers and will process what follows. * - * As a protection against this attack, Redis will terminate the connection + * As a protection against this attack, the server will terminate the connection * when a POST or "Host:" header is seen, and will log the event from * time to time (to avoid creating a DOS as a result of too many logs). */ void securityWarningCommand(client *c) { @@ -3800,7 +3800,7 @@ void rewriteClientCommandArgument(client *c, int i, robj *newval) { } } -/* This function returns the number of bytes that Redis is +/* This function returns the number of bytes that the server is * using to store the reply still not read by the client. * * Note: this function is very fast so can be called as many time as @@ -4083,7 +4083,7 @@ static void pauseClientsByClient(mstime_t endTime, int isPauseClientAll) { * so that a failover without data loss to occur. Replicas will continue to receive * traffic to facilitate this functionality. * - * This function is also internally used by Redis Cluster for the manual + * This function is also internally used by Cluster for the manual * failover procedure implemented by CLUSTER FAILOVER. * * The function always succeed, even if there is already a pause in progress. @@ -4127,7 +4127,7 @@ uint32_t isPausedActionsWithUpdate(uint32_t actions_bitmask) { return (server.paused_actions & actions_bitmask); } -/* This function is called by Redis in order to process a few events from +/* This function is called by the server in order to process a few events from * time to time while blocked into some not interruptible operation. * This allows to reply to clients with the -LOADING error while loading the * data set at startup or after a full resynchronization with the master diff --git a/src/notify.c b/src/notify.c index 2881a48dba..3bf6d5fc62 100644 --- a/src/notify.c +++ b/src/notify.c @@ -93,13 +93,13 @@ sds keyspaceEventsFlagsToString(int flags) { return res; } -/* The API provided to the rest of the Redis core is a simple function: +/* The API provided to the rest of the serer core is a simple function: * * notifyKeyspaceEvent(int type, char *event, robj *key, int dbid); * * 'type' is the notification class we define in `server.h`. * 'event' is a C string representing the event name. - * 'key' is a Redis object representing the key name. + * 'key' is an Object representing the key name. * 'dbid' is the database ID where the key lives. */ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) { sds chan; diff --git a/src/object.c b/src/object.c index 8c00adbcba..a67f083a4b 100644 --- a/src/object.c +++ b/src/object.c @@ -1,4 +1,4 @@ -/* Redis Object implementation. +/* Object implementation. * * Copyright (c) 2009-2012, Salvatore Sanfilippo * All rights reserved. @@ -173,7 +173,7 @@ robj *createStringObjectFromLongLong(long long value) { /* The function avoids returning a shared integer when LFU/LRU info * are needed, that is, when the object is used as a value in the key - * space(for instance when the INCR command is used), and Redis is + * space(for instance when the INCR command is used), and the server is * configured to evict based on LFU/LRU, so we want LFU/LRU values * specific for each key. */ robj *createStringObjectFromLongLongForValue(long long value) { @@ -649,7 +649,7 @@ robj *tryObjectEncodingEx(robj *o, int try_trim) { if (!sdsEncodedObject(o)) return o; /* It's not safe to encode shared objects: shared objects can be shared - * everywhere in the "object space" of Redis and may end in places where + * everywhere in the "object space" of the server and may end in places where * they are not handled. We handle them only as values in the keyspace. */ if (o->refcount > 1) return o; @@ -1296,7 +1296,7 @@ void inputCatSds(void *result, const char *str) { *info = sdscat(*info, str); } -/* This implements MEMORY DOCTOR. An human readable analysis of the Redis +/* This implements MEMORY DOCTOR. An human readable analysis of the server * memory condition. */ sds getMemoryDoctorReport(void) { int empty = 0; /* Instance is empty or almost empty. */ @@ -1425,7 +1425,7 @@ int objectSetLRUOrLFU(robj *val, long long lfu_freq, long long lru_idle, } } else if (lru_idle >= 0) { /* Provided LRU idle time is in seconds. Scale - * according to the LRU clock resolution this Redis + * according to the LRU clock resolution this * instance was compiled with (normally 1000 ms, so the * below statement will expand to lru_idle*1000/1000. */ lru_idle = lru_idle*lru_multiplier/LRU_CLOCK_RESOLUTION; @@ -1457,7 +1457,7 @@ robj *objectCommandLookupOrReply(client *c, robj *key, robj *reply) { return o; } -/* Object command allows to inspect the internals of a Redis Object. +/* Object command allows to inspect the internals of an Object. * Usage: OBJECT */ void objectCommand(client *c) { robj *o; @@ -1513,7 +1513,7 @@ NULL } /* The memory command will eventually be a complete interface for the - * memory introspection capabilities of Redis. + * memory introspection capabilities of the server. * * Usage: MEMORY usage */ void memoryCommand(client *c) { diff --git a/src/pqsort.c b/src/pqsort.c index fab54e026a..ca4f99359d 100644 --- a/src/pqsort.c +++ b/src/pqsort.c @@ -1,5 +1,5 @@ /* The following is the NetBSD libc qsort implementation modified in order to - * support partial sorting of ranges for Redis. + * support partial sorting of ranges. * * Copyright(C) 2009-2012 Salvatore Sanfilippo. All rights reserved. * diff --git a/src/pqsort.h b/src/pqsort.h index 824ab5c096..5f1c5c1cd3 100644 --- a/src/pqsort.h +++ b/src/pqsort.h @@ -1,5 +1,5 @@ /* The following is the NetBSD libc qsort implementation modified in order to - * support partial sorting of ranges for Redis. + * support partial sorting of ranges. * * Copyright (c) 2009-2012, Salvatore Sanfilippo * All rights reserved. diff --git a/src/pubsub.c b/src/pubsub.c index b6db719b66..1fcad2565b 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -100,7 +100,7 @@ pubsubtype pubSubShardType = { *----------------------------------------------------------------------------*/ /* Send a pubsub message of type "message" to the client. - * Normally 'msg' is a Redis object containing the string to send as + * Normally 'msg' is an Object containing the string to send as * message. However if the caller sets 'msg' as NULL, it will be able * to send a special message (for instance an Array type) by using the * addReply*() API family. */ @@ -315,7 +315,7 @@ int pubsubUnsubscribeChannel(client *c, robj *channel, int notify, pubsubtype ty if (dictSize(clients) == 0) { /* Free the dict and associated hash entry at all if this was * the latest client, so that it will be possible to abuse - * Redis PUBSUB creating millions of channels. */ + * PUBSUB creating millions of channels. */ kvstoreDictDelete(*type.serverPubSubChannels, slot, channel); } } diff --git a/src/rax.h b/src/rax.h index c58c28b2c6..3604057d6f 100644 --- a/src/rax.h +++ b/src/rax.h @@ -159,7 +159,7 @@ typedef struct raxStack { * This callback is used to perform very low level analysis of the radix tree * structure, scanning each possible node (but the root node), or in order to * reallocate the nodes to reduce the allocation fragmentation (this is the - * Redis application for this callback). + * server's application for this callback). * * This is currently only supported in forward iterations (raxNext) */ typedef int (*raxNodeCallback)(raxNode **noderef); diff --git a/src/rdb.c b/src/rdb.c index f35a41d8ee..22dd658e18 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -127,7 +127,7 @@ int rdbLoadType(rio *rdb) { } /* This is only used to load old databases stored with the RDB_OPCODE_EXPIRETIME - * opcode. New versions of Redis store using the RDB_OPCODE_EXPIRETIME_MS + * opcode. New versions of the server store using the RDB_OPCODE_EXPIRETIME_MS * opcode. On error -1 is returned, however this could be a valid time, so * to check for loading errors the caller should call rioGetReadError() after * calling this function. */ @@ -144,13 +144,13 @@ ssize_t rdbSaveMillisecondTime(rio *rdb, long long t) { } /* This function loads a time from the RDB file. It gets the version of the - * RDB because, unfortunately, before Redis 5 (RDB version 9), the function + * RDB because, unfortunately, before Redis OSS 5 (RDB version 9), the function * failed to convert data to/from little endian, so RDB files with keys having * expires could not be shared between big endian and little endian systems * (because the expire time will be totally wrong). The fix for this is just * to call memrev64ifbe(), however if we fix this for all the RDB versions, * this call will introduce an incompatibility for big endian systems: - * after upgrading to Redis version 5 they will no longer be able to load their + * after upgrading to Redis OSS version 5 they will no longer be able to load their * own old RDB files. Because of that, we instead fix the function only for new * RDB versions, and load older RDB versions as we used to do in the past, * allowing big endian systems to load their own old RDB files. @@ -250,7 +250,7 @@ int rdbLoadLenByRef(rio *rdb, int *isencoded, uint64_t *lenptr) { /* This is like rdbLoadLenByRef() but directly returns the value read * from the RDB stream, signaling an error by returning RDB_LENERR - * (since it is a too large count to be applicable in any Redis data + * (since it is a too large count to be applicable in any server data * structure). */ uint64_t rdbLoadLen(rio *rdb, int *isencoded) { uint64_t len; @@ -490,7 +490,7 @@ ssize_t rdbSaveLongLongAsStringObject(rio *rdb, long long value) { return nwritten; } -/* Like rdbSaveRawString() gets a Redis object instead. */ +/* Like rdbSaveRawString() gets an Object instead. */ ssize_t rdbSaveStringObject(rio *rdb, robj *obj) { /* Avoid to decode the object, then encode it again, if the * object is already integer encoded. */ @@ -505,13 +505,13 @@ ssize_t rdbSaveStringObject(rio *rdb, robj *obj) { /* Load a string object from an RDB file according to flags: * * RDB_LOAD_NONE (no flags): load an RDB object, unencoded. - * RDB_LOAD_ENC: If the returned type is a Redis object, try to + * RDB_LOAD_ENC: If the returned type is an Object, try to * encode it in a special way to be more memory * efficient. When this flag is passed the function * no longer guarantees that obj->ptr is an SDS string. * RDB_LOAD_PLAIN: Return a plain string allocated with zmalloc() - * instead of a Redis object with an sds in it. - * RDB_LOAD_SDS: Return an SDS string instead of a Redis object. + * instead of an Object with an sds in it. + * RDB_LOAD_SDS: Return an SDS string instead of an Object. * * On I/O error NULL is returned. */ @@ -809,7 +809,7 @@ size_t rdbSaveStreamConsumers(rio *rdb, streamCG *cg) { return nwritten; } -/* Save a Redis object. +/* Save an Object. * Returns -1 on error, number of bytes written on success. */ ssize_t rdbSaveObject(rio *rdb, robj *o, robj *key, int dbid) { ssize_t n = 0, nwritten = 0; @@ -1377,7 +1377,7 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) { } /* Produces a dump of the database in RDB format sending it to the specified - * Redis I/O channel. On success C_OK is returned, otherwise C_ERR + * I/O channel. On success C_OK is returned, otherwise C_ERR * is returned and part of the output, or all the output, can be * missing because of I/O errors. * @@ -1632,7 +1632,7 @@ void rdbRemoveTempFile(pid_t childpid, int from_signal) { /* This function is called by rdbLoadObject() when the code is in RDB-check * mode and we find a module value of type 2 that can be parsed without * the need of the actual module. The value is parsed for errors, finally - * a dummy redis object is returned just to conform to the API. */ + * a dummy Object is returned just to conform to the API. */ robj *rdbLoadCheckModuleValue(rio *rdb, char *modulename) { uint64_t opcode; while((opcode = rdbLoadLen(rdb,NULL)) != RDB_MODULE_OPCODE_EOF) { @@ -1830,7 +1830,7 @@ int lpValidateIntegrityAndDups(unsigned char *lp, size_t size, int deep, int pai return ret; } -/* Load a Redis object of the specified type from the specified file. +/* Load an Object of the specified type from the specified file. * On success a newly allocated object is returned, otherwise NULL. * When the function returns NULL and if 'error' is not NULL, the * integer pointed by 'error' is set to the type of error that occurred */ @@ -2277,7 +2277,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) { return NULL; } /* Convert to ziplist encoded hash. This must be deprecated - * when loading dumps created by Redis 2.4 gets deprecated. */ + * when loading dumps created by Redis OSS 2.4 gets deprecated. */ { unsigned char *lp = lpNew(0); unsigned char *zi = zipmapRewind(o->ptr); @@ -3196,7 +3196,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin decrRefCount(auxval); continue; /* Read type again. */ } else if (type == RDB_OPCODE_MODULE_AUX) { - /* Load module data that is not related to the Redis key space. + /* Load module data that is not related to the server key space. * Such data can be potentially be stored both before and after the * RDB keys-values section. */ uint64_t moduleid = rdbLoadLen(rdb,NULL); @@ -3391,7 +3391,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin return C_OK; /* Unexpected end of file is handled here calling rdbReportReadError(): - * this will in turn either abort Redis in most cases, or if we are loading + * this will in turn either abort the server in most cases, or if we are loading * the RDB file from a socket during initial SYNC (diskless replica mode), * we'll report the error to the caller, so that we can retry. */ eoferr: diff --git a/src/release.c b/src/release.c index fdc1dbd5b2..a8b6fa188f 100644 --- a/src/release.c +++ b/src/release.c @@ -27,7 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* Every time the Redis Git SHA1 or Dirty status changes only this small +/* Every time the Git SHA1 or Dirty status changes only this small * file is recompiled, as we access this information in all the other * files using this functions. */ diff --git a/src/replication.c b/src/replication.c index 5fb477cd8b..f68c550983 100644 --- a/src/replication.c +++ b/src/replication.c @@ -233,7 +233,7 @@ int prepareReplicasToWrite(void) { return prepared; } -/* Wrapper for feedReplicationBuffer() that takes Redis string objects +/* Wrapper for feedReplicationBuffer() that takes string Objects * as input. */ void feedReplicationBufferWithObject(robj *o) { char llstr[LONG_STR_SIZE]; @@ -1030,7 +1030,7 @@ void syncCommand(client *c) { } } else { /* If a slave uses SYNC, we are dealing with an old implementation - * of the replication protocol (like redis-cli --slave). Flag the client + * of the replication protocol (like valkey-cli --slave). Flag the client * so that we don't expect to receive REPLCONF ACK feedbacks. */ c->flags |= CLIENT_PRE_PSYNC; } @@ -1142,7 +1142,7 @@ void syncCommand(client *c) { * * - listening-port * - ip-address - * What is the listening ip and port of the Replica redis instance, so that + * What is the listening ip and port of the Replica instance, so that * the master can accurately lists replicas and their listening ports in the * INFO output. * @@ -2038,7 +2038,7 @@ void readSyncBulkPayload(connection *conn) { /* We reach this point in one of the following cases: * * 1. The replica is using diskless replication, that is, it reads data - * directly from the socket to the Redis memory, without using + * directly from the socket to the server memory, without using * a temporary RDB file on disk. In that case we just block and * read everything from the socket. * @@ -2342,7 +2342,7 @@ char *sendCommand(connection *conn, ...) { size_t argslen = 0; char *arg; - /* Create the command to send to the master, we use redis binary + /* Create the command to send to the master, we use binary * protocol to make sure correct arguments are sent. This function * is not safe for all binary data. */ va_start(ap,conn); @@ -2665,7 +2665,7 @@ void syncWithMaster(connection *conn) { /* We accept only two replies as valid, a positive +PONG reply * (we just check for "+") or an authentication error. - * Note that older versions of Redis replied with "operation not + * Note that older versions of Redis OSS replied with "operation not * permitted" instead of using a proper error code, so we test * both. */ if (err[0] != '+' && @@ -2765,7 +2765,7 @@ void syncWithMaster(connection *conn) { if (server.repl_state == REPL_STATE_RECEIVE_PORT_REPLY) { err = receiveSynchronousResponse(conn); if (err == NULL) goto no_response_error; - /* Ignore the error if any, not all the Redis versions support + /* Ignore the error if any, not all the Redis OSS versions support * REPLCONF listening-port. */ if (err[0] == '-') { serverLog(LL_NOTICE,"(Non critical) Master does not understand " @@ -2783,7 +2783,7 @@ void syncWithMaster(connection *conn) { if (server.repl_state == REPL_STATE_RECEIVE_IP_REPLY) { err = receiveSynchronousResponse(conn); if (err == NULL) goto no_response_error; - /* Ignore the error if any, not all the Redis versions support + /* Ignore the error if any, not all the Redis OSS versions support * REPLCONF ip-address. */ if (err[0] == '-') { serverLog(LL_NOTICE,"(Non critical) Master does not understand " @@ -2798,7 +2798,7 @@ void syncWithMaster(connection *conn) { if (server.repl_state == REPL_STATE_RECEIVE_CAPA_REPLY) { err = receiveSynchronousResponse(conn); if (err == NULL) goto no_response_error; - /* Ignore the error if any, not all the Redis versions support + /* Ignore the error if any, not all the Redis OSS versions support * REPLCONF capa. */ if (err[0] == '-') { serverLog(LL_NOTICE,"(Non critical) Master does not understand " @@ -3465,9 +3465,9 @@ int checkGoodReplicasStatus(void) { } /* ----------------------- SYNCHRONOUS REPLICATION -------------------------- - * Redis synchronous replication design can be summarized in points: + * Synchronous replication design can be summarized in points: * - * - Redis masters have a global replication offset, used by PSYNC. + * - Masters have a global replication offset, used by PSYNC. * - Master increment the offset every time new commands are sent to slaves. * - Slaves ping back masters with the offset processed so far. * @@ -3777,7 +3777,7 @@ void replicationCron(void) { listLength(server.slaves)) { /* Note that we don't send the PING if the clients are paused during - * a Redis Cluster manual failover: the PING we send will otherwise + * a Cluster manual failover: the PING we send will otherwise * alter the replication offsets of master and slave, and will no longer * match the one stored into 'mf_master_offset' state. */ int manual_failover_in_progress = @@ -3895,7 +3895,7 @@ void replicationCron(void) { replicationStartPendingFork(); - /* Remove the RDB file used for replication if Redis is not running + /* Remove the RDB file used for replication if the server is not running * with any persistence. */ removeRDBUsedToSyncReplicas(); diff --git a/src/resp_parser.c b/src/resp_parser.c index b92a74cffb..df96d78a84 100644 --- a/src/resp_parser.c +++ b/src/resp_parser.c @@ -49,7 +49,7 @@ * time of parsing. Callers may calculate it themselves after parsing the * entire collection. * - * NOTE: This parser is designed to only handle replies generated by Redis + * NOTE: This parser is designed to only handle replies generated by the server * itself. It does not perform many required validations and thus NOT SAFE FOR * PARSING USER INPUT. * ---------------------------------------------------------------------------------------- diff --git a/src/rio.c b/src/rio.c index eaf88d25fc..9b1823e513 100644 --- a/src/rio.c +++ b/src/rio.c @@ -476,7 +476,7 @@ uint8_t rioCheckType(rio *r) { /* --------------------------- Higher level interface -------------------------- * * The following higher level functions use lower level rio.c functions to help - * generating the Redis protocol for the Append Only File. */ + * generating the RESP for the Append Only File. */ /* Write multi bulk count in the format: "*\r\n". */ size_t rioWriteBulkCount(rio *r, char prefix, long count) { diff --git a/src/script.c b/src/script.c index fd7c616717..db42e2f455 100644 --- a/src/script.c +++ b/src/script.c @@ -424,7 +424,7 @@ static int scriptVerifyClusterState(scriptRunCtx *run_ctx, client *c, client *or if (!server.cluster_enabled || mustObeyClient(original_c)) { return C_OK; } - /* If this is a Redis Cluster node, we need to make sure the script is not + /* If this is a Cluster node, we need to make sure the script is not * trying to access non-local keys, with the exception of commands * received from our master or when loading the AOF back in memory. */ int error_code; @@ -527,7 +527,7 @@ static int scriptVerifyAllowStale(client *c, sds *err) { return C_ERR; } -/* Call a Redis command. +/* Call a server command. * The reply is written to the run_ctx client and it is * up to the engine to take and parse. * The err out variable is set only if error occurs and describe the error. diff --git a/src/script.h b/src/script.h index caf95ef959..307eb41bd0 100644 --- a/src/script.h +++ b/src/script.h @@ -32,9 +32,9 @@ /* * Script.c unit provides an API for functions and eval - * to interact with Redis. Interaction includes mostly + * to interact with the server. Interaction includes mostly * executing commands, but also functionalities like calling - * Redis back on long scripts or check if the script was killed. + * the server back on long scripts or check if the script was killed. * * The interaction is done using a scriptRunCtx object that * need to be created by the user and initialized using scriptPrepareForRun. @@ -44,7 +44,7 @@ * acl, cluster, read only run, ...) * 2. Set Resp * 3. Set Replication method (AOF/REPLICATION/NONE) - * 4. Call Redis back to on long running scripts to allow Redis reply + * 4. Call the server back to on long running scripts to allow the server reply * to clients and perform script kill */ diff --git a/src/script_lua.c b/src/script_lua.c index fbfc73eb9f..24784c1d85 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -55,7 +55,7 @@ static char *libraries_allow_list[] = { NULL, }; -/* Redis Lua API globals */ +/* Lua API globals */ static char *redis_api_allow_list[] = { SERVER_API_NAME, REDIS_API_NAME, @@ -192,21 +192,21 @@ void* luaGetFromRegistry(lua_State* lua, const char* name) { } /* --------------------------------------------------------------------------- - * Redis reply to Lua type conversion functions. + * Server reply to Lua type conversion functions. * ------------------------------------------------------------------------- */ -/* Take a Redis reply in the Redis protocol format and convert it into a +/* Take a server reply in the RESP format and convert it into a * Lua type. Thanks to this function, and the introduction of not connected * clients, it is trivial to implement the redis() lua function. * - * Basically we take the arguments, execute the Redis command in the context + * Basically we take the arguments, execute the command in the context * of a non connected client, then take the generated reply and convert it * into a suitable Lua type. With this trick the scripting feature does not - * need the introduction of a full Redis internals API. The script + * need the introduction of a full server internals API. The script * is like a normal client that bypasses all the slow I/O paths. * * Note: in this function we do not do any sanity check as the reply is - * generated by Redis directly. This allows us to go faster. + * generated by the server directly. This allows us to go faster. * * Errors are returned as a table with a single 'err' field set to the * error string. @@ -536,7 +536,7 @@ void luaPushErrorBuff(lua_State *lua, sds err_buffer) { sds error_code; /* If debugging is active and in step mode, log errors resulting from - * Redis commands. */ + * server commands. */ if (ldbIsEnabled()) { ldbLog(sdscatprintf(sdsempty()," %s",err_buffer)); } @@ -563,8 +563,8 @@ void luaPushErrorBuff(lua_State *lua, sds err_buffer) { msg = err_buffer; error_code = sdsnew("ERR"); } - /* Trim newline at end of string. If we reuse the ready-made Redis error objects (case 1 above) then we might - * have a newline that needs to be trimmed. In any case the lua Redis error table shouldn't end with a newline. */ + /* Trim newline at end of string. If we reuse the ready-made error objects (case 1 above) then we might + * have a newline that needs to be trimmed. In any case the lua server error table shouldn't end with a newline. */ msg = sdstrim(msg, "\r\n"); sds final_msg = sdscatfmt(error_code, " %s", msg); @@ -591,11 +591,11 @@ int luaError(lua_State *lua) { /* --------------------------------------------------------------------------- - * Lua reply to Redis reply conversion functions. + * Lua reply to server reply conversion functions. * ------------------------------------------------------------------------- */ /* Reply to client 'c' converting the top element in the Lua stack to a - * Redis reply. As a side effect the element is consumed from the stack. */ + * server reply. As a side effect the element is consumed from the stack. */ static void luaReplyToRedisReply(client *c, client* script_client, lua_State *lua) { int t = lua_type(lua,-1); @@ -953,7 +953,7 @@ static int luaRedisGenericCommand(lua_State *lua, int raise_error) { goto cleanup; } - /* Convert the result of the Redis command into a suitable Lua type. + /* Convert the result of the command into a suitable Lua type. * The first thing we need is to create a single string from the client * output buffers. */ if (listLength(c->reply) == 0 && (size_t)c->bufpos < c->buf_usable_size) { @@ -976,7 +976,7 @@ static int luaRedisGenericCommand(lua_State *lua, int raise_error) { if (raise_error && reply[0] != '-') raise_error = 0; redisProtocolToLuaType(lua,reply); - /* If the debugger is active, log the reply from Redis. */ + /* If the debugger is active, log the reply from the server. */ if (ldbIsEnabled()) ldbLogRedisReply(reply); @@ -1004,9 +1004,9 @@ static int luaRedisGenericCommand(lua_State *lua, int raise_error) { /* Our implementation to lua pcall. * We need this implementation for backward - * comparability with older Redis versions. + * comparability with older Redis OSS versions. * - * On Redis 7, the error object is a table, + * On Redis OSS 7, the error object is a table, * compare to older version where the error * object is a string. To keep backward * comparability we catch the table object @@ -1062,7 +1062,7 @@ static int luaRedisSha1hexCommand(lua_State *lua) { /* Returns a table with a single field 'field' set to the string value * passed as argument. This helper function is handy when returning - * a Redis Protocol error or status reply from Lua: + * a RESP error or status reply from Lua: * * return redis.error_reply("ERR Some Error") * return redis.status_reply("ERR Some Error") @@ -1440,7 +1440,7 @@ void luaRegisterRedisAPI(lua_State* lua) { lua_pushcfunction(lua,luaRedisPcall); lua_setglobal(lua, "pcall"); - /* Register the redis commands table and fields */ + /* Register the commands table and fields */ lua_newtable(lua); /* redis.call */ @@ -1527,7 +1527,7 @@ void luaRegisterRedisAPI(lua_State* lua) { lua_setglobal(lua,"math"); } -/* Set an array of Redis String Objects as a Lua array (table) stored into a +/* Set an array of String Objects as a Lua array (table) stored into a * global variable. */ static void luaCreateArray(lua_State *lua, robj **elev, int elec) { int j; @@ -1540,7 +1540,7 @@ static void luaCreateArray(lua_State *lua, robj **elev, int elec) { } /* --------------------------------------------------------------------------- - * Redis provided math.random + * Custom provided math.random * ------------------------------------------------------------------------- */ /* We replace math.random() with our implementation that is not affected @@ -1735,7 +1735,7 @@ void luaCallFunction(scriptRunCtx* run_ctx, lua_State *lua, robj** keys, size_t } lua_pop(lua,1); /* Consume the Lua error */ } else { - /* On success convert the Lua return value into Redis protocol, and + /* On success convert the Lua return value into RESP, and * send it to * the client. */ luaReplyToRedisReply(c, run_ctx->c, lua); /* Convert and consume the reply. */ } diff --git a/src/script_lua.h b/src/script_lua.h index 07446725d3..73210e6b36 100644 --- a/src/script_lua.h +++ b/src/script_lua.h @@ -38,10 +38,10 @@ * the top of the Lua stack. In addition, parsing the execution * result and convert it to the resp and reply to the client. * - * * Run Redis commands from within the Lua code (Including + * * Run server commands from within the Lua code (Including * parsing the reply and create a Lua object out of it). * - * * Register Redis API to the Lua interpreter. Only shared + * * Register the server API to the Lua interpreter. Only shared * API are registered (API that is only relevant on eval.c * (like debugging) are registered on eval.c). * diff --git a/src/sentinel.c b/src/sentinel.c index 24e8c3ded9..ad2ebdd510 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1,4 +1,4 @@ -/* Redis Sentinel implementation +/* Sentinel implementation * * Copyright (c) 2009-2012, Salvatore Sanfilippo * All rights reserved. @@ -60,7 +60,7 @@ typedef struct sentinelAddr { int port; } sentinelAddr; -/* A Sentinel Redis Instance object is monitoring. */ +/* A Sentinel Instance object is monitoring. */ #define SRI_MASTER (1<<0) #define SRI_SLAVE (1<<1) #define SRI_SENTINEL (1<<2) @@ -477,7 +477,7 @@ const char *preMonitorCfgName[] = { "announce-hostnames" }; -/* This function overwrites a few normal Redis config default with Sentinel +/* This function overwrites a few normal server config default with Sentinel * specific defaults. */ void initSentinelConfig(void) { server.port = REDIS_SENTINEL_PORT; @@ -617,7 +617,7 @@ int sentinelAddrEqualsHostname(sentinelAddr *a, char *hostname) { sentinel.resolve_hostnames ? ANET_NONE : ANET_IP_ONLY) == ANET_ERR) { /* If failed resolve then compare based on hostnames. That is our best effort as - * long as the server is unavailable for some reason. It is fine since Redis + * long as the server is unavailable for some reason. It is fine since an * instance cannot have multiple hostnames for a given setup */ return !strcasecmp(sentinel.resolve_hostnames ? a->hostname : a->ip, hostname); } @@ -649,7 +649,7 @@ sds announceSentinelAddrAndPort(const sentinelAddr *a) { * * 'type' is the message type, also used as a pub/sub channel name. * - * 'ri', is the redis instance target of this event if applicable, and is + * 'ri', is the server instance target of this event if applicable, and is * used to obtain the path of the notification script to execute. * * The remaining arguments are printf-alike. @@ -1260,7 +1260,7 @@ void sentinelDisconnectCallback(const redisAsyncContext *c, int status) { /* ========================== sentinelRedisInstance ========================= */ -/* Create a redis instance, the following fields must be populated by the +/* Create an instance of the server, the following fields must be populated by the * caller if needed: * runid: set to NULL but will be populated once INFO output is received. * info_refresh: is set to 0 to mean that we never received INFO so far. @@ -1406,7 +1406,7 @@ void releaseSentinelRedisInstance(sentinelRedisInstance *ri) { zfree(ri); } -/* Lookup a slave in a master Redis instance, by ip and port. */ +/* Lookup a slave in a master instance, by ip and port. */ sentinelRedisInstance *sentinelRedisInstanceLookupSlave( sentinelRedisInstance *ri, char *slave_addr, int port) { @@ -1696,7 +1696,7 @@ void sentinelPropagateDownAfterPeriod(sentinelRedisInstance *master) { } } -/* This function is used in order to send commands to Redis instances: the +/* This function is used in order to send commands to server instances: the * commands we send from Sentinel may be renamed, a common case is a master * with CONFIG and SLAVEOF commands renamed for security concerns. In that * case we check the ri->renamed_command table (or if the instance is a slave, @@ -2274,10 +2274,10 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) { rewriteConfigMarkAsProcessed(state,"sentinel master-reboot-down-after-period"); } -/* This function uses the config rewriting Redis engine in order to persist +/* This function uses the config rewriting in order to persist * the state of the Sentinel in the current configuration file. * - * On failure the function logs a warning on the Redis log. */ + * On failure the function logs a warning on the server log. */ int sentinelFlushConfig(void) { int saved_hz = server.hz; int rewrite_status; @@ -2356,12 +2356,12 @@ void sentinelSendAuthIfNeeded(sentinelRedisInstance *ri, redisAsyncContext *c) { } } -/* Use CLIENT SETNAME to name the connection in the Redis instance as +/* Use CLIENT SETNAME to name the connection in the instance as * sentinel-- * The connection type is "cmd" or "pubsub" as specified by 'type'. * * This makes it possible to list all the sentinel instances connected - * to a Redis server with CLIENT LIST, grepping for a specific name format. */ + * to a server with CLIENT LIST, grepping for a specific name format. */ void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char *type) { char name[64]; @@ -2491,7 +2491,7 @@ void sentinelReconnectInstance(sentinelRedisInstance *ri) { link->disconnected = 0; } -/* ======================== Redis instances pinging ======================== */ +/* ======================== Server instances pinging ======================== */ /* Return true if master looks "sane", that is: * 1) It is actually a master in the current configuration. @@ -3002,7 +3002,7 @@ void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privd sentinelProcessHelloMessage(r->element[2]->str, r->element[2]->len); } -/* Send a "Hello" message via Pub/Sub to the specified 'ri' Redis +/* Send a "Hello" message via Pub/Sub to the specified 'ri' server * instance in order to broadcast the current configuration for this * master, and to advertise the existence of this Sentinel at the same time. * @@ -3071,7 +3071,7 @@ void sentinelForceHelloUpdateDictOfRedisInstances(dict *instances) { } /* This function forces the delivery of a "Hello" message (see - * sentinelSendHello() top comment for further information) to all the Redis + * sentinelSendHello() top comment for further information) to all the server * and Sentinel instances related to the specified 'master'. * * It is technically not needed since we send an update to every instance @@ -3395,7 +3395,7 @@ const char *sentinelFailoverStateStr(int state) { } } -/* Redis instance to Redis protocol representation. */ +/* Server instance to RESP representation. */ void addReplySentinelRedisInstance(client *c, sentinelRedisInstance *ri) { char *flags = sdsempty(); void *mbl; @@ -3800,7 +3800,7 @@ void addReplySentinelDebugInfo(client *c) { } /* Output a number of instances contained inside a dictionary as - * Redis protocol. */ + * RESP. */ void addReplyDictOfRedisInstances(client *c, dict *instances) { dictIterator *di; dictEntry *de; @@ -4868,7 +4868,7 @@ char *sentinelGetLeader(sentinelRedisInstance *master, uint64_t epoch) { /* Send SLAVEOF to the specified instance, always followed by a * CONFIG REWRITE command in order to store the new configuration on disk - * when possible (that is, if the Redis instance is recent enough to support + * when possible (that is, if the instance is recent enough to support * config rewriting, and if the server was started with a configuration file). * * If Host is NULL the function sends "SLAVEOF NO ONE". @@ -4920,9 +4920,9 @@ int sentinelSendSlaveOf(sentinelRedisInstance *ri, const sentinelAddr *addr) { if (retval == C_ERR) return retval; ri->link->pending_commands++; - /* CLIENT KILL TYPE is only supported starting from Redis 2.8.12, + /* CLIENT KILL TYPE is only supported starting from Redis OSS 2.8.12, * however sending it to an instance not understanding this command is not - * an issue because CLIENT is variadic command, so Redis will not + * an issue because CLIENT is variadic command, so the server will not * recognized as a syntax error, and the transaction will not fail (but * only the unsupported command will fail). */ for (int type = 0; type < 2; type++) { @@ -5048,7 +5048,7 @@ int compareSlavesForPromotion(const void *a, const void *b) { /* If the replication offset is the same select the slave with that has * the lexicographically smaller runid. Note that we try to handle runid - * == NULL as there are old Redis versions that don't publish runid in + * == NULL as there are old Redis OSS versions that don't publish runid in * INFO. A NULL runid is considered bigger than any other runid. */ sa_runid = (*sa)->runid; sb_runid = (*sb)->runid; @@ -5374,7 +5374,7 @@ void sentinelAbortFailover(sentinelRedisInstance *ri) { * in design. * -------------------------------------------------------------------------- */ -/* Perform scheduled operations for the specified Redis instance. */ +/* Perform scheduled operations for the specified instance. */ void sentinelHandleRedisInstance(sentinelRedisInstance *ri) { /* ========== MONITORING HALF ============ */ /* Every kind of instance */ @@ -5473,7 +5473,7 @@ void sentinelTimer(void) { sentinelCollectTerminatedScripts(); sentinelKillTimedoutScripts(); - /* We continuously change the frequency of the Redis "timer interrupt" + /* We continuously change the frequency of the server "timer interrupt" * in order to desynchronize every Sentinel from every other. * This non-determinism avoids that Sentinels started at the same time * exactly continue to stay synchronized asking to be voted at the diff --git a/src/server.c b/src/server.c index 756039a071..a6069c0161 100644 --- a/src/server.c +++ b/src/server.c @@ -105,7 +105,7 @@ const char *replstateToString(int replstate); ((server.current_client && server.current_client->id == CLIENT_ID_AOF) ? 1 : 0) /* We use a private localtime implementation which is fork-safe. The logging - * function of Redis may be called from other threads. */ + * function of the server may be called from other threads. */ void nolocks_localtime(struct tm *tmp, time_t t, time_t tz, int dst); /* Low level logging. To use only for very big messages, otherwise @@ -201,7 +201,7 @@ void serverLogRawFromHandler(int level, const char *msg) { * with LL_RAW flag only the msg is printed (with no new line at the end) * * We actually use this only for signals that are not fatal from the point - * of view of Redis. Signals that are going to kill the server anyway and + * of view of the server. Signals that are going to kill the server anyway and * where we need printf-alike features are served by serverLog(). */ void serverLogFromHandler(int level, const char *fmt, ...) { va_list ap; @@ -267,7 +267,7 @@ void exitFromChild(int retcode) { /*====================== Hash table type implementation ==================== */ /* This is a hash table type that uses the SDS dynamic strings library as - * keys and redis objects as values (objects can hold SDS strings, + * keys and Objects as values (Objects can hold SDS strings, * lists, sets). */ void dictVanillaFree(dict *d, void *val) @@ -423,10 +423,10 @@ uint64_t dictEncObjHash(const void *key) { } /* Return 1 if currently we allow dict to expand. Dict may allocate huge - * memory to contain hash buckets when dict expands, that may lead redis - * rejects user's requests or evicts some keys, we can stop dict to expand + * memory to contain hash buckets when dict expands, that may lead the server to + * reject user's requests or evict some keys, we can stop dict to expand * provisionally if used memory will be over maxmemory after dict expands, - * but to guarantee the performance of redis, we still allow dict to expand + * but to guarantee the performance of the server, we still allow dict to expand * if dict load factor exceeds HASHTABLE_MAX_LOAD_FACTOR. */ int dictResizeAllowed(size_t moreMem, double usedRatio) { /* for debug purposes: dict is not allowed to be resized. */ @@ -439,7 +439,7 @@ int dictResizeAllowed(size_t moreMem, double usedRatio) { } } -/* Generic hash table type where keys are Redis Objects, Values +/* Generic hash table type where keys are Objects, Values * dummy pointers. */ dictType objectKeyPointerValueDictType = { dictEncObjHash, /* hash function */ @@ -487,7 +487,7 @@ dictType zsetDictType = { NULL, /* allow to expand */ }; -/* Db->dict, keys are sds strings, vals are Redis objects. */ +/* Db->dict, keys are sds strings, vals are Objects. */ dictType dbDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ @@ -542,7 +542,7 @@ dictType sdsReplyDictType = { NULL /* allow to expand */ }; -/* Keylist hash table type has unencoded redis objects as keys and +/* Keylist hash table type has unencoded Objects as keys and * lists as values. It's used for blocking operations (BLPOP) and to * map swapped keys to a list of clients waiting for this keys to be loaded. */ dictType keylistDictType = { @@ -555,7 +555,7 @@ dictType keylistDictType = { NULL /* allow to expand */ }; -/* KeyDict hash table type has unencoded redis objects as keys and +/* KeyDict hash table type has unencoded Objects as keys and * dicts as values. It's used for PUBSUB command to track clients subscribing the channels. */ dictType objToDictDictType = { dictObjHash, /* hash function */ @@ -979,7 +979,7 @@ void getExpansiveClientsInfo(size_t *in_usage, size_t *out_usage) { * commands. * * It is very important for this function, and the functions it calls, to be - * very fast: sometimes Redis has tens of hundreds of connected clients, and the + * very fast: sometimes the server has tens of hundreds of connected clients, and the * default server.hz value is 10, so sometimes here we need to process thousands * of clients per second, turning this function into a source of latency. */ @@ -1050,7 +1050,7 @@ void clientsCron(void) { } /* This function handles 'background' operations we are required to do - * incrementally in Redis databases, such as active key expiring, resizing, + * incrementally in the databases, such as active key expiring, resizing, * rehashing. */ void databasesCron(void) { /* Expire keys by random sampling. Not required for slaves @@ -1326,7 +1326,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { * * Note that even if the counter wraps it's not a big problem, * everything will still work but some object will appear younger - * to Redis. However for this to happen a given object should never be + * to the server. However for this to happen a given object should never be * touched for all the time needed to the counter to wrap, which is * not likely. * @@ -1383,7 +1383,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { /* We need to do a few operations on clients asynchronously. */ clientsCron(); - /* Handle background operations on Redis databases. */ + /* Handle background operations on databases. */ databasesCron(); /* Start a scheduled AOF rewrite if this was requested by the user while @@ -1470,7 +1470,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { /* Replication cron function -- used to reconnect to master, * detect transfer failures, start background RDB transfers and so forth. * - * If Redis is trying to failover then run the replication cron faster so + * If the server is trying to failover then run the replication cron faster so * progress on the handshake happens more quickly. */ if (server.failover_state != NO_FAILOVER) { run_with_period(100) replicationCron(); @@ -1478,7 +1478,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { run_with_period(1000) replicationCron(); } - /* Run the Redis Cluster cron. */ + /* Run the Cluster cron. */ run_with_period(100) { if (server.cluster_enabled) clusterCron(); } @@ -1617,7 +1617,7 @@ static void sendGetackToReplicas(void) { extern int ProcessingEventsWhileBlocked; -/* This function gets called every time Redis is entering the +/* This function gets called every time the server is entering the * main loop of the event driven library, that is, before to sleep * for ready file descriptors. * @@ -1664,8 +1664,8 @@ void beforeSleep(struct aeEventLoop *eventLoop) { /* If any connection type(typical TLS) still has pending unread data don't sleep at all. */ int dont_sleep = connTypeHasPendingData(); - /* Call the Redis Cluster before sleep function. Note that this function - * may change the state of Redis Cluster (from ok to fail or vice versa), + /* Call the Cluster before sleep function. Note that this function + * may change the state of Cluster (from ok to fail or vice versa), * so it's a good idea to call it before serving the unblocked clients * later in this function, must be done before blockedBeforeSleep. */ if (server.cluster_enabled) clusterBeforeSleep(); @@ -1791,7 +1791,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) { aeSetDontWait(server.el, dont_sleep); /* Before we are going to sleep, let the threads access the dataset by - * releasing the GIL. Redis main thread will not touch anything at this + * releasing the GIL. The server main thread will not touch anything at this * time. */ if (moduleCount()) moduleReleaseGIL(); /********************* WARNING ******************** @@ -1800,7 +1800,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) { } /* This function is called immediately after the event loop multiplexing - * API returned, and the control is going to soon return to Redis by invoking + * API returned, and the control is going to soon return to the server by invoking * the different events callbacks. */ void afterSleep(struct aeEventLoop *eventLoop) { UNUSED(eventLoop); @@ -2198,7 +2198,7 @@ int restartServer(int flags, mstime_t delay) { } /* Close all file descriptors, with the exception of stdin, stdout, stderr - * which are useful if we restart a Redis server which is not daemonized. */ + * which are useful if we restart a server which is not daemonized. */ for (j = 3; j < (int)server.maxclients + 1024; j++) { /* Test the descriptor validity before closing it, otherwise * Valgrind issues a warning on close(). */ @@ -2231,7 +2231,7 @@ int setOOMScoreAdj(int process_class) { serverAssert(process_class >= 0 && process_class < CONFIG_OOM_COUNT); #ifdef HAVE_PROC_OOM_SCORE_ADJ - /* The following statics are used to indicate Redis has changed the process's oom score. + /* The following statics are used to indicate the server has changed the process's oom score. * And to save the original score so we can restore it later if needed. * We need this so when we disabled oom-score-adj (also during configuration rollback * when another configuration parameter was invalid and causes a rollback after @@ -2247,7 +2247,7 @@ int setOOMScoreAdj(int process_class) { if (server.oom_score_adj != OOM_SCORE_ADJ_NO) { if (!oom_score_adjusted_by_redis) { oom_score_adjusted_by_redis = 1; - /* Backup base value before enabling Redis control over oom score */ + /* Backup base value before enabling the server control over oom score */ fd = open("/proc/self/oom_score_adj", O_RDONLY); if (fd < 0 || read(fd, buf, sizeof(buf)) < 0) { serverLog(LL_WARNING, "Unable to read oom_score_adj: %s", strerror(errno)); @@ -2449,7 +2449,7 @@ int createSocketAcceptHandler(connListener *sfd, aeFileProc *accept_handler) { } /* Initialize a set of file descriptors to listen to the specified 'port' - * binding the addresses specified in the Redis server configuration. + * binding the addresses specified in the server configuration. * * The listening file descriptors are stored in the integer array 'fds' * and their number is set in '*count'. Actually @sfd should be 'listener', @@ -2657,7 +2657,7 @@ void initServer(void) { } server.db = zmalloc(sizeof(server)*server.dbnum); - /* Create the Redis databases, and initialize other internal state. */ + /* Create the databases, and initialize other internal state. */ int slot_count_bits = 0; int flags = KVSTORE_ALLOCATE_DICTS_ON_DEMAND; if (server.cluster_enabled) { @@ -2768,7 +2768,7 @@ void initServer(void) { /* 32 bit instances are limited to 4GB of address space, so if there is * no explicit limit in the user provided configuration we set a limit * at 3 GB using maxmemory with 'noeviction' policy'. This avoids - * useless crashes of the Redis instance for out of memory. */ + * useless crashes of the instance for out of memory. */ if (server.arch_bits == 32 && server.maxmemory == 0) { serverLog(LL_WARNING,"Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now."); server.maxmemory = 3072LL*(1024*1024); /* 3 GB */ @@ -2893,7 +2893,7 @@ void InitServerLast(void) { * 3. The order of the range specs must be ascending (i.e. * lastkey of spec[i] == firstkey-1 of spec[i+1]). * - * This function will succeed on all native Redis commands and may + * This function will succeed on all native commands and may * fail on module commands, even if it only has "range" specs that * could actually be "glued", in the following cases: * 1. The order of "range" specs is not ascending (e.g. the spec for @@ -2910,7 +2910,7 @@ void populateCommandLegacyRangeSpec(struct serverCommand *c) { memset(&c->legacy_range_key_spec, 0, sizeof(c->legacy_range_key_spec)); /* Set the movablekeys flag if we have a GETKEYS flag for modules. - * Note that for native redis commands, we always have keyspecs, + * Note that for native commands, we always have keyspecs, * with enough information to rely on for movablekeys. */ if (c->flags & CMD_MODULE_GETKEYS) c->flags |= CMD_MOVABLE_KEYS; @@ -3062,7 +3062,7 @@ int populateCommandStructure(struct serverCommand *c) { extern struct serverCommand serverCommandTable[]; -/* Populates the Redis Command Table dict from the static table in commands.c +/* Populates the Command Table dict from the static table in commands.c * which is auto generated from the json files in the commands folder. */ void populateCommandTable(void) { int j; @@ -3115,7 +3115,7 @@ void resetErrorTableStats(void) { server.errors_enabled = 1; } -/* ========================== Redis OP Array API ============================ */ +/* ========================== OP Array API ============================ */ int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int target) { serverOp *op; @@ -3303,8 +3303,8 @@ static void propagateNow(int dbid, robj **argv, int argc, int target) { * after the current command is propagated to AOF / Replication. * * dbid is the database ID the command should be propagated into. - * Arguments of the command to propagate are passed as an array of redis - * objects pointers of len 'argc', using the 'argv' vector. + * Arguments of the command to propagate are passed as an array of + * Objects pointers of len 'argc', using the 'argv' vector. * * The function does not take a reference to the passed 'argv' vector, * so it is up to the caller to release the passed argv (but it is usually @@ -3326,7 +3326,7 @@ void alsoPropagate(int dbid, robj **argv, int argc, int target) { } /* It is possible to call the function forceCommandPropagation() inside a - * Redis command implementation in order to to force the propagation of a + * command implementation in order to to force the propagation of a * specific command execution into AOF / Replication. */ void forceCommandPropagation(client *c, int flags) { serverAssert(c->cmd->flags & (CMD_WRITE | CMD_MAY_REPLICATE)); @@ -3424,7 +3424,7 @@ static void propagatePendingCommands(void) { /* Performs operations that should be performed after an execution unit ends. * Execution unit is a code that should be done atomically. - * Execution units can be nested and are not necessarily starts with Redis command. + * Execution units can be nested and do not necessarily start with a server command. * * For example the following is a logical unit: * active expire -> @@ -3478,7 +3478,7 @@ int incrCommandStatsOnError(struct serverCommand *cmd, int flags) { return res; } -/* Call() is the core of Redis execution of a command. +/* Call() is the core of the server's execution of a command. * * The following flags can be passed: * CMD_CALL_NONE No flags. @@ -3534,7 +3534,7 @@ void call(client *c, int flags) { * demand, and initialize the array for additional commands propagation. */ c->flags &= ~(CLIENT_FORCE_AOF|CLIENT_FORCE_REPL|CLIENT_PREVENT_PROP); - /* Redis core is in charge of propagation when the first entry point + /* The server core is in charge of propagation when the first entry point * of call() is processCommand(). * The only other option to get to call() without having processCommand * as an entry point is if a module triggers RM_Call outside of call() @@ -4432,7 +4432,7 @@ int finishShutdown(void) { * doing it's cleanup, but in this case this code will not be reached, * so we need to call rdbRemoveTempFile which will close fd(in order * to unlink file actually) in background thread. - * The temp rdb file fd may won't be closed when redis exits quickly, + * The temp rdb file fd may won't be closed when the server exits quickly, * but OS will close this fd when process exits. */ rdbRemoveTempFile(server.child_pid, 0); } @@ -4484,7 +4484,7 @@ int finishShutdown(void) { if (rdbSave(SLAVE_REQ_NONE,server.rdb_filename,rsiptr,RDBFLAGS_KEEP_CACHE) != C_OK) { /* Ooops.. error saving! The best we can do is to continue * operating. Note that if there was a background saving process, - * in the next cron() Redis will be notified that the background + * in the next cron() the server will be notified that the background * saving aborted, handling special stuff like slaves pending for * synchronization... */ if (force) { @@ -4537,8 +4537,8 @@ int finishShutdown(void) { /*================================== Commands =============================== */ -/* Sometimes Redis cannot accept write commands because there is a persistence - * error with the RDB or AOF file, and Redis is configured in order to stop +/* Sometimes the server cannot accept write commands because there is a persistence + * error with the RDB or AOF file, and the server is configured in order to stop * accepting writes in such situation. This function returns if such a * condition is active, and the type of the condition. * @@ -4952,7 +4952,7 @@ void addReplyCommandSubCommands(client *c, struct serverCommand *cmd, void (*rep dictReleaseIterator(di); } -/* Output the representation of a Redis command. Used by the COMMAND command and COMMAND INFO. */ +/* Output the representation of a server command. Used by the COMMAND command and COMMAND INFO. */ void addReplyCommandInfo(client *c, struct serverCommand *cmd) { if (!cmd) { addReplyNull(c); @@ -4980,7 +4980,7 @@ void addReplyCommandInfo(client *c, struct serverCommand *cmd) { } } -/* Output the representation of a Redis command. Used by the COMMAND DOCS. */ +/* Output the representation of a server command. Used by the COMMAND DOCS. */ void addReplyCommandDocs(client *c, struct serverCommand *cmd) { /* Count our reply len so we don't have to use deferred reply. */ long maplen = 1; @@ -6253,7 +6253,7 @@ void daemonize(void) { if (fork() != 0) exit(0); /* parent exits */ setsid(); /* create a new session */ - /* Every output goes to /dev/null. If Redis is daemonized but + /* Every output goes to /dev/null. If the server is daemonized but * the 'logfile' is set to 'stdout' in the configuration file * it will not log at all. */ if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { @@ -6994,8 +6994,8 @@ int main(int argc, char **argv) { initSentinel(); } - /* Check if we need to start in redis-check-rdb/aof mode. We just execute - * the program main. However the program is part of the Redis executable + /* Check if we need to start in valkey-check-rdb/aof mode. We just execute + * the program main. However the program is part of the server executable * so that we can easily execute an RDB check on loading errors. */ if (strstr(exec_name,"valkey-check-rdb") != NULL) redis_check_rdb_main(argc,argv,NULL); diff --git a/src/server.h b/src/server.h index 0ca24e3c92..d891fccfb1 100644 --- a/src/server.h +++ b/src/server.h @@ -82,9 +82,9 @@ typedef long long ustime_t; /* microsecond time type. */ #define VALKEYMODULE_CORE 1 typedef struct serverObject robj; -#include "valkeymodule.h" /* Redis modules API defines. */ +#include "valkeymodule.h" /* Modules API defines. */ -/* Following includes allow test functions to be called from Redis main() */ +/* Following includes allow test functions to be called from main() */ #include "zipmap.h" #include "ziplist.h" /* Compact list data structure */ #include "sha1.h" @@ -225,7 +225,7 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT]; #define CMD_NO_MANDATORY_KEYS (1ULL<<19) #define CMD_PROTECTED (1ULL<<20) #define CMD_MODULE_GETKEYS (1ULL<<21) /* Use the modules getkeys interface. */ -#define CMD_MODULE_NO_CLUSTER (1ULL<<22) /* Deny on Redis Cluster. */ +#define CMD_MODULE_NO_CLUSTER (1ULL<<22) /* Deny on Cluster. */ #define CMD_NO_ASYNC_LOADING (1ULL<<23) #define CMD_NO_MULTI (1ULL<<24) #define CMD_MOVABLE_KEYS (1ULL<<25) /* The legacy range spec doesn't cover all keys. @@ -560,7 +560,7 @@ typedef enum { #define OOM_SCORE_RELATIVE 1 #define OOM_SCORE_ADJ_ABSOLUTE 2 -/* Redis maxmemory strategies. Instead of using just incremental number +/* Server maxmemory strategies. Instead of using just incremental number * for this defines, we use a set of flags so that testing for certain * properties common to multiple policies is faster. */ #define MAXMEMORY_FLAG_LRU (1<<0) @@ -699,9 +699,9 @@ typedef enum { * Data types *----------------------------------------------------------------------------*/ -/* A redis object, that is a type able to hold a string / list / set */ +/* An Object, that is a type able to hold a string / list / set */ -/* The actual Redis Object */ +/* The actual Object */ #define OBJ_STRING 0 /* String object. */ #define OBJ_LIST 1 /* List object. */ #define OBJ_SET 2 /* Set object. */ @@ -709,7 +709,7 @@ typedef enum { #define OBJ_HASH 4 /* Hash object. */ /* The "module" object type is a special one that signals that the object - * is one directly managed by a Redis module. In this case the value points + * is one directly managed by a module. In this case the value points * to a moduleValue struct, which contains the object value (which is only * handled by the module itself) and the ValkeyModuleType struct which lists * function pointers in order to serialize, deserialize, AOF-rewrite and @@ -792,7 +792,7 @@ typedef struct ValkeyModuleType { char name[10]; /* 9 bytes name + null term. Charset: A-Z a-z 0-9 _- */ } moduleType; -/* In Redis objects 'robj' structures of type OBJ_MODULE, the value pointer +/* In Object 'robj' structures of type OBJ_MODULE, the value pointer * is set to the following structure, referencing the moduleType structure * in order to work with the value, and at the same time providing a raw * pointer to the value, as created by the module commands operating with @@ -837,7 +837,7 @@ struct ValkeyModule { }; typedef struct ValkeyModule ValkeyModule; -/* This is a wrapper for the 'rio' streams used inside rdb.c in Redis, so that +/* This is a wrapper for the 'rio' streams used inside rdb.c in the server, so that * the user does not have to take the total count of the written bytes nor * to care about error conditions. */ struct ValkeyModuleIO { @@ -865,7 +865,7 @@ struct ValkeyModuleIO { iovar.pre_flush_buffer = NULL; \ } while(0) -/* This is a structure used to export DEBUG DIGEST capabilities to Redis +/* This is a structure used to export DEBUG DIGEST capabilities to * modules. We want to capture both the ordered and unordered elements of * a data structure, so that a digest can be created in a way that correctly * reflects the values. See the DEBUG DIGEST command implementation for more @@ -924,7 +924,7 @@ struct serverObject { * and Module types have their registered name returned. */ char *getObjectTypeName(robj*); -/* Macro used to initialize a Redis object allocated on the stack. +/* Macro used to initialize an Object allocated on the stack. * Note that this macro is taken near the structure definition to make sure * we'll update it when the structure is changed, to avoid bugs like * bug #85 introduced exactly in this way. */ @@ -971,7 +971,7 @@ typedef struct replBufBlock { char buf[]; } replBufBlock; -/* Redis database representation. There are multiple databases identified +/* Database representation. There are multiple databases identified * by integers from 0 (the default database) up to the max configured * database. The database number is the 'id' field in the structure. */ typedef struct serverDb { @@ -1058,7 +1058,7 @@ typedef struct blockingState { * After the execution of every command or script, we iterate over this list to check * if as a result we should serve data to clients blocked, unblocking them. * Note that server.ready_keys will not have duplicates as there dictionary - * also called ready_keys in every structure representing a Redis database, + * also called ready_keys in every structure representing a database, * where we make sure to remember if a given key was already added in the * server.ready_keys list. */ typedef struct readyList { @@ -1066,7 +1066,7 @@ typedef struct readyList { robj *key; } readyList; -/* This structure represents a Redis user. This is useful for ACLs, the +/* This structure represents a user. This is useful for ACLs, the * user is associated to the connection after the connection is authenticated. * If there is no associated user, the connection uses the default user. */ #define USER_COMMAND_BITS_COUNT 1024 /* The total number of command bits @@ -1243,10 +1243,10 @@ typedef struct client { * changes. */ void *auth_callback_privdata; /* Private data that is passed when the auth * changed callback is executed. Opaque for - * Redis Core. */ + * the Server Core. */ void *auth_module; /* The module that owns the callback, which is used * to disconnect the client if the module is - * unloaded for cleanup. Opaque for Redis Core.*/ + * unloaded for cleanup. Opaque for the Server Core.*/ /* If this client is in tracking mode and this field is non zero, * invalidation messages for keys fetched by this client will be sent to @@ -1371,7 +1371,7 @@ typedef struct clientBufferLimitsConfig { extern clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_OBUF_COUNT]; -/* The serverOp structure defines a Redis Operation, that is an instance of +/* The serverOp structure defines an Operation, that is an instance of * a command with an argument vector, database ID, propagation target * (PROPAGATE_*), and command pointer. * @@ -1382,7 +1382,7 @@ typedef struct serverOp { int argc, dbid, target; } serverOp; -/* Defines an array of Redis operations. There is an API to add to this +/* Defines an array of Operations. There is an API to add to this * structure in an easy way. * * int serverOpArrayAppend(serverOpArray *oa, int dbid, robj **argv, int argc, int target); @@ -1526,7 +1526,7 @@ typedef struct { *----------------------------------------------------------------------------*/ /* AIX defines hz to __hz, we don't use this define and in order to allow - * Redis build on AIX we need to undef it. */ + * the server build on AIX we need to undef it. */ #ifdef _AIX #undef hz #endif @@ -2011,7 +2011,7 @@ struct valkeyServer { int cluster_announce_port; /* base port to announce on cluster bus. */ int cluster_announce_tls_port; /* TLS port to announce on cluster bus. */ int cluster_announce_bus_port; /* bus port to announce on cluster bus. */ - int cluster_module_flags; /* Set of flags that Redis modules are able + int cluster_module_flags; /* Set of flags that modules are able to set in order to suppress certain native Redis Cluster features. Check the VALKEYMODULE_CLUSTER_FLAG_*. */ @@ -2052,7 +2052,7 @@ struct valkeyServer { int tls_auth_clients; serverTLSContextConfig tls_ctx_config; /* cpu affinity */ - char *server_cpulist; /* cpu affinity list of redis server main/io thread. */ + char *server_cpulist; /* cpu affinity list of server main/io thread. */ char *bio_cpulist; /* cpu affinity list of bio thread. */ char *aof_rewrite_cpulist; /* cpu affinity list of aof rewrite process. */ char *bgsave_cpulist; /* cpu affinity list of bgsave process. */ @@ -2240,7 +2240,7 @@ typedef enum { typedef void serverCommandProc(client *c); typedef int serverGetKeysProc(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); -/* Redis command structure. +/* Command structure. * * Note that the command table is in commands.c and it is auto-generated. * @@ -2355,7 +2355,7 @@ struct serverCommand { keySpec *key_specs; int key_specs_num; /* Use a function to determine keys arguments in a command line. - * Used for Redis Cluster redirect (may be NULL) */ + * Used for Cluster redirect (may be NULL) */ serverGetKeysProc *getkeys_proc; int num_args; /* Length of args array. */ /* Array of subcommands (may be NULL) */ @@ -2752,7 +2752,7 @@ void discardTransaction(client *c); void flagTransaction(client *c); void execCommandAbort(client *c, sds error); -/* Redis object implementation */ +/* Object implementation */ void decrRefCount(robj *o); void decrRefCountVoid(void *o); void incrRefCount(robj *o); @@ -3377,7 +3377,7 @@ void sentinelInfoCommand(client *c); void sentinelPublishCommand(client *c); void sentinelRoleCommand(client *c); -/* redis-check-rdb & aof */ +/* valkey-check-rdb & aof */ int redis_check_rdb(char *rdbfilename, FILE *fp); int redis_check_rdb_main(int argc, char **argv, FILE *fp); int redis_check_aof_main(int argc, char **argv); diff --git a/src/serverassert.h b/src/serverassert.h index da1b7c7fa2..945549f895 100644 --- a/src/serverassert.h +++ b/src/serverassert.h @@ -1,8 +1,8 @@ /* serverassert.h -- Drop in replacements assert.h that prints the stack trace - * in the Redis logs. + * in the server logs. * * This file should be included instead of "assert.h" inside libraries used by - * Redis that are using assertions, so instead of Redis disappearing with + * the server that are using assertions, so instead of the server disappearing with * SIGABORT, we get the details and stack trace inside the log file. * * ---------------------------------------------------------------------------- diff --git a/src/slowlog.c b/src/slowlog.c index a68064af2d..b6d743aa06 100644 --- a/src/slowlog.c +++ b/src/slowlog.c @@ -5,7 +5,7 @@ * using the 'slowlog-log-slower-than' config directive, that is also * readable and writable using the CONFIG SET/GET command. * - * The slow queries log is actually not "logged" in the Redis log file + * The slow queries log is actually not "logged" in the server log file * but is accessible thanks to the SLOWLOG command. * * ---------------------------------------------------------------------------- @@ -78,7 +78,7 @@ slowlogEntry *slowlogCreateEntry(client *c, robj **argv, int argc, long long dur /* Here we need to duplicate the string objects composing the * argument vector of the command, because those may otherwise * end shared with string objects stored into keys. Having - * shared objects between any part of Redis, and the data + * shared objects between any part of the server, and the data * structure holding the data, is a problem: FLUSHALL ASYNC * may release the shared string object and create a race. */ se->argv[j] = dupStringObject(argv[j]); @@ -138,7 +138,7 @@ void slowlogReset(void) { } /* The SLOWLOG command. Implements all the subcommands needed to handle the - * Redis slow log. */ + * slow log. */ void slowlogCommand(client *c) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { const char *help[] = { diff --git a/src/socket.c b/src/socket.c index 775d56d375..70b77d4b42 100644 --- a/src/socket.c +++ b/src/socket.c @@ -31,7 +31,7 @@ #include "connhelpers.h" /* The connections module provides a lean abstraction of network connections - * to avoid direct socket and async event management across the Redis code base. + * to avoid direct socket and async event management across the server code base. * * It does NOT provide advanced connection features commonly found in similar * libraries such as complete in/out buffer management, throttling, etc. These diff --git a/src/sort.c b/src/sort.c index 78d15a7199..dea9bb73e3 100644 --- a/src/sort.c +++ b/src/sort.c @@ -185,7 +185,7 @@ int sortCompare(const void *s1, const void *s2) { return server.sort_desc ? -cmp : cmp; } -/* The SORT command is the most complex command in Redis. Warning: this code +/* The SORT command is the most complex command in the server. Warning: this code * is optimized for speed and a bit less for readability */ void sortCommandGeneric(client *c, int readonly) { list *operations; diff --git a/src/syncio.c b/src/syncio.c index b2843d5fbc..b6aa6a8e76 100644 --- a/src/syncio.c +++ b/src/syncio.c @@ -32,7 +32,7 @@ /* ----------------- Blocking sockets I/O with timeouts --------------------- */ -/* Redis performs most of the I/O in a nonblocking way, with the exception +/* The server performs most of the I/O in a nonblocking way, with the exception * of the SYNC command where the slave does it in a blocking way, and * the MIGRATE command that must be blocking in order to be atomic from the * point of view of the two instances (one migrating the key and one receiving diff --git a/src/syscheck.c b/src/syscheck.c index 0ea3a2510b..008e28bbff 100644 --- a/src/syscheck.c +++ b/src/syscheck.c @@ -63,7 +63,7 @@ static sds read_sysfs_line(char *path) { } /* Verify our clocksource implementation doesn't go through a system call (uses vdso). - * Going through a system call to check the time degrades Redis performance. */ + * Going through a system call to check the time degrades server performance. */ static int checkClocksource(sds *error_msg) { unsigned long test_time_us, system_hz; struct timespec ts; @@ -117,7 +117,7 @@ static int checkClocksource(sds *error_msg) { } /* Verify we're not using the `xen` clocksource. The xen hypervisor's default clocksource is slow and affects - * Redis's performance. This has been measured on ec2 xen based instances. ec2 recommends using the non-default + * the server's performance. This has been measured on ec2 xen based instances. ec2 recommends using the non-default * tsc clock source for these instances. */ int checkXenClocksource(sds *error_msg) { sds curr = read_sysfs_line("/sys/devices/system/clocksource/clocksource0/current_clocksource"); diff --git a/src/t_hash.c b/src/t_hash.c index ff8746384c..5c1d218c55 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -137,7 +137,7 @@ int hashTypeGetValue(robj *o, sds field, unsigned char **vstr, unsigned int *vle return C_ERR; } -/* Like hashTypeGetValue() but returns a Redis object, which is useful for +/* Like hashTypeGetValue() but returns an Object, which is useful for * interaction with the hash type outside t_hash.c. * The function returns NULL if the field is not found in the hash. Otherwise * a newly allocated string object with the value is returned. */ diff --git a/src/t_list.c b/src/t_list.c index d931937495..a3668ce1e3 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -1143,7 +1143,7 @@ void lmoveGenericCommand(client *c, int wherefrom, int whereto) { if (listTypeLength(sobj) == 0) { /* This may only happen after loading very old RDB files. Recent - * versions of Redis delete keys of empty lists. */ + * versions of the server delete keys of empty lists. */ addReplyNull(c); } else { robj *dobj = lookupKeyWrite(c->db,c->argv[2]); diff --git a/src/t_set.c b/src/t_set.c index 24e7b0e7d2..cb53045eb2 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -516,7 +516,7 @@ int setTypeConvertAndExpand(robj *setobj, int enc, unsigned long cap, int panic) return C_ERR; } - /* To add the elements we extract integers and create redis objects */ + /* To add the elements we extract integers and create Objects */ si = setTypeInitIterator(setobj); while ((element = setTypeNextObject(si)) != NULL) { serverAssert(dictAdd(d,element,NULL) == DICT_OK); diff --git a/src/t_stream.c b/src/t_stream.c index ee37f97808..f70019a746 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -1870,7 +1870,7 @@ robj *streamTypeLookupWriteOrCreate(client *c, robj *key, int no_create) { return o; } -/* Parse a stream ID in the format given by clients to Redis, that is +/* Parse a stream ID in the format given by clients to the server, that is * -, and converts it into a streamID structure. If * the specified ID is invalid C_ERR is returned and an error is reported * to the client, otherwise C_OK is returned. The ID may be in incomplete diff --git a/src/t_string.c b/src/t_string.c index 2bce3acc81..1a36871233 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -57,7 +57,7 @@ static int checkStringLength(client *c, long long size, long long append) { * * 'flags' changes the behavior of the command (NX, XX or GET, see below). * - * 'expire' represents an expire to set in form of a Redis object as passed + * 'expire' represents an expire to set in the form of an Object as passed * by the user. It is interpreted according to the specified 'unit'. * * 'ok_reply' and 'abort_reply' is what the function will reply to the client diff --git a/src/t_zset.c b/src/t_zset.c index 6d4edd2123..d9a401a4d9 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -36,9 +36,9 @@ * in order to get O(log(N)) INSERT and REMOVE operations into a sorted * data structure. * - * The elements are added to a hash table mapping Redis objects to scores. + * The elements are added to a hash table mapping Objects to scores. * At the same time the elements are added to a skip list mapping scores - * to Redis objects (so objects are sorted by scores in this "view"). + * to Objects (so objects are sorted by scores in this "view"). * * Note that the SDS string representing the element is the same in both * the hash table and skiplist in order to save memory. What we do in order @@ -598,7 +598,7 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) { * - means the min string possible * + means the max string possible * - * If the string is valid the *dest pointer is set to the redis object + * If the string is valid the *dest pointer is set to the Object * that will be used for the comparison, and ex will be set to 0 or 1 * respectively if the item is exclusive or inclusive. C_OK will be * returned. diff --git a/src/tls.c b/src/tls.c index ee3cd0fa3b..54eaf255dc 100644 --- a/src/tls.c +++ b/src/tls.c @@ -27,7 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define VALKEYMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */ +#define VALKEYMODULE_CORE_MODULE /* A module that's part of the server core, uses server.h too. */ #include "server.h" #include "connhelpers.h" @@ -1175,7 +1175,7 @@ int ValkeyModule_OnLoad(void *ctx, ValkeyModuleString **argv, int argc) { UNUSED(argv); UNUSED(argc); - /* Connection modules must be part of the same build as redis. */ + /* Connection modules must be part of the same build as the server. */ if (strcmp(REDIS_BUILD_ID_RAW, serverBuildIdRaw())) { serverLog(LL_NOTICE, "Connection type %s was not built together with the redis-server used.", CONN_TYPE_TLS); return VALKEYMODULE_ERR; diff --git a/src/tracking.c b/src/tracking.c index 429770065b..87183af566 100644 --- a/src/tracking.c +++ b/src/tracking.c @@ -216,7 +216,7 @@ void enableTracking(client *c, uint64_t redirect_to, uint64_t options, robj **pr /* This function is called after the execution of a readonly command in the * case the client 'c' has keys tracking enabled and the tracking is not * in BCAST mode. It will populate the tracking invalidation table according - * to the keys the user fetched, so that Redis will know what are the clients + * to the keys the user fetched, so that the server will know what are the clients * that should receive an invalidation message with certain groups of keys * are modified. */ void trackingRememberKeys(client *tracking, client *executing) { @@ -268,7 +268,7 @@ void trackingRememberKeys(client *tracking, client *executing) { * * In case the 'proto' argument is non zero, the function will assume that * 'keyname' points to a buffer of 'keylen' bytes already expressed in the - * form of Redis RESP protocol. This is used for: + * form of RESP protocol. This is used for: * - In BCAST mode, to send an array of invalidated keys to all * applicable clients * - Following a flush command, to send a single RESP NULL to indicate @@ -331,7 +331,7 @@ void sendTrackingMessage(client *c, char *keyname, size_t keylen, int proto) { if (!(old_flags & CLIENT_PUSHING)) c->flags &= ~CLIENT_PUSHING; } -/* This function is called when a key is modified in Redis and in the case +/* This function is called when a key is modified in the server and in the case * we have at least one client with the BCAST mode enabled. * Its goal is to set the key in the right broadcast state if the key * matches one or more prefixes in the prefix table. Later when we @@ -355,7 +355,7 @@ void trackingRememberKeyToBroadcast(client *c, char *keyname, size_t keylen) { raxStop(&ri); } -/* This function is called from signalModifiedKey() or other places in Redis +/* This function is called from signalModifiedKey() or other places in the server * when a key changes value. In the context of keys tracking, our task here is * to send a notification to every client that may have keys about such caching * slot. @@ -366,7 +366,7 @@ void trackingRememberKeyToBroadcast(client *c, char *keyname, size_t keylen) { * * The last argument 'bcast' tells the function if it should also schedule * the key for broadcasting to clients in BCAST mode. This is the case when - * the function is called from the Redis core once a key is modified, however + * the function is called from the server core once a key is modified, however * we also call the function in order to evict keys in the key table in case * of memory pressure: in that case the key didn't really change, so we want * just to notify the clients that are in the table for this key, that would @@ -458,7 +458,7 @@ void trackingHandlePendingKeyInvalidations(void) { listEmpty(server.tracking_pending_keys); } -/* This function is called when one or all the Redis databases are +/* This function is called when one or all of the databases are * flushed. Caching keys are not specific for each DB but are global: * currently what we do is send a special notification to clients with * tracking enabled, sending a RESP NULL, which means, "all the keys", @@ -504,12 +504,12 @@ void trackingInvalidateKeysOnFlush(int async) { } } -/* Tracking forces Redis to remember information about which client may have +/* Tracking forces the server to remember information about which client may have * certain keys. In workloads where there are a lot of reads, but keys are * hardly modified, the amount of information we have to remember server side * could be a lot, with the number of keys being totally not bound. * - * So Redis allows the user to configure a maximum number of keys for the + * So the server allows the user to configure a maximum number of keys for the * invalidation table. This function makes sure that we don't go over the * specified fill rate: if we are over, we can just evict information about * a random key, and send invalidation messages to clients like if the key was @@ -553,7 +553,7 @@ void trackingLimitUsedSlots(void) { timeout_counter++; } -/* Generate Redis protocol for an array containing all the key names +/* Generate RESP for an array containing all the key names * in the 'keys' radix tree. If the client is not NULL, the list will not * include keys that were modified the last time by this client, in order * to implement the NOLOOP option. diff --git a/src/unix.c b/src/unix.c index eb5850765a..5428c5110c 100644 --- a/src/unix.c +++ b/src/unix.c @@ -56,7 +56,7 @@ static int connUnixListen(connListener *listener) { if (listener->bindaddr_count == 0) return C_OK; - /* currently listener->bindaddr_count is always 1, we still use a loop here in case Redis supports multi Unix socket in the future */ + /* currently listener->bindaddr_count is always 1, we still use a loop here in case the server supports multi Unix socket in the future */ for (int j = 0; j < listener->bindaddr_count; j++) { char *addr = listener->bindaddr[j]; diff --git a/src/util.c b/src/util.c index 3f9533369b..b5ef5ea2b4 100644 --- a/src/util.c +++ b/src/util.c @@ -696,7 +696,7 @@ int d2string(char *buf, size_t len, double value) { * We convert the double to long and multiply it by 10 ^ to shift * the decimal places. * Note that multiply it of input value by 10 ^ can overflow but on the scenario - * that we currently use within redis this that is not possible. + * that we currently use within the server this that is not possible. * After we get the long representation we use the logic from ull2string function on this file * which is based on the following article: * https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920 @@ -959,8 +959,8 @@ void getRandomBytes(unsigned char *p, size_t len) { } } -/* Generate the Redis "Run ID", a SHA1-sized random number that identifies a - * given execution of Redis, so that if you are talking with an instance +/* Generate the server "Run ID", a SHA1-sized random number that identifies a + * given execution of the server, so that if you are talking with an instance * having run_id == A, and you reconnect and it has run_id == B, you can be * sure that it is either a different instance or it was restarted. */ void getRandomHexChars(char *p, size_t len) { @@ -1042,7 +1042,7 @@ long getTimeZone(void) { /* Return true if the specified path is just a file basename without any * relative or absolute path. This function just checks that no / or \ * character exists inside the specified path, that's enough in the - * environments where Redis runs. */ + * environments where the server runs. */ int pathIsBaseName(char *path) { return strchr(path,'/') == NULL && strchr(path,'\\') == NULL; } diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index bfc0760927..d3a3944f75 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -1,4 +1,4 @@ -/* Redis benchmark utility. +/* Server benchmark utility. * * Copyright (c) 2009-2012, Salvatore Sanfilippo * All rights reserved. @@ -1377,7 +1377,7 @@ static void updateClusterSlotsConfiguration(void) { pthread_mutex_unlock(&config.is_updating_slots_mutex); } -/* Generate random data for redis benchmark. See #7196. */ +/* Generate random data for the benchmark. See #7196. */ static void genBenchmarkRandomData(char *data, int count) { static uint32_t state = 1234; int i = 0; diff --git a/src/valkey-check-aof.c b/src/valkey-check-aof.c index cf2888cb90..dfe268201e 100644 --- a/src/valkey-check-aof.c +++ b/src/valkey-check-aof.c @@ -129,7 +129,7 @@ int readArgc(FILE *fp, long *target) { } /* Used to decode a RESP record in the AOF file to obtain the original - * redis command, and also check whether the command is MULTI/EXEC. If the + * server command, and also check whether the command is MULTI/EXEC. If the * command is MULTI, the parameter out_multi will be incremented by one, and * if the command is EXEC, the parameter out_multi will be decremented * by one. The parameter out_multi will be used by the upper caller to determine @@ -426,7 +426,7 @@ int fileIsManifest(char *filepath) { * AOF_RDB_PREAMBLE: Old-style RDB-preamble AOF * AOF_MULTI_PART: manifest in Multi Part AOF * - * redis-check-aof tool will automatically perform different + * valkey-check-aof tool will automatically perform different * verification logic according to different file formats. * */ input_file_type getInputFileType(char *filepath) { @@ -454,7 +454,7 @@ void printAofStyle(int ret, char *aofFileName, char *aofType) { /* Check if Multi Part AOF is valid. It will check the BASE file and INCR files * at once according to the manifest instructions (this is somewhat similar to - * redis' AOF loading). + * the server's AOF loading). * * When the verification is successful, we can guarantee: * 1. The manifest file format is valid diff --git a/src/valkey-check-rdb.c b/src/valkey-check-rdb.c index f938a48664..fcc525dcb3 100644 --- a/src/valkey-check-rdb.c +++ b/src/valkey-check-rdb.c @@ -396,8 +396,8 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) { return 1; } -/* RDB check main: called form server.c when Redis is executed with the - * redis-check-rdb alias, on during RDB loading errors. +/* RDB check main: called form server.c when the server is executed with the + * valkey-check-rdb alias, on during RDB loading errors. * * The function works in two ways: can be called with argc/argv as a * standalone executable, or called with a non NULL 'fp' argument if we @@ -426,7 +426,7 @@ int redis_check_rdb_main(int argc, char **argv, FILE *fp) { /* In order to call the loading functions we need to create the shared * integer objects, however since this function may be called from - * an already initialized Redis instance, check if we really need to. */ + * an already initialized server instance, check if we really need to. */ if (shared.integers[0] == NULL) createSharedObjects(); server.loading_process_events_interval_bytes = 0; diff --git a/src/valkey-cli.c b/src/valkey-cli.c index ba16d03fa7..cfc3fcaaff 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -1,4 +1,4 @@ -/* Redis CLI (command line interface) +/* Server CLI (command line interface) * * Copyright (c) 2009-2012, Salvatore Sanfilippo * All rights reserved. @@ -425,10 +425,10 @@ static int helpEntriesLen = 0; /* For backwards compatibility with pre-7.0 servers. * cliLegacyInitHelp() sets up the helpEntries array with the command and group - * names from the commands.c file. However the Redis instance we are connecting + * names from the commands.c file. However the server instance we are connecting * to may support more commands, so this function integrates the previous * entries with additional entries obtained using the COMMAND command - * available in recent versions of Redis. */ + * available in recent versions of the server. */ static void cliLegacyIntegrateHelp(void) { if (cliConnect(CC_QUIET) == REDIS_ERR) return; @@ -986,7 +986,7 @@ static void cliOutputHelp(int argc, char **argv) { if (helpEntries == NULL) { /* Initialize the help using the results of the COMMAND command. - * In case we are using redis-cli help XXX, we need to init it. */ + * In case we are using valkey-cli help XXX, we need to init it. */ cliInitHelp(); } @@ -1602,7 +1602,7 @@ static int cliSelect(void) { return result; } -/* Select RESP3 mode if redis-cli was started with the -3 option. */ +/* Select RESP3 mode if valkey-cli was started with the -3 option. */ static int cliSwitchProto(void) { redisReply *reply; if (!config.resp3 || config.resp2) return REDIS_OK; @@ -1689,7 +1689,7 @@ static int cliConnect(int flags) { } - /* Set aggressive KEEP_ALIVE socket option in the Redis context socket + /* Set aggressive KEEP_ALIVE socket option in the server context socket * in order to prevent timeouts caused by the execution of long * commands. At the same time this improves the detection of real * errors. */ @@ -2315,7 +2315,7 @@ static int cliReadReply(int output_raw_strings) { return REDIS_OK; } -/* Simultaneously wait for pubsub messages from redis and input on stdin. */ +/* Simultaneously wait for pubsub messages from the server and input on stdin. */ static void cliWaitForMessagesOrStdin(void) { int show_info = config.output != OUTPUT_RAW && (isatty(STDOUT_FILENO) || getenv("FAKETTY")); @@ -2337,7 +2337,7 @@ static void cliWaitForMessagesOrStdin(void) { } } while(reply); - /* Wait for input, either on the Redis socket or on stdin. */ + /* Wait for input, either on the server socket or on stdin. */ struct timeval tv; fd_set readfds; FD_ZERO(&readfds); @@ -2366,7 +2366,7 @@ static void cliWaitForMessagesOrStdin(void) { } break; } else if (FD_ISSET(context->fd, &readfds)) { - /* Message from Redis */ + /* Message from the server */ if (cliReadReply(0) != REDIS_OK) { cliPrintContextError(); exit(1); @@ -2409,7 +2409,7 @@ static int cliSendCommand(int argc, char **argv, long repeat) { !strcasecmp(argv[1],"graph")) || (argc == 2 && !strcasecmp(command,"latency") && !strcasecmp(argv[1],"doctor")) || - /* Format PROXY INFO command for Redis Cluster Proxy: + /* Format PROXY INFO command for Cluster Proxy: * https://github.com/artix75/redis-cluster-proxy */ (argc >= 2 && !strcasecmp(command,"proxy") && !strcasecmp(argv[1],"info"))) @@ -2760,7 +2760,7 @@ static int parseOptions(int argc, char **argv) { config.bigkeys = 1; } else if (!strcmp(argv[i],"--memkeys")) { config.memkeys = 1; - config.memkeys_samples = 0; /* use redis default */ + config.memkeys_samples = 0; /* use the server default */ } else if (!strcmp(argv[i],"--memkeys-samples") && !lastarg) { config.memkeys = 1; config.memkeys_samples = atoi(argv[++i]); @@ -3167,10 +3167,10 @@ static int confirmWithYes(char *msg, int ignore_force) { } static int issueCommandRepeat(int argc, char **argv, long repeat) { - /* In Lua debugging mode, we want to pass the "help" to Redis to get + /* In Lua debugging mode, we want to pass the "help" to the server to get * it's own HELP message, rather than handle it by the CLI, see ldbRepl. * - * For the normal Redis HELP, we can process it without a connection. */ + * For the normal server HELP, we can process it without a connection. */ if (!config.eval_ldb && (!strcasecmp(argv[0],"help") || !strcasecmp(argv[0],"?"))) { @@ -3363,9 +3363,9 @@ static void repl(void) { int argc; sds *argv; - /* There is no need to initialize redis HELP when we are in lua debugger mode. + /* There is no need to initialize HELP when we are in lua debugger mode. * It has its own HELP and commands (COMMAND or COMMAND DOCS will fail and got nothing). - * We will initialize the redis HELP after the Lua debugging session ended.*/ + * We will initialize the HELP after the Lua debugging session ended.*/ if ((!config.eval_ldb) && isatty(fileno(stdin))) { /* Initialize the help using the results of the COMMAND command. */ cliInitHelp(); @@ -4109,7 +4109,7 @@ static int clusterManagerNodeConnect(clusterManagerNode *node) { node->context = NULL; return 0; } - /* Set aggressive KEEP_ALIVE socket option in the Redis context socket + /* Set aggressive KEEP_ALIVE socket option in the server context socket * in order to prevent timeouts caused by the execution of long * commands. At the same time this improves the detection of real * errors. */ @@ -4193,7 +4193,7 @@ static void clusterManagerNodeResetSlots(clusterManagerNode *node) { node->slots_count = 0; } -/* Call "INFO" redis command on the specified node and return the reply. */ +/* Call "INFO" command on the specified node and return the reply. */ static redisReply *clusterManagerGetNodeRedisInfo(clusterManagerNode *node, char **err) { @@ -4882,7 +4882,7 @@ static int clusterManagerSetSlotOwner(clusterManagerNode *owner, } /* Get the hash for the values of the specified keys in *keys_reply for the - * specified nodes *n1 and *n2, by calling DEBUG DIGEST-VALUE redis command + * specified nodes *n1 and *n2, by calling DEBUG DIGEST-VALUE command * on both nodes. Every key with same name on both nodes but having different * values will be added to the *diffs list. Return 0 in case of reply * error. */ @@ -6873,7 +6873,7 @@ static void clusterManagerPrintNotClusterNodeError(clusterManagerNode *node, clusterManagerLogErr("[ERR] Node %s:%d %s\n", node->ip, node->port, msg); } -/* Execute redis-cli in Cluster Manager mode */ +/* Execute valkey-cli in Cluster Manager mode */ static void clusterManagerMode(clusterManagerCommandProc *proc) { int argc = config.cluster_manager_command.argc; char **argv = config.cluster_manager_command.argv; @@ -8828,7 +8828,7 @@ static void pipeMode(void) { /* The ECHO sequence starts with a "\r\n" so that if there * is garbage in the protocol we read from stdin, the ECHO * will likely still be properly formatted. - * CRLF is ignored by Redis, so it has no effects. */ + * CRLF is ignored by the server, so it has no effects. */ char echo[] = "\r\n*2\r\n$4\r\nECHO\r\n$20\r\n01234567890123456789\r\n"; int j; diff --git a/src/version.h b/src/version.h index b82be5cbe6..3b2e3a0601 100644 --- a/src/version.h +++ b/src/version.h @@ -2,7 +2,7 @@ #define VALKEY_VERSION "255.255.255" #define VALKEY_VERSION_NUM 0x00ffffff -/* Redis compatibility version, should never +/* Redis OSS compatibility version, should never * exceed 7.2.x. */ #define REDIS_VERSION "7.2.4" #define REDIS_VERSION_NUM 0x00070204 diff --git a/src/zipmap.c b/src/zipmap.c index 214c49d2fc..de42a04abc 100644 --- a/src/zipmap.c +++ b/src/zipmap.c @@ -3,11 +3,11 @@ * implementing an O(n) lookup data structure designed to be very memory * efficient. * - * The Redis Hash type uses this data structure for hashes composed of a small + * The Hash type uses this data structure for hashes composed of a small * number of elements, to switch to a hash table once a given number of * elements is reached. * - * Given that many times Redis Hashes are used to represent objects composed + * Given that many times Hashes are used to represent objects composed * of few fields, this is a very big win in terms of used memory. * * -------------------------------------------------------------------------- diff --git a/src/zmalloc.c b/src/zmalloc.c index 65ad1f4c6a..550752240f 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -446,7 +446,7 @@ void zmadvise_dontneed(void *ptr) { /* Get the RSS information in an OS-specific way. * * WARNING: the function zmalloc_get_rss() is not designed to be fast - * and may not be called in the busy loops where Redis tries to release + * and may not be called in the busy loops where the server tries to release * memory expiring or swapping out objects. * * For this kind of "fast RSS reporting" usages use instead the @@ -769,7 +769,7 @@ void zlibc_trim(void) { /* For proc_pidinfo() used later in zmalloc_get_smap_bytes_by_field(). * Note that this file cannot be included in zmalloc.h because it includes * a Darwin queue.h file where there is a "LIST_HEAD" macro (!) defined - * conficting with Redis user code. */ + * conficting with user code. */ #include #endif diff --git a/src/zmalloc.h b/src/zmalloc.h index 9baa36b3de..1cf4af96c4 100644 --- a/src/zmalloc.h +++ b/src/zmalloc.h @@ -99,8 +99,8 @@ #include #endif -/* We can enable the Redis defrag capabilities only if we are using Jemalloc - * and the version used is our special version modified for Redis having +/* We can enable the server defrag capabilities only if we are using Jemalloc + * and the version used is our special version modified for the server having * the ability to return per-allocation fragmentation hints. */ #if defined(USE_JEMALLOC) && defined(JEMALLOC_FRAG_HINT) #define HAVE_DEFRAG diff --git a/tests/assets/default.conf b/tests/assets/default.conf index de460cc081..4478f80fca 100644 --- a/tests/assets/default.conf +++ b/tests/assets/default.conf @@ -1,4 +1,4 @@ -# Redis configuration for testing. +# Server configuration for testing. always-show-logo yes notify-keyspace-events KEA diff --git a/tests/assets/test_cli_hint_suite.txt b/tests/assets/test_cli_hint_suite.txt index b4a20163fb..3cebf5229c 100644 --- a/tests/assets/test_cli_hint_suite.txt +++ b/tests/assets/test_cli_hint_suite.txt @@ -1,4 +1,4 @@ -# Test suite for redis-cli command-line hinting mechanism. +# Test suite for valkey-cli command-line hinting mechanism. # Each test case consists of two strings: a (partial) input command line, and the expected hint string. # Command with one arg: GET key diff --git a/tests/cluster/run.tcl b/tests/cluster/run.tcl index 86c5f589b7..9808032b50 100644 --- a/tests/cluster/run.tcl +++ b/tests/cluster/run.tcl @@ -5,7 +5,7 @@ cd tests/cluster source cluster.tcl source ../instances.tcl -source ../../support/cluster.tcl ; # Redis Cluster client. +source ../../support/cluster.tcl ; # Cluster client. set ::instances_count 20 ; # How many instances we use at max. set ::tlsdir "../../tls" diff --git a/tests/cluster/tests/04-resharding.tcl b/tests/cluster/tests/04-resharding.tcl index babedd9724..e38b2bc6b5 100644 --- a/tests/cluster/tests/04-resharding.tcl +++ b/tests/cluster/tests/04-resharding.tcl @@ -101,7 +101,7 @@ test "Cluster consistency during live resharding" { set key "key:$listid" incr ele # We write both with Lua scripts and with plain commands. - # This way we are able to stress Lua -> Redis command invocation + # This way we are able to stress Lua -> server command invocation # as well, that has tests to prevent Lua to write into wrong # hash slots. # We also use both TLS and plaintext connections. @@ -129,7 +129,7 @@ test "Cluster consistency during live resharding" { } test "Verify $numkeys keys for consistency with logical content" { - # Check that the Redis Cluster content matches our logical content. + # Check that the Cluster content matches our logical content. foreach {key value} [array get content] { if {[$cluster lrange $key 0 -1] ne $value} { fail "Key $key expected to hold '$value' but actual content is [$cluster lrange $key 0 -1]" @@ -151,7 +151,7 @@ test "Cluster should eventually be up again" { } test "Verify $numkeys keys after the restart" { - # Check that the Redis Cluster content matches our logical content. + # Check that the Cluster content matches our logical content. foreach {key value} [array get content] { if {[$cluster lrange $key 0 -1] ne $value} { fail "Key $key expected to hold '$value' but actual content is [$cluster lrange $key 0 -1]" diff --git a/tests/cluster/tests/10-manual-failover.tcl b/tests/cluster/tests/10-manual-failover.tcl index 5441b79f38..e93bd680e3 100644 --- a/tests/cluster/tests/10-manual-failover.tcl +++ b/tests/cluster/tests/10-manual-failover.tcl @@ -41,7 +41,7 @@ test "Send CLUSTER FAILOVER to #5, during load" { set key "key:$listid" set ele [randomValue] # We write both with Lua scripts and with plain commands. - # This way we are able to stress Lua -> Redis command invocation + # This way we are able to stress Lua -> server command invocation # as well, that has tests to prevent Lua to write into wrong # hash slots. if {$listid % 2} { @@ -80,7 +80,7 @@ test "Instance #5 is now a master" { } test "Verify $numkeys keys for consistency with logical content" { - # Check that the Redis Cluster content matches our logical content. + # Check that the Cluster content matches our logical content. foreach {key value} [array get content] { assert {[$cluster lrange $key 0 -1] eq $value} } diff --git a/tests/cluster/tests/20-half-migrated-slot.tcl b/tests/cluster/tests/20-half-migrated-slot.tcl index 229b3a86df..6d49716e12 100644 --- a/tests/cluster/tests/20-half-migrated-slot.tcl +++ b/tests/cluster/tests/20-half-migrated-slot.tcl @@ -6,7 +6,7 @@ # 5. migration is half finished on "importing" node # TODO: Test is currently disabled until it is stabilized (fixing the test -# itself or real issues in Redis). +# itself or real issues in the server). if {false} { source "../tests/includes/init-tests.tcl" diff --git a/tests/cluster/tests/21-many-slot-migration.tcl b/tests/cluster/tests/21-many-slot-migration.tcl index 1ac73dc997..e4f8eb205b 100644 --- a/tests/cluster/tests/21-many-slot-migration.tcl +++ b/tests/cluster/tests/21-many-slot-migration.tcl @@ -1,7 +1,7 @@ # Tests for many simultaneous migrations. # TODO: Test is currently disabled until it is stabilized (fixing the test -# itself or real issues in Redis). +# itself or real issues in the server). if {false} { diff --git a/tests/cluster/tests/includes/utils.tcl b/tests/cluster/tests/includes/utils.tcl index e8925ebfc4..dd477cce84 100644 --- a/tests/cluster/tests/includes/utils.tcl +++ b/tests/cluster/tests/includes/utils.tcl @@ -13,7 +13,7 @@ proc fix_cluster {addr} { if {$code != 0} { puts "redis-cli --cluster fix returns non-zero exit code, output below:\n$result" } - # Note: redis-cli --cluster fix may return a non-zero exit code if nodes don't agree, + # Note: valkey-cli --cluster fix may return a non-zero exit code if nodes don't agree, # but we can ignore that and rely on the check below. assert_cluster_state ok wait_for_condition 100 100 { diff --git a/tests/helpers/fake_redis_node.tcl b/tests/helpers/fake_redis_node.tcl index a12d87fedf..cfcce62401 100644 --- a/tests/helpers/fake_redis_node.tcl +++ b/tests/helpers/fake_redis_node.tcl @@ -1,4 +1,4 @@ -# A fake Redis node for replaying predefined/expected traffic with a client. +# A fake node for replaying predefined/expected traffic with a client. # # Usage: tclsh fake_redis_node.tcl PORT COMMAND REPLY [ COMMAND REPLY [ ... ] ] # diff --git a/tests/instances.tcl b/tests/instances.tcl index 1450d7ee01..7f81a15bc3 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -1,6 +1,6 @@ # Multi-instance test framework. -# This is used in order to test Sentinel and Redis Cluster, and provides -# basic capabilities for spawning and handling N parallel Redis / Sentinel +# This is used in order to test Sentinel and Cluster, and provides +# basic capabilities for spawning and handling N parallel Server / Sentinel # instances. # # Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com @@ -64,7 +64,7 @@ proc exec_instance {type dirname cfgfile} { return $pid } -# Spawn a redis or sentinel instance, depending on 'type'. +# Spawn a server or sentinel instance, depending on 'type'. proc spawn_instance {type base_port count {conf {}} {base_conf_file ""}} { for {set j 0} {$j < $count} {incr j} { set port [find_available_port $base_port $::redis_port_count] @@ -526,14 +526,14 @@ proc S {n args} { [dict get $s link] {*}$args } -# Returns a Redis instance by index. +# Returns a server instance by index. # Example: # [Rn 0] info proc Rn {n} { return [dict get [lindex $::redis_instances $n] link] } -# Like R but to chat with Redis instances. +# Like R but to chat with server instances. proc R {n args} { [Rn $n] {*}$args } @@ -566,7 +566,7 @@ proc RPort {n} { } } -# Iterate over IDs of sentinel or redis instances. +# Iterate over IDs of sentinel or server instances. proc foreach_instance_id {instances idvar code} { upvar 1 $idvar id for {set id 0} {$id < [llength $instances]} {incr id} { diff --git a/tests/integration/aof-multi-part.tcl b/tests/integration/aof-multi-part.tcl index 383dbeb73e..c642232044 100644 --- a/tests/integration/aof-multi-part.tcl +++ b/tests/integration/aof-multi-part.tcl @@ -19,9 +19,9 @@ tags {"external:skip"} { # Test Part 1 - # In order to test the loading logic of redis under different combinations of manifest and AOF. - # We will manually construct the manifest file and AOF, and then start redis to verify whether - # the redis behavior is as expected. + # In order to test the loading logic of the server under different combinations of manifest and AOF. + # We will manually construct the manifest file and AOF, and then start the server to verify whether + # the server behavior is as expected. test {Multi Part AOF can't load data when some file missing} { create_aof $aof_dirpath $aof_base1_file { @@ -748,8 +748,8 @@ tags {"external:skip"} { # Test Part 2 # - # To test whether the AOFRW behaves as expected during the redis run. - # We will start redis first, then perform pressure writing, enable and disable AOF, and manually + # To test whether the AOFRW behaves as expected during the server run. + # We will start the server first, then perform pressure writing, enable and disable AOF, and manually # and automatically run bgrewrite and other actions, to test whether the correct AOF file is created, # whether the correct manifest is generated, whether the data can be reload correctly under continuous # writing pressure, etc. diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 6006a00ff9..5c24e71608 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -374,7 +374,7 @@ tags {"aof external:skip"} { } } - # redis could load AOF which has timestamp annotations inside + # The server could load AOF which has timestamp annotations inside create_aof $aof_dirpath $aof_file { append_to_aof "#TS:1628217470\r\n" append_to_aof [formatCommand set foo1 bar1] diff --git a/tests/integration/corrupt-dump-fuzzer.tcl b/tests/integration/corrupt-dump-fuzzer.tcl index 206e503fc7..0ed30ee5e7 100644 --- a/tests/integration/corrupt-dump-fuzzer.tcl +++ b/tests/integration/corrupt-dump-fuzzer.tcl @@ -5,7 +5,7 @@ tags {"dump" "corruption" "external:skip" "logreqres:skip"} { # catch sigterm so that in case one of the random command hangs the test, -# usually due to redis not putting a response in the output buffers, +# usually due to the server not putting a response in the output buffers, # we'll know which command it was if { ! [ catch { package require Tclx diff --git a/tests/integration/logging.tcl b/tests/integration/logging.tcl index b547cd8fab..06b2e24e58 100644 --- a/tests/integration/logging.tcl +++ b/tests/integration/logging.tcl @@ -8,7 +8,7 @@ if {$system_name eq {linux}} { } # look for the DEBUG command in the backtrace, used when we triggered -# a stack trace print while we know redis is running that command. +# a stack trace print while we know the server is running that command. proc check_log_backtrace_for_debug {log_pattern} { # search for the final line in the stacktraces generation to make sure it was completed. set pattern "* STACK TRACE DONE *" @@ -17,7 +17,7 @@ proc check_log_backtrace_for_debug {log_pattern} { set res [wait_for_log_messages 0 \"$log_pattern\" 0 100 100] if {$::verbose} { puts $res} - # If the stacktrace is printed more than once, it means redis crashed during crash report generation + # If the stacktrace is printed more than once, it means the server crashed during crash report generation assert_equal [count_log_message 0 "STACK TRACE -"] 1 upvar threads_mngr_supported threads_mngr_supported @@ -30,7 +30,7 @@ proc check_log_backtrace_for_debug {log_pattern} { # the following are skipped since valgrind is slow and a timeout can happen if {!$::valgrind} { assert_equal [count_log_message 0 "wait_threads(): waiting threads timed out"] 0 - # make sure redis prints stack trace for all threads. we know 3 threads are idle in bio.c + # make sure the server prints stack trace for all threads. we know 3 threads are idle in bio.c assert_equal [count_log_message 0 "bioProcessBackgroundJobs"] 3 } } @@ -55,7 +55,7 @@ if {$backtrace_supported} { r debug sleep 1 check_log_backtrace_for_debug "*WATCHDOG TIMER EXPIRED*" - # make sure redis is still alive + # make sure the server is still alive assert_equal "PONG" [r ping] } } @@ -77,7 +77,7 @@ if {!$::valgrind} { r deferred 1 r debug sleep 10 ;# so that we see the function in the stack trace r flush - after 100 ;# wait for redis to get into the sleep + after 100 ;# wait for the server to get into the sleep exec kill -SIGABRT $pid $check_cb "*crashed by signal*" } @@ -100,12 +100,12 @@ if {!$::valgrind} { r deferred 1 r debug sleep 10 ;# so that we see the function in the stack trace r flush - after 100 ;# wait for redis to get into the sleep + after 100 ;# wait for the server to get into the sleep exec kill -SIGALRM $pid $check_cb "*Received SIGALRM*" r read r deferred 0 - # make sure redis is still alive + # make sure the server is still alive assert_equal "PONG" [r ping] } } diff --git a/tests/integration/psync2-pingoff.tcl b/tests/integration/psync2-pingoff.tcl index 3589d07e75..4ea70f0c32 100644 --- a/tests/integration/psync2-pingoff.tcl +++ b/tests/integration/psync2-pingoff.tcl @@ -1,5 +1,5 @@ # These tests were added together with the meaningful offset implementation -# in redis 6.0.0, which was later abandoned in 6.0.4, they used to test that +# in redis OSS 6.0.0, which was later abandoned in 6.0.4, they used to test that # servers are able to PSYNC with replicas even if the replication stream has # PINGs at the end which present in one sever and missing on another. # We keep these tests just because they reproduce edge cases in the replication diff --git a/tests/integration/psync2-reg.tcl b/tests/integration/psync2-reg.tcl index a803d82a8a..53a45cf57c 100644 --- a/tests/integration/psync2-reg.tcl +++ b/tests/integration/psync2-reg.tcl @@ -1,7 +1,7 @@ # Issue 3899 regression test. # We create a chain of three instances: master -> slave -> slave2 # and continuously break the link while traffic is generated by -# redis-benchmark. At the end we check that the data is the same +# valkey-benchmark. At the end we check that the data is the same # everywhere. start_server {tags {"psync2 external:skip"}} { diff --git a/tests/integration/psync2.tcl b/tests/integration/psync2.tcl index 4abe059b1a..69d536601c 100644 --- a/tests/integration/psync2.tcl +++ b/tests/integration/psync2.tcl @@ -77,7 +77,7 @@ start_server {} { start_server {} { set master_id 0 ; # Current master set start_time [clock seconds] ; # Test start time - set counter_value 0 ; # Current value of the Redis counter "x" + set counter_value 0 ; # Current value of the server counter "x" # Config set debug_msg 0 ; # Enable additional debug messages diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index 106fc0b50c..f70900c1a4 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -255,7 +255,7 @@ start_server {overrides {save ""}} { assert {[s rdb_last_cow_size] == 0} # using a 200us delay, the bgsave is empirically taking about 10 seconds. - # we need it to take more than some 5 seconds, since redis only report COW once a second. + # we need it to take more than some 5 seconds, since the server only report COW once a second. r config set rdb-key-save-delay 200 r config set loglevel debug diff --git a/tests/integration/valkey-benchmark.tcl b/tests/integration/valkey-benchmark.tcl index c3254408c8..e62985312d 100644 --- a/tests/integration/valkey-benchmark.tcl +++ b/tests/integration/valkey-benchmark.tcl @@ -5,7 +5,7 @@ proc cmdstat {cmd} { return [cmdrstat $cmd r] } -# common code to reset stats, flush the db and run redis-benchmark +# common code to reset stats, flush the db and run valkey-benchmark proc common_bench_setup {cmd} { r config resetstat r flushall diff --git a/tests/integration/valkey-cli.tcl b/tests/integration/valkey-cli.tcl index 19b6e00bae..4a6a2b314c 100644 --- a/tests/integration/valkey-cli.tcl +++ b/tests/integration/valkey-cli.tcl @@ -360,7 +360,7 @@ start_server {tags {"cli"}} { if {!$::tls} { ;# fake_redis_node doesn't support TLS test_nontty_cli "ASK redirect test" { - # Set up two fake Redis nodes. + # Set up two fake nodes. set tclsh [info nameofexecutable] set script "tests/helpers/fake_redis_node.tcl" set port1 [find_available_port $::baseport $::portcount] diff --git a/tests/modules/aclcheck.c b/tests/modules/aclcheck.c index b746518043..28ea1a5630 100644 --- a/tests/modules/aclcheck.c +++ b/tests/modules/aclcheck.c @@ -226,7 +226,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) if (argc > 1) return RedisModule_WrongArity(ctx); /* When that flag is passed, we try to create too many categories, - * and the test expects this to fail. In this case redis returns REDISMODULE_ERR + * and the test expects this to fail. In this case the server returns REDISMODULE_ERR * and set errno to ENOMEM*/ if (argc == 1) { long long fail_flag = 0; @@ -289,14 +289,14 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_ERR; /* This validates that, when module tries to add a category with invalid characters, - * redis returns REDISMODULE_ERR and set errno to `EINVAL` */ + * the server returns REDISMODULE_ERR and set errno to `EINVAL` */ if (RedisModule_AddACLCategory(ctx,"!nval!dch@r@cter$") == REDISMODULE_ERR) RedisModule_Assert(errno == EINVAL); else return REDISMODULE_ERR; /* This validates that, when module tries to add a category that already exists, - * redis returns REDISMODULE_ERR and set errno to `EBUSY` */ + * the server returns REDISMODULE_ERR and set errno to `EBUSY` */ if (RedisModule_AddACLCategory(ctx,"write") == REDISMODULE_ERR) RedisModule_Assert(errno == EBUSY); else diff --git a/tests/modules/auth.c b/tests/modules/auth.c index 19be95a0ab..5d6b740929 100644 --- a/tests/modules/auth.c +++ b/tests/modules/auth.c @@ -220,8 +220,8 @@ int test_rm_register_blocking_auth_cb(RedisModuleCtx *ctx, RedisModuleString **a return REDISMODULE_OK; } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); diff --git a/tests/modules/basics.c b/tests/modules/basics.c index 897cb5d87e..33086c3024 100644 --- a/tests/modules/basics.c +++ b/tests/modules/basics.c @@ -1,4 +1,4 @@ -/* Module designed to test the Redis modules subsystem. +/* Module designed to test the modules subsystem. * * ----------------------------------------------------------------------------- * diff --git a/tests/modules/blockedclient.c b/tests/modules/blockedclient.c index 4a59623fdc..c3a354670e 100644 --- a/tests/modules/blockedclient.c +++ b/tests/modules/blockedclient.c @@ -16,7 +16,7 @@ static volatile int g_slow_bg_operation = 0; static volatile int g_is_in_slow_bg_operation = 0; void *sub_worker(void *arg) { - // Get Redis module context + // Get module context RedisModuleCtx *ctx = (RedisModuleCtx *)arg; // Try acquiring GIL @@ -32,7 +32,7 @@ void *worker(void *arg) { // Retrieve blocked client RedisModuleBlockedClient *bc = (RedisModuleBlockedClient *)arg; - // Get Redis module context + // Get module context RedisModuleCtx *ctx = RedisModule_GetThreadSafeContext(bc); // Acquire GIL @@ -55,7 +55,7 @@ void *worker(void *arg) { // Unblock client RedisModule_UnblockClient(bc, NULL); - // Free the Redis module context + // Free the module context RedisModule_FreeThreadSafeContext(ctx); return NULL; @@ -104,7 +104,7 @@ void *bg_call_worker(void *arg) { bg_call_data *bg = arg; RedisModuleBlockedClient *bc = bg->bc; - // Get Redis module context + // Get module context RedisModuleCtx *ctx = RedisModule_GetThreadSafeContext(bg->bc); // Acquire GIL @@ -156,7 +156,7 @@ void *bg_call_worker(void *arg) { // Unblock client RedisModule_UnblockClient(bc, NULL); - // Free the Redis module context + // Free the module context RedisModule_FreeThreadSafeContext(ctx); return NULL; @@ -616,7 +616,7 @@ static void timer_callback(RedisModuleCtx *ctx, void *data) RedisModuleBlockedClient *bc = data; - // Get Redis module context + // Get module context RedisModuleCtx *reply_ctx = RedisModule_GetThreadSafeContext(bc); // Reply to client @@ -625,7 +625,7 @@ static void timer_callback(RedisModuleCtx *ctx, void *data) // Unblock client RedisModule_UnblockClient(bc, NULL); - // Free the Redis module context + // Free the module context RedisModule_FreeThreadSafeContext(reply_ctx); } diff --git a/tests/modules/blockonkeys.c b/tests/modules/blockonkeys.c index 94bb361231..c7b4797fd0 100644 --- a/tests/modules/blockonkeys.c +++ b/tests/modules/blockonkeys.c @@ -10,7 +10,7 @@ #define LIST_SIZE 1024 /* The FSL (Fixed-Size List) data type is a low-budget imitation of the - * native Redis list, in order to test list-like commands implemented + * list data type, in order to test list-like commands implemented * by a module. * Examples: FSL.PUSH, FSL.BPOP, etc. */ diff --git a/tests/modules/cmdintrospection.c b/tests/modules/cmdintrospection.c index 1a5e4863b6..3a1870a3f3 100644 --- a/tests/modules/cmdintrospection.c +++ b/tests/modules/cmdintrospection.c @@ -29,7 +29,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) .tips = "nondeterministic_output", .history = (RedisModuleCommandHistoryEntry[]){ /* NOTE: All versions specified should be the module's versions, not - * Redis'! We use Redis versions in this example for the purpose of + * the server's! We use server versions in this example for the purpose of * testing (comparing the output with the output of the vanilla * XADD). */ {"6.2.0", "Added the `NOMKSTREAM` option, `MINID` trimming strategy and the `LIMIT` option."}, diff --git a/tests/modules/datatype2.c b/tests/modules/datatype2.c index bc0dc3dfeb..fbfafd6f6d 100644 --- a/tests/modules/datatype2.c +++ b/tests/modules/datatype2.c @@ -45,7 +45,7 @@ * dict * * - * Keys in redis database: + * Keys in server database: * * ┌───────┐ * │ size │ @@ -64,7 +64,7 @@ * │ k3 │ ───┼─┐ │ k2 │ ───┼─┐ * │ │ │ │ │ │ │ │ * └─────┴─────┘ │ ┌───────┐ └─────┴─────┘ │ ┌───────┐ - * redis db[0] │ │ size │ redis db[1] │ │ size │ + * server db[0] │ │ size │ server db[1] │ │ size │ * └───────────►│ used │ └───────────►│ used │ * │ mask │ │ mask │ * └───────┘ └───────┘ diff --git a/tests/modules/hooks.c b/tests/modules/hooks.c index e91dd9bb51..24449d0d34 100644 --- a/tests/modules/hooks.c +++ b/tests/modules/hooks.c @@ -400,8 +400,8 @@ static int cmdKeyExpiry(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_OK; } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { #define VerifySubEventSupported(e, s) \ if (!RedisModule_IsSubEventSupported(e, s)) { \ diff --git a/tests/modules/keyspace_events.c b/tests/modules/keyspace_events.c index 1a284b50f4..d60d8a6934 100644 --- a/tests/modules/keyspace_events.c +++ b/tests/modules/keyspace_events.c @@ -316,8 +316,8 @@ static int cmdGetDels(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return RedisModule_ReplyWithLongLong(ctx, dels); } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (RedisModule_Init(ctx,"testkeyspace",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR){ return REDISMODULE_ERR; diff --git a/tests/modules/postnotifications.c b/tests/modules/postnotifications.c index 770711bc3f..52baec2a5c 100644 --- a/tests/modules/postnotifications.c +++ b/tests/modules/postnotifications.c @@ -244,8 +244,8 @@ static void KeySpace_ServerEventCallback(RedisModuleCtx *ctx, RedisModuleEvent e if (res == REDISMODULE_ERR) KeySpace_ServerEventPostNotificationFree(pn_ctx); } -/* This function must be present on each Redis module. It is used in order to - * register the commands into the Redis server. */ +/* This function must be present on each module. It is used in order to + * register the commands into the server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); diff --git a/tests/modules/test_lazyfree.c b/tests/modules/test_lazyfree.c index 7ba213ff86..d47cc7dbd8 100644 --- a/tests/modules/test_lazyfree.c +++ b/tests/modules/test_lazyfree.c @@ -166,7 +166,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) if (RedisModule_Init(ctx,"lazyfreetest",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - /* We only allow our module to be loaded when the redis core version is greater than the version of my module */ + /* We only allow our module to be loaded when the core version is greater than the version of my module */ if (RedisModule_GetTypeMethodVersion() < REDISMODULE_TYPE_METHOD_VERSION) { return REDISMODULE_ERR; } diff --git a/tests/modules/usercall.c b/tests/modules/usercall.c index 316de1eea0..4add315d5b 100644 --- a/tests/modules/usercall.c +++ b/tests/modules/usercall.c @@ -117,7 +117,7 @@ void *bg_call_worker(void *arg) { bg_call_data *bg = arg; RedisModuleBlockedClient *bc = bg->bc; - // Get Redis module context + // Get module context RedisModuleCtx *ctx = RedisModule_GetThreadSafeContext(bg->bc); // Acquire GIL @@ -157,7 +157,7 @@ void *bg_call_worker(void *arg) { // Unblock client RedisModule_UnblockClient(bc, NULL); - // Free the Redis module context + // Free the module context RedisModule_FreeThreadSafeContext(ctx); return NULL; diff --git a/tests/sentinel/tests/10-replica-priority.tcl b/tests/sentinel/tests/10-replica-priority.tcl index d3f868afab..17a59ed66a 100644 --- a/tests/sentinel/tests/10-replica-priority.tcl +++ b/tests/sentinel/tests/10-replica-priority.tcl @@ -24,7 +24,7 @@ test "Check acceptable replica-priority values" { fail "Able to set replica-announced with something else than yes or no (a3b2c1) whereas it should not be possible" } - # test only the first redis replica, no need to double test + # test only the first replica, no need to double test break } } diff --git a/tests/support/cluster.tcl b/tests/support/cluster.tcl index 081ef6a952..f6ae76f2f8 100644 --- a/tests/support/cluster.tcl +++ b/tests/support/cluster.tcl @@ -1,4 +1,4 @@ -# Tcl redis cluster client as a wrapper of redis.rb. +# Tcl cluster client as a wrapper of redis.rb. # Copyright (C) 2014 Salvatore Sanfilippo # Released under the BSD license like Redis itself # @@ -57,7 +57,7 @@ proc redis_cluster {nodes {tls -1}} { # maps ::redis_cluster::slots($id) with an hash mapping slot numbers # to node IDs. # -# This function is called when a new Redis Cluster client is initialized +# This function is called when a new Cluster client is initialized # and every time we get a -MOVED redirection error. proc ::redis_cluster::__method__refresh_nodes_map {id} { # Contact the first responding startup node. @@ -258,7 +258,7 @@ proc ::redis_cluster::__dispatch__ {id method args} { proc ::redis_cluster::get_keys_from_command {cmd argv} { set cmd [string tolower $cmd] - # Most Redis commands get just one key as first argument. + # Most commands get just one key as first argument. if {[lsearch -exact $::redis_cluster::plain_commands $cmd] != -1} { return [list [lindex $argv 0]] } @@ -276,7 +276,7 @@ proc ::redis_cluster::get_keys_from_command {cmd argv} { } # Returns the CRC16 of the specified string. -# The CRC parameters are described in the Redis Cluster specification. +# The CRC parameters are described in the Cluster specification. set ::redis_cluster::XMODEMCRC16Lookup { 0x0000 0x1021 0x2042 0x3063 0x4084 0x50a5 0x60c6 0x70e7 0x8108 0x9129 0xa14a 0xb16b 0xc18c 0xd1ad 0xe1ce 0xf1ef @@ -323,7 +323,7 @@ proc ::redis_cluster::crc16 {s} { } # Hash a single key returning the slot it belongs to, Implemented hash -# tags as described in the Redis Cluster specification. +# tags as described in the Cluster specification. proc ::redis_cluster::hash {key} { set keylen [string length $key] set s {} @@ -352,7 +352,7 @@ proc ::redis_cluster::hash {key} { # Return the slot the specified keys hash to. # If the keys hash to multiple slots, an empty string is returned to -# signal that the command can't be run in Redis Cluster. +# signal that the command can't be run in Cluster. proc ::redis_cluster::get_slot_from_keys {keys} { set slot {} foreach k $keys { diff --git a/tests/support/redis.tcl b/tests/support/redis.tcl index 53fa9fe915..bc106ffd68 100644 --- a/tests/support/redis.tcl +++ b/tests/support/redis.tcl @@ -1,4 +1,4 @@ -# Tcl client library - used by the Redis test +# Tcl client library - used by the server test # Copyright (C) 2009-2014 Salvatore Sanfilippo # Released under the BSD license like Redis itself # diff --git a/tests/support/response_transformers.tcl b/tests/support/response_transformers.tcl index c49bbb15c3..eeba2ff3bb 100644 --- a/tests/support/response_transformers.tcl +++ b/tests/support/response_transformers.tcl @@ -1,4 +1,4 @@ -# Tcl client library - used by the Redis test +# Tcl client library - used by the server test # Copyright (C) 2009-2023 Redis Ltd. # Released under the BSD license like Redis itself # diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 00d94ff338..6567abc657 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -542,7 +542,7 @@ proc find_valgrind_errors {stderr on_termination} { return "" } - # Look for the absence of a leak free summary (happens when redis isn't terminated properly). + # Look for the absence of a leak free summary (happens when the server isn't terminated properly). if {(![regexp -- {definitely lost: 0 bytes} $buf] && ![regexp -- {no leaks are possible} $buf])} { return $buf @@ -552,7 +552,7 @@ proc find_valgrind_errors {stderr on_termination} { } # Execute a background process writing random data for the specified number -# of seconds to the specified Redis instance. +# of seconds to the specified the server instance. proc start_write_load {host port seconds} { set tclsh [info nameofexecutable] exec $tclsh tests/helpers/gen_write_load.tcl $host $port $seconds $::tls & @@ -588,7 +588,7 @@ proc lshuffle {list} { } # Execute a background process writing complex data for the specified number -# of ops to the specified Redis instance. +# of ops to the specified server instance. proc start_bg_complex_data {host port db ops} { set tclsh [info nameofexecutable] exec $tclsh tests/helpers/bg_complex_data.tcl $host $port $db $ops $::tls & @@ -601,7 +601,7 @@ proc stop_bg_complex_data {handle} { # Write num keys with the given key prefix and value size (in bytes). If idx is # given, it's the index (AKA level) used with the srv procedure and it specifies -# to which Redis instance to write the keys. +# to which server instance to write the keys. proc populate {num {prefix key:} {size 3} {idx 0} {prints false} {expires 0}} { r $idx deferred 1 if {$num > 16} {set pipeline 16} else {set pipeline $num} @@ -705,11 +705,11 @@ proc generate_fuzzy_traffic_on_key {key duration} { # find a random command for our key type set cmd_idx [expr {int(rand()*[llength $cmds])}] set cmd [lindex $cmds $cmd_idx] - # get the command details from redis + # get the command details from the server if { [ catch { set cmd_info [lindex [r command info $cmd] 0] } err ] } { - # if we failed, it means redis crashed after the previous command + # if we failed, it means the server crashed after the previous command return $sent } # try to build a valid command argument @@ -1022,7 +1022,7 @@ proc init_large_mem_vars {} { } } -# Utility function to write big argument into redis client connection +# Utility function to write big argument into a server client connection proc write_big_bulk {size {prefix ""} {skip_read no}} { init_large_mem_vars diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 1c79cbbec1..a6a2b658b5 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -1,4 +1,4 @@ -# Redis test suite. Copyright (C) 2009 Salvatore Sanfilippo antirez@gmail.com +# Server test suite. Copyright (C) 2009 Salvatore Sanfilippo antirez@gmail.com # This software is released under the BSD License. See the COPYING file for # more information. @@ -112,7 +112,7 @@ set ::next_test 0 set ::host 127.0.0.1 set ::port 6379; # port for external server -set ::baseport 21111; # initial port for spawned redis servers +set ::baseport 21111; # initial port for spawned servers set ::portcount 8000; # we don't wanna use more than 10000 to avoid collision with cluster bus ports set ::traceleaks 0 set ::valgrind 0 @@ -138,7 +138,7 @@ set ::accurate 0; # If true runs fuzz tests with more iterations set ::force_failure 0 set ::timeout 1200; # 20 minutes without progresses will quit the test. set ::last_progress [clock seconds] -set ::active_servers {} ; # Pids of active Redis instances. +set ::active_servers {} ; # Pids of active server instances. set ::dont_clean 0 set ::dont_pre_clean 0 set ::wait_server 0 @@ -154,7 +154,7 @@ set ::large_memory 0 set ::log_req_res 0 set ::force_resp3 0 -# Set to 1 when we are running in client mode. The Redis test uses a +# Set to 1 when we are running in client mode. The server test uses a # server-client model to run tests simultaneously. The server instance # runs the specified number of client instances that will actually run tests. # The server is responsible of showing the result to the user, and exit with @@ -218,7 +218,7 @@ proc r {args} { [srv $level "client"] {*}$args } -# Returns a Redis instance by index. +# Returns a server instance by index. proc Rn {n} { set level [expr -1*$n] return [srv $level "client"] @@ -909,7 +909,7 @@ proc close_replication_stream {s} { return } -# With the parallel test running multiple Redis instances at the same time +# With the parallel test running multiple server instances at the same time # we need a fast enough computer, otherwise a lot of tests may generate # false positives. # If the computer is too slow we revert the sequential test without any diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index cdd12511e2..b69b1f40b2 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -526,7 +526,7 @@ start_server {tags {"acl external:skip"}} { } } - # Note that the order of the generated ACL rules is not stable in Redis + # Note that the order of the generated ACL rules is not stable in the server # so we need to match the different parts and not as a whole string. test {ACL GETUSER is able to translate back command permissions} { # Subtractive diff --git a/tests/unit/bitfield.tcl b/tests/unit/bitfield.tcl index 21091aa99c..2dfc77b48a 100644 --- a/tests/unit/bitfield.tcl +++ b/tests/unit/bitfield.tcl @@ -114,7 +114,7 @@ start_server {tags {"bitops"}} { } set max [expr {$min+$range-1}] - # Compare Tcl vs Redis + # Compare Tcl vs the server set range2 [expr {$range*2}] set value [expr {($min*2)+[randomInt $range2]}] set increment [expr {($min*2)+[randomInt $range2]}] @@ -166,7 +166,7 @@ start_server {tags {"bitops"}} { } set max [expr {$min+$range-1}] - # Compare Tcl vs Redis + # Compare Tcl vs the server set range2 [expr {$range*2}] set value [expr {($min*2)+[randomInt $range2]}] set increment [expr {($min*2)+[randomInt $range2]}] diff --git a/tests/unit/bitops.tcl b/tests/unit/bitops.tcl index f50f65dfa0..edcafdee07 100644 --- a/tests/unit/bitops.tcl +++ b/tests/unit/bitops.tcl @@ -1,4 +1,4 @@ -# Compare Redis commands against Tcl implementations of the same commands. +# Compare server commands against Tcl implementations of the same commands. proc count_bits s { binary scan $s b* bits string length [regsub -all {0} $bits {}] diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index 1fc7c02ca9..2484a4d136 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -1,6 +1,6 @@ tags {"external:skip logreqres:skip"} { -# Get info about a redis client connection: +# Get info about a server client connection: # name - name of client we want to query # f - field name from "CLIENT LIST" we want to get proc client_field {name f} { @@ -27,7 +27,7 @@ proc gen_client {} { return [list $rr $name] } -# Sum a value across all redis client connections: +# Sum a value across all server client connections: # f - the field name from "CLIENT LIST" we want to sum proc clients_sum {f} { set sum 0 diff --git a/tests/unit/cluster/cli.tcl b/tests/unit/cluster/cli.tcl index 734dd19c9f..b5d9e81de3 100644 --- a/tests/unit/cluster/cli.tcl +++ b/tests/unit/cluster/cli.tcl @@ -1,4 +1,4 @@ -# Primitive tests on cluster-enabled redis using redis-cli +# Primitive tests on cluster-enabled server using valkey-cli source tests/support/cli.tcl @@ -87,7 +87,7 @@ start_multiple_servers 3 [list overrides $base_conf] { set endpoint_type_before_set [lindex [split [$node1 CONFIG GET cluster-preferred-endpoint-type] " "] 1] $node1 CONFIG SET cluster-preferred-endpoint-type unknown-endpoint - # when redis-cli not in cluster mode, return MOVE with empty host + # when valkey-cli not in cluster mode, return MOVE with empty host set slot_for_foo [$node1 CLUSTER KEYSLOT foo] assert_error "*MOVED $slot_for_foo :*" {$node1 set foo bar} @@ -272,7 +272,7 @@ test {Migrate the last slot away from a node using valkey-cli} { set owner_r [redis $owner_host $owner_port 0 $::tls] set owner_id [$owner_r CLUSTER MYID] - # Move slot to new node using plain Redis commands + # Move slot to new node using plain commands assert_equal OK [$newnode_r CLUSTER SETSLOT $slot IMPORTING $owner_id] assert_equal OK [$owner_r CLUSTER SETSLOT $slot MIGRATING $newnode_id] assert_equal {foo} [$owner_r CLUSTER GETKEYSINSLOT $slot 10] @@ -295,7 +295,7 @@ test {Migrate the last slot away from a node using valkey-cli} { fail "Cluster doesn't stabilize" } - # Move the only slot back to original node using redis-cli + # Move the only slot back to original node using valkey-cli exec src/valkey-cli --cluster reshard 127.0.0.1:[srv -3 port] \ --cluster-from $newnode_id \ --cluster-to $owner_id \ diff --git a/tests/unit/cluster/links.tcl b/tests/unit/cluster/links.tcl index a202c378bd..4092d99833 100644 --- a/tests/unit/cluster/links.tcl +++ b/tests/unit/cluster/links.tcl @@ -191,7 +191,7 @@ start_cluster 3 0 {tags {external:skip cluster}} { # On primary1, set cluster link send buffer limit to 256KB, which is large enough to not be # overflowed by regular gossip messages but also small enough that it doesn't take too much - # memory to overflow it. If it is set too high, Redis may get OOM killed by kernel before this + # memory to overflow it. If it is set too high, the server may get OOM killed by kernel before this # limit is overflowed in some RAM-limited test environments. set oldlimit [lindex [$primary1 CONFIG get cluster-link-sendbuf-limit] 1] $primary1 CONFIG set cluster-link-sendbuf-limit [expr 256*1024] diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl index 08fa88a105..a2554c865d 100644 --- a/tests/unit/expire.tcl +++ b/tests/unit/expire.tcl @@ -187,7 +187,7 @@ start_server {tags {"expire"}} { r psetex key2 500 a r psetex key3 500 a assert_equal 3 [r dbsize] - # Redis expires random keys ten times every second so we are + # The server expires random keys ten times every second so we are # fairly sure that all the three keys should be evicted after # two seconds. wait_for_condition 20 100 { @@ -204,7 +204,7 @@ start_server {tags {"expire"}} { r psetex key2{t} 500 a r psetex key3{t} 500 a set size1 [r dbsize] - # Redis expires random keys ten times every second so we are + # The server expires random keys ten times every second so we are # fairly sure that all the three keys should be evicted after # one second. after 1000 diff --git a/tests/unit/geo.tcl b/tests/unit/geo.tcl index 6175329da0..19af863993 100644 --- a/tests/unit/geo.tcl +++ b/tests/unit/geo.tcl @@ -1,5 +1,5 @@ # Helper functions to simulate search-in-radius in the Tcl side in order to -# verify the Redis implementation with a fuzzy test. +# verify the server implementation with a fuzzy test. proc geo_degrad deg {expr {$deg*(atan(1)*8/360)}} proc geo_raddeg rad {expr {$rad/(atan(1)*8/360)}} @@ -632,7 +632,7 @@ start_server {tags {"geo"}} { continue } if {$mydist < [expr {$radius_km*1000}]} { - # This is a false positive for redis since given the + # This is a false positive for the server since given the # same points the higher precision calculation provided # by TCL shows the point within range incr rounding_errors diff --git a/tests/unit/hyperloglog.tcl b/tests/unit/hyperloglog.tcl index ee437189fb..c1e24ceec6 100644 --- a/tests/unit/hyperloglog.tcl +++ b/tests/unit/hyperloglog.tcl @@ -167,7 +167,7 @@ start_server {tags {"hll"}} { } # Use the hyperloglog to check if it crashes - # Redis in some way. + # the server in some way. catch { r pfcount hll } diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 1e6e38625c..f6c78ea75e 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -612,7 +612,7 @@ start_server {tags {"introspection"}} { } test {CONFIG SET rollback on apply error} { - # This test tries to configure a used port number in redis. This is expected + # This test tries to configure a used port number in the server. This is expected # to pass the `CONFIG SET` validity checking implementation but fail on # actual "apply" of the setting. This will validate that after an "apply" # failure we rollback to the previous values. @@ -645,7 +645,7 @@ start_server {tags {"introspection"}} { set used_port [find_available_port $::baseport $::portcount] dict set some_configs port $used_port - # Run a dummy server on used_port so we know we can't configure redis to + # Run a dummy server on used_port so we know we can't configure the server to # use it. It's ok for this to fail because that means used_port is invalid # anyway catch {socket -server dummy_accept -myaddr 127.0.0.1 $used_port} e diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl index 363dab4725..bbf43c2f14 100644 --- a/tests/unit/maxmemory.tcl +++ b/tests/unit/maxmemory.tcl @@ -272,7 +272,7 @@ start_server {tags {"maxmemory external:skip"}} { incr numkeys } # Now we add the same number of volatile keys already added. - # We expect Redis to evict only volatile keys in order to make + # We expect the server to evict only volatile keys in order to make # space. set err 0 for {set j 0} {$j < $numkeys} {incr j} { @@ -435,7 +435,7 @@ start_server {tags {"maxmemory external:skip"}} { # Next writing command will trigger evicting some keys if last # command trigger DB dict rehash r set k2 v2 - # There must be 4098 keys because redis doesn't evict keys. + # There must be 4098 keys because the server doesn't evict keys. r dbsize } {4098} } diff --git a/tests/unit/moduleapi/async_rm_call.tcl b/tests/unit/moduleapi/async_rm_call.tcl index 1bf12de237..d03cfc25c0 100644 --- a/tests/unit/moduleapi/async_rm_call.tcl +++ b/tests/unit/moduleapi/async_rm_call.tcl @@ -165,7 +165,7 @@ start_server {tags {"modules"}} { $rd do_rm_call_async blpop l 0 wait_for_blocked_clients_count 1 - #become a replica of a not existing redis + #become a replica of a not existing server r replicaof localhost 30000 catch {[$rd read]} e diff --git a/tests/unit/moduleapi/auth.tcl b/tests/unit/moduleapi/auth.tcl index c7c2def779..aae57535e3 100644 --- a/tests/unit/moduleapi/auth.tcl +++ b/tests/unit/moduleapi/auth.tcl @@ -21,7 +21,7 @@ start_server {tags {"modules"}} { assert_equal [r auth.changecount] 0 r auth.createmoduleuser - # Catch the I/O exception that was thrown when Redis + # Catch the I/O exception that was thrown when the server # disconnected with us. catch { [r ping] } e assert_match {*I/O*} $e diff --git a/tests/unit/moduleapi/blockedclient.tcl b/tests/unit/moduleapi/blockedclient.tcl index 22b2c4bae5..abefaff274 100644 --- a/tests/unit/moduleapi/blockedclient.tcl +++ b/tests/unit/moduleapi/blockedclient.tcl @@ -151,7 +151,7 @@ foreach call_type {nested normal} { $rd slow_fg_command 200000 } $rd flush - after 10 ;# try to make sure redis started running the command before we proceed + after 10 ;# try to make sure the server started running the command before we proceed # make sure we didn't get BUSY error, it simply blocked till the command was done r ping diff --git a/tests/unit/moduleapi/cluster.tcl b/tests/unit/moduleapi/cluster.tcl index 4c0a49d48d..d24082ec44 100644 --- a/tests/unit/moduleapi/cluster.tcl +++ b/tests/unit/moduleapi/cluster.tcl @@ -1,4 +1,4 @@ -# Primitive tests on cluster-enabled redis with modules +# Primitive tests on cluster-enabled server with modules source tests/support/cli.tcl diff --git a/tests/unit/moduleapi/defrag.tcl b/tests/unit/moduleapi/defrag.tcl index b2e23967ec..e169f8de9b 100644 --- a/tests/unit/moduleapi/defrag.tcl +++ b/tests/unit/moduleapi/defrag.tcl @@ -7,7 +7,7 @@ start_server {tags {"modules"} overrides {{save ""}}} { r config set active-defrag-threshold-lower 0 r config set active-defrag-cycle-min 99 - # try to enable active defrag, it will fail if redis was compiled without it + # try to enable active defrag, it will fail if the server was compiled without it catch {r config set activedefrag yes} e if {[r config get activedefrag] eq "activedefrag yes"} { diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index da2ca8489c..7bee0ea2b5 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -549,7 +549,7 @@ if {[string match {*jemalloc*} [s mem_allocator]]} { test {test RM_Call with large arg for SET command} { # set a big value to trigger increasing the query buf r set foo [string repeat A 100000] - # set a smaller value but > PROTO_MBULK_BIG_ARG (32*1024) Redis will try to save the query buf itself on the DB. + # set a smaller value but > PROTO_MBULK_BIG_ARG (32*1024) the server will try to save the query buf itself on the DB. r test.call_generic set bar [string repeat A 33000] # asset the value was trimmed assert {[r memory usage bar] < 42000}; # 42K to count for Jemalloc's additional memory overhead. diff --git a/tests/unit/moduleapi/moduleauth.tcl b/tests/unit/moduleapi/moduleauth.tcl index 82f42f5d1e..a9eb0561c3 100644 --- a/tests/unit/moduleapi/moduleauth.tcl +++ b/tests/unit/moduleapi/moduleauth.tcl @@ -291,7 +291,7 @@ start_server {tags {"modules"}} { r acl setuser foo >pwd on ~* &* +@all set rd [redis_deferring_client] - # Attempt blocking module auth and disable the Redis user while module auth is in progress. + # Attempt blocking module auth and disable the user while module auth is in progress. $rd AUTH foo pwd wait_for_blocked_clients_count 1 r acl setuser foo >pwd off ~* &* +@all @@ -339,8 +339,8 @@ start_server {tags {"modules"}} { r acl setuser foo >defaultpwd on ~* &* +@all set rd [redis_deferring_client] - # Start the module auth attempt with the standard Redis auth password for the user. This - # will result in all module auth cbs attempted and then standard Redis auth will be tried. + # Start the module auth attempt with the standard auth password for the user. This + # will result in all module auth cbs attempted and then standard auth will be tried. $rd AUTH foo defaultpwd wait_for_blocked_clients_count 1 diff --git a/tests/unit/moduleapi/rdbloadsave.tcl b/tests/unit/moduleapi/rdbloadsave.tcl index 9319c93854..b0e6d54229 100644 --- a/tests/unit/moduleapi/rdbloadsave.tcl +++ b/tests/unit/moduleapi/rdbloadsave.tcl @@ -32,10 +32,10 @@ start_server {tags {"modules"}} { assert_equal [r dbsize] 0 # Send commands with pipeline. First command will call RM_RdbLoad() in - # the command callback. While loading RDB, Redis can go to networking to + # the command callback. While loading RDB, the server can go to networking to # reply -LOADING. By sending commands in pipeline, we verify it doesn't # cause a problem. - # e.g. Redis won't try to process next message of the current client + # e.g. the server won't try to process next message of the current client # while it is in the command callback for that client . set rd1 [redis_deferring_client] $rd1 test.rdbload blabla.rdb diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 85d20ddf38..80765e69c7 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -883,7 +883,7 @@ start_server {tags {"multi"}} { r set foo bar r config set maxmemory bla - # letting the redis parser read it, it'll throw an exception instead of + # letting the server parser read it, it'll throw an exception instead of # reply with an array that contains an error, so we switch to reading # raw RESP instead r readraw 1 diff --git a/tests/unit/obuf-limits.tcl b/tests/unit/obuf-limits.tcl index 45efc26b45..42185fa3d9 100644 --- a/tests/unit/obuf-limits.tcl +++ b/tests/unit/obuf-limits.tcl @@ -131,7 +131,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { $rd flush after 100 - # Before we read reply, redis will close this client. + # Before we read reply, the server will close this client. set clients [r client list] assert_no_match "*name=mybiglist*" $clients set cur_mem [s used_memory] @@ -143,7 +143,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { assert_equal {} [$rd rawread] } - # Note: This test assumes that what's written with one write, will be read by redis in one read. + # Note: This test assumes that what's written with one write, will be read by the server in one read. # this assumption is wrong, but seem to work empirically (for now) test {No response for multi commands in pipeline if client output buffer limit is enforced} { r config set client-output-buffer-limit {normal 100000 0 0} @@ -154,7 +154,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { $rd2 client setname multicommands assert_equal "OK" [$rd2 read] - # Let redis sleep 1s firstly + # Let the server sleep 1s firstly $rd1 debug sleep 1 $rd1 flush after 100 @@ -162,7 +162,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { # Create a pipeline of commands that will be processed in one socket read. # It is important to use one write, in TLS mode independent writes seem # to wait for response from the server. - # Total size should be less than OS socket buffer, redis can + # Total size should be less than OS socket buffer, the server can # execute all commands in this pipeline when it wakes up. set buf "" for {set i 0} {$i < 15} {incr i} { diff --git a/tests/unit/scan.tcl b/tests/unit/scan.tcl index d980a52adb..49939288fb 100644 --- a/tests/unit/scan.tcl +++ b/tests/unit/scan.tcl @@ -109,7 +109,7 @@ proc test_scan {type} { after 2 - # TODO: remove this in redis 8.0 + # TODO: remove this in server version 8.0 set cur 0 set keys {} while 1 { @@ -124,7 +124,7 @@ proc test_scan {type} { # make sure that expired key have been removed by scan command assert_equal 1000 [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d] - # TODO: uncomment in redis 8.0 + # TODO: uncomment in server version 8.0 #assert_error "*unknown type name*" {r scan 0 type "string1"} # expired key will be no touched by scan command #assert_equal 1001 [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d] @@ -193,7 +193,7 @@ proc test_scan {type} { # make sure that expired key have been removed by scan command assert_equal 1000 [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d] - # TODO: uncomment in redis 8.0 + # TODO: uncomment in server version 8.0 # make sure that only the expired key in the type match will been removed by scan command #assert_equal 1001 [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d] diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index feef69122d..b45099519d 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -377,7 +377,7 @@ start_server {tags {"scripting"}} { test {EVAL - JSON numeric decoding} { # We must return the table as a string because otherwise - # Redis converts floats to ints and we get 0 and 1023 instead + # the server converts floats to ints and we get 0 and 1023 instead # of 0.0003 and 1023.2 as the parsed output. run_script {return table.concat( @@ -1414,7 +1414,7 @@ start_server {tags {"scripting repl external:skip"}} { } } - # replicate_commands is the default on Redis Function + # replicate_commands is the default on server Functions test "Redis.replicate_commands() can be issued anywhere now" { r eval { redis.call('set','foo','bar'); @@ -2227,7 +2227,7 @@ start_server {tags {"scripting"}} { test "Consistent eval error reporting" { r config resetstat r config set maxmemory 1 - # Script aborted due to Redis state (OOM) should report script execution error with detailed internal error + # Script aborted due to server state (OOM) should report script execution error with detailed internal error assert_error {OOM command not allowed when used memory > 'maxmemory'*} { r eval {return redis.call('set','x','y')} 1 x } @@ -2236,7 +2236,7 @@ start_server {tags {"scripting"}} { assert_match {calls=0*rejected_calls=1,failed_calls=0*} [cmdrstat set r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval r] - # redis.pcall() failure due to Redis state (OOM) returns lua error table with Redis error message without '-' prefix + # redis.pcall() failure due to server state (OOM) returns lua error table with server error message without '-' prefix r config resetstat assert_equal [ r eval { @@ -2268,7 +2268,7 @@ start_server {tags {"scripting"}} { r config set maxmemory 0 r config resetstat - # Script aborted due to error result of Redis command + # Script aborted due to error result of server command assert_error {ERR DB index is out of range*} { r eval {return redis.call('select',99)} 0 } @@ -2277,7 +2277,7 @@ start_server {tags {"scripting"}} { assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat select r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval r] - # redis.pcall() failure due to error in Redis command returns lua error table with redis error message without '-' prefix + # redis.pcall() failure due to error in server command returns lua error table with server error message without '-' prefix r config resetstat assert_equal [ r eval { @@ -2304,7 +2304,7 @@ start_server {tags {"scripting"}} { assert_match {calls=0*rejected_calls=1,failed_calls=0*} [cmdrstat set r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval_ro r] - # redis.pcall() failure due to scripting specific error state (write cmd with eval_ro) returns lua error table with Redis error message without '-' prefix + # redis.pcall() failure due to scripting specific error state (write cmd with eval_ro) returns lua error table with server error message without '-' prefix r config resetstat assert_equal [ r eval_ro { diff --git a/tests/unit/sort.tcl b/tests/unit/sort.tcl index a46f77cf9b..397e7e12ea 100644 --- a/tests/unit/sort.tcl +++ b/tests/unit/sort.tcl @@ -12,7 +12,7 @@ start_server { r del tosort for {set i 0} {$i < $num} {incr i} { # Make sure all the weights are different because - # Redis does not use a stable sort but Tcl does. + # the server does not use a stable sort but Tcl does. while 1 { randpath { set rint [expr int(rand()*1000000)] diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl index 666b5930e4..ee28c0a918 100644 --- a/tests/unit/tracking.tcl +++ b/tests/unit/tracking.tcl @@ -745,7 +745,7 @@ start_server {tags {"tracking network logreqres:skip"}} { test {Regression test for #11715} { # This issue manifests when a client invalidates keys through the max key - # limit, which invalidates keys to get Redis below the limit, but no command is + # limit, which invalidates keys to get the server below the limit, but no command is # then executed. This can occur in several ways but the simplest is through # multi-exec which queues commands. clean_all diff --git a/tests/unit/type/stream.tcl b/tests/unit/type/stream.tcl index 06f58c8a2f..68648aab7e 100644 --- a/tests/unit/type/stream.tcl +++ b/tests/unit/type/stream.tcl @@ -32,7 +32,7 @@ proc streamRandomID {min_id max_id} { return $ms-$seq } -# Tcl-side implementation of XRANGE to perform fuzz testing in the Redis +# Tcl-side implementation of XRANGE to perform fuzz testing in the server # XRANGE implementation. proc streamSimulateXRANGE {items start end} { set res {} diff --git a/tests/unit/type/string.tcl b/tests/unit/type/string.tcl index 94702ec3dc..381cc4a693 100644 --- a/tests/unit/type/string.tcl +++ b/tests/unit/type/string.tcl @@ -501,7 +501,7 @@ if {[string match {*jemalloc*} [s mem_allocator]]} { test {trim on SET with big value} { # set a big value to trigger increasing the query buf r set key [string repeat A 100000] - # set a smaller value but > PROTO_MBULK_BIG_ARG (32*1024) Redis will try to save the query buf itself on the DB. + # set a smaller value but > PROTO_MBULK_BIG_ARG (32*1024) the server will try to save the query buf itself on the DB. r set key [string repeat A 33000] # asset the value was trimmed assert {[r memory usage key] < 42000}; # 42K to count for Jemalloc's additional memory overhead. diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index 03f451c797..fd24e418fd 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -1826,7 +1826,7 @@ start_server {tags {"zset"}} { # Make sure data is the same in both sides assert {[r zrange zset 0 -1] eq $lexset} - # Get the Redis output + # Get the server output set output [r $cmd zset $cmin $cmax] if {$rev} { set outlen [r zlexcount zset $cmax $cmin] @@ -1842,7 +1842,7 @@ start_server {tags {"zset"}} { # Empty output when ranges are inverted. } else { if {$rev} { - # Invert the Tcl array using Redis itself. + # Invert the Tcl array using the server itself. set copy [r zrevrange zset 0 -1] # Invert min / max as well lassign [list $min $max $mininc $maxinc] \ diff --git a/utils/generate-command-code.py b/utils/generate-command-code.py index 673ef28466..05e218e780 100755 --- a/utils/generate-command-code.py +++ b/utils/generate-command-code.py @@ -576,7 +576,7 @@ def create_command(name, desc): """ /* We have fabulous commands from * the fantastic - * Redis Command Table! */ + * Command Table! */ /* Must match serverCommandGroup */ const char *COMMAND_GROUP_STR[] = { diff --git a/utils/hyperloglog/hll-err.rb b/utils/hyperloglog/hll-err.rb index 2c71ac5efc..e04cf93800 100644 --- a/utils/hyperloglog/hll-err.rb +++ b/utils/hyperloglog/hll-err.rb @@ -1,7 +1,7 @@ # hll-err.rb - Copyright (C) 2014 Salvatore Sanfilippo # BSD license, See the COPYING file for more information. # -# Check error of HyperLogLog Redis implementation for different set sizes. +# Check error of HyperLogLog implementation for different set sizes. require 'rubygems' require 'redis' diff --git a/utils/hyperloglog/hll-gnuplot-graph.rb b/utils/hyperloglog/hll-gnuplot-graph.rb index 6c7596d17c..61f0672637 100644 --- a/utils/hyperloglog/hll-gnuplot-graph.rb +++ b/utils/hyperloglog/hll-gnuplot-graph.rb @@ -2,7 +2,7 @@ # BSD license, See the COPYING file for more information. # # This program is suited to output average and maximum errors of -# the Redis HyperLogLog implementation in a format suitable to print +# the HyperLogLog implementation in a format suitable to print # graphs using gnuplot. require 'rubygems' @@ -12,7 +12,7 @@ # Generate an array of [cardinality,relative_error] pairs # in the 0 - max range, with the specified step. # -# 'r' is the Redis object used to perform the queries. +# 'r' is the Object used to perform the queries. # 'seed' must be different every time you want a test performed # with a different set. The function guarantees that if 'seed' is the # same, exactly the same dataset is used, and when it is different, diff --git a/utils/install_server.sh b/utils/install_server.sh index e22d88bb40..6a1f26d647 100755 --- a/utils/install_server.sh +++ b/utils/install_server.sh @@ -25,7 +25,7 @@ # ################################################################################ # -# Service installer for redis server, runs interactively by default. +# Service installer for the server, runs interactively by default. # # To run this script non-interactively (for automation/provisioning purposes), # feed the variables into the script. Any missing variables will be prompted! @@ -37,9 +37,9 @@ # REDIS_CONFIG_FILE=/etc/redis/1234.conf \ # REDIS_LOG_FILE=/var/log/redis_1234.log \ # REDIS_DATA_DIR=/var/lib/redis/1234 \ -# REDIS_EXECUTABLE=`command -v redis-server` ./utils/install_server.sh +# REDIS_EXECUTABLE=`command -v valkey-server` ./utils/install_server.sh # -# This generates a redis config file and an /etc/init.d script, and installs them. +# This generates a server config file and an /etc/init.d script, and installs them. # # /!\ This script should be run as root # @@ -85,7 +85,7 @@ unset _pid_1_exe if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then _MANUAL_EXECUTION=true - #Read the redis port + #Read the server port read -p "Please select the redis port for this instance: [$_REDIS_PORT] " REDIS_PORT if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then echo "Selecting default: $_REDIS_PORT" @@ -95,7 +95,7 @@ fi if [ -z "$REDIS_CONFIG_FILE" ] ; then _MANUAL_EXECUTION=true - #read the redis config file + #read the server config file _REDIS_CONFIG_FILE="/etc/redis/$REDIS_PORT.conf" read -p "Please select the redis config file name [$_REDIS_CONFIG_FILE] " REDIS_CONFIG_FILE if [ -z "$REDIS_CONFIG_FILE" ] ; then @@ -106,7 +106,7 @@ fi if [ -z "$REDIS_LOG_FILE" ] ; then _MANUAL_EXECUTION=true - #read the redis log file path + #read the server log file path _REDIS_LOG_FILE="/var/log/redis_$REDIS_PORT.log" read -p "Please select the redis log file name [$_REDIS_LOG_FILE] " REDIS_LOG_FILE if [ -z "$REDIS_LOG_FILE" ] ; then @@ -117,7 +117,7 @@ fi if [ -z "$REDIS_DATA_DIR" ] ; then _MANUAL_EXECUTION=true - #get the redis data directory + #get the server data directory _REDIS_DATA_DIR="/var/lib/redis/$REDIS_PORT" read -p "Please select the data directory for this instance [$_REDIS_DATA_DIR] " REDIS_DATA_DIR if [ -z "$REDIS_DATA_DIR" ] ; then @@ -128,7 +128,7 @@ fi if [ ! -x "$REDIS_EXECUTABLE" ] ; then _MANUAL_EXECUTION=true - #get the redis executable path + #get the server executable path _REDIS_EXECUTABLE=`command -v redis-server` read -p "Please select the redis executable path [$_REDIS_EXECUTABLE] " REDIS_EXECUTABLE if [ ! -x "$REDIS_EXECUTABLE" ] ; then @@ -141,7 +141,7 @@ if [ ! -x "$REDIS_EXECUTABLE" ] ; then fi fi -#check the default for redis cli +#check the default for valkey cli CLI_EXEC=`command -v redis-cli` if [ -z "$CLI_EXEC" ] ; then CLI_EXEC=`dirname $REDIS_EXECUTABLE`"/redis-cli" diff --git a/utils/lru/lfu-simulation.c b/utils/lru/lfu-simulation.c index 60105e55b0..59b5e332c0 100644 --- a/utils/lru/lfu-simulation.c +++ b/utils/lru/lfu-simulation.c @@ -8,7 +8,7 @@ int keyspace_size = 1000000; time_t switch_after = 30; /* Switch access pattern after N seconds. */ struct entry { - /* Field that the LFU Redis implementation will have (we have + /* Field that the LFU implementation will have (we have * 24 bits of total space in the object->lru field). */ uint8_t counter; /* Logarithmic counter. */ uint16_t decrtime; /* (Reduced precision) time of last decrement. */ diff --git a/utils/redis-copy.rb b/utils/redis-copy.rb index 7c5c52dd6c..9f8335c341 100644 --- a/utils/redis-copy.rb +++ b/utils/redis-copy.rb @@ -1,7 +1,7 @@ # redis-copy.rb - Copyright (C) 2009-2010 Salvatore Sanfilippo # BSD license, See the COPYING file for more information. # -# Copy the whole dataset from one Redis instance to another one +# Copy the whole dataset from one server instance to another one # # WARNING: this utility is deprecated and serves as a legacy adapter # for the more-robust redis-copy gem. diff --git a/utils/redis_init_script b/utils/redis_init_script index 006db87e5f..da8fee41ff 100755 --- a/utils/redis_init_script +++ b/utils/redis_init_script @@ -1,6 +1,6 @@ #!/bin/sh # -# Simple Redis init.d script conceived to work on Linux systems +# Simple server init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. ### BEGIN INIT INFO diff --git a/utils/req-res-log-validator.py b/utils/req-res-log-validator.py index e2d471370c..d9d0df71af 100755 --- a/utils/req-res-log-validator.py +++ b/utils/req-res-log-validator.py @@ -159,7 +159,7 @@ def __init__(self, f, line_counter): count = int(line[1:]) for i in range(count): field = Response(f, line_counter) - # Redis allows fields to be non-strings but JSON doesn't. + # The server allows fields to be non-strings but JSON doesn't. # Luckily, for any kind of response we can validate, the fields are # always strings (example: XINFO STREAM) # The reason we can't always convert to string is because of DEBUG PROTOCOL MAP diff --git a/utils/speed-regression.tcl b/utils/speed-regression.tcl index bf35c7db4b..6802d8cd5e 100755 --- a/utils/speed-regression.tcl +++ b/utils/speed-regression.tcl @@ -26,7 +26,7 @@ proc run-tests branches { continue } - # Start the Redis server + # Start the server puts " starting the server... [exec ./redis-server -v]" set pids [exec echo "port $::port\nloglevel warning\n" | ./redis-server - > /dev/null 2> /dev/null &] puts " pids: $pids" @@ -83,7 +83,7 @@ proc combine-results {results} { } proc main {} { - # Note: the first branch is only used in order to get the redis-benchmark + # Note: the first branch is only used in order to get the valkey-benchmark # executable. Tests are performed starting from the second branch. set branches { slowset 2.2.0 2.4.0 unstable slowset diff --git a/utils/tracking_collisions.c b/utils/tracking_collisions.c index f52111173d..4df3e84af5 100644 --- a/utils/tracking_collisions.c +++ b/utils/tracking_collisions.c @@ -1,6 +1,6 @@ /* This is a small program used in order to understand the collision rate * of CRC64 (ISO version) VS other stronger hashing functions in the context - * of hashing keys for the Redis "tracking" feature (client side caching + * of hashing keys for the "tracking" feature (client side caching * assisted by the server). * * The program attempts to hash keys with common names in the form of From c0cef48e98574acd9840abf1c44c963eb56861ce Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Tue, 9 Apr 2024 07:15:59 -0700 Subject: [PATCH 81/98] Fix reference to redis-tls module (#273) Update test usage of valkey-tls.so module to use valkey-tls.so instead. Fixes tests failures like https://github.com/valkey-io/valkey/actions/runs/8592855995/job/23543475478. Signed-off-by: Madelyn Olson --- tests/instances.tcl | 2 +- tests/support/server.tcl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/instances.tcl b/tests/instances.tcl index 7f81a15bc3..6b8efe4486 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -87,7 +87,7 @@ proc spawn_instance {type base_port count {conf {}} {base_conf_file ""}} { if {$::tls} { if {$::tls_module} { - puts $cfg [format "loadmodule %s/../../../src/redis-tls.so" [pwd]] + puts $cfg [format "loadmodule %s/../../../src/valkey-tls.so" [pwd]] } puts $cfg "tls-port $port" diff --git a/tests/support/server.tcl b/tests/support/server.tcl index a4af3db174..c28444950c 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -480,7 +480,7 @@ proc start_server {options {code undefined}} { set config {} if {$::tls} { if {$::tls_module} { - lappend config_lines [list "loadmodule" [format "%s/src/redis-tls.so" [pwd]]] + lappend config_lines [list "loadmodule" [format "%s/src/valkey-tls.so" [pwd]]] } dict set config "tls-cert-file" [format "%s/tests/tls/server.crt" [pwd]] dict set config "tls-key-file" [format "%s/tests/tls/server.key" [pwd]] From da831c0d2242251be84a5d7f14f954c6c7fa8ee8 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Tue, 9 Apr 2024 10:38:09 -0400 Subject: [PATCH 82/98] rename procedure redis_deferring_client to valkey_deferring_client (#270) Updated procedure redis_deferring_client in test environent to valkey_deferring_client. Signed-off-by: Shivshankar-Reddy --- src/logreqres.c | 2 +- .../tests/16-transactions-on-replica.tcl | 2 +- .../cluster/tests/17-diskless-load-swapdb.tcl | 2 +- .../tests/25-pubsubshard-slot-migration.tcl | 12 +- tests/cluster/tests/26-pubsubshard.tcl | 20 +-- tests/instances.tcl | 4 +- tests/integration/aof.tcl | 4 +- tests/integration/corrupt-dump-fuzzer.tcl | 2 +- tests/integration/dismiss-mem.tcl | 4 +- tests/integration/failover.tcl | 2 +- tests/integration/rdb.tcl | 4 +- tests/integration/replication-buffer.tcl | 2 +- tests/integration/replication.tcl | 22 +-- tests/integration/shutdown.tcl | 10 +- tests/test_helper.tcl | 2 +- tests/unit/acl.tcl | 36 ++--- tests/unit/client-eviction.tcl | 6 +- tests/unit/cluster/cli.tcl | 4 +- tests/unit/cluster/links.tcl | 4 +- tests/unit/dump.tcl | 2 +- tests/unit/functions.tcl | 6 +- tests/unit/info.tcl | 8 +- tests/unit/introspection.tcl | 34 ++--- tests/unit/limits.tcl | 2 +- tests/unit/maxmemory.tcl | 12 +- tests/unit/memefficiency.tcl | 14 +- tests/unit/moduleapi/async_rm_call.tcl | 40 +++--- tests/unit/moduleapi/blockedclient.tcl | 6 +- tests/unit/moduleapi/blockonbackground.tcl | 2 +- tests/unit/moduleapi/blockonkeys.tcl | 52 ++++---- tests/unit/moduleapi/cluster.tcl | 10 +- tests/unit/moduleapi/commandfilter.tcl | 2 +- tests/unit/moduleapi/datatype.tcl | 2 +- tests/unit/moduleapi/hooks.tcl | 4 +- tests/unit/moduleapi/keyspace_events.tcl | 2 +- tests/unit/moduleapi/moduleauth.tcl | 12 +- tests/unit/moduleapi/publish.tcl | 4 +- tests/unit/moduleapi/rdbloadsave.tcl | 2 +- tests/unit/moduleapi/stream.tcl | 4 +- tests/unit/moduleapi/test_lazyfree.tcl | 2 +- tests/unit/multi.tcl | 12 +- tests/unit/obuf-limits.tcl | 10 +- tests/unit/other.tcl | 2 +- tests/unit/pause.tcl | 26 ++-- tests/unit/protocol.tcl | 2 +- tests/unit/pubsub.tcl | 60 ++++----- tests/unit/pubsubshard.tcl | 26 ++-- tests/unit/scripting.tcl | 20 +-- tests/unit/shutdown.tcl | 2 +- tests/unit/slowlog.tcl | 4 +- tests/unit/tracking.tcl | 14 +- tests/unit/type/list.tcl | 126 +++++++++--------- tests/unit/type/stream-cgroups.tcl | 46 +++---- tests/unit/type/stream.tcl | 20 +-- tests/unit/type/zset.tcl | 38 +++--- tests/unit/wait.tcl | 22 +-- 56 files changed, 398 insertions(+), 398 deletions(-) diff --git a/src/logreqres.c b/src/logreqres.c index 6e7621d35d..bd19483e48 100644 --- a/src/logreqres.c +++ b/src/logreqres.c @@ -143,7 +143,7 @@ void reqresReset(client *c, int free_buf) { * Ideally, we would just have this code inside reqresAppendRequest, which is called * from processCommand, but we cannot save the reply offset inside processCommand * because of the following pipe-lining scenario: - * set rd [redis_deferring_client] + * set rd [valkey_deferring_client] * set buf "" * append buf "SET key vale\r\n" * append buf "BLPOP mylist 0\r\n" diff --git a/tests/cluster/tests/16-transactions-on-replica.tcl b/tests/cluster/tests/16-transactions-on-replica.tcl index 8bec06ee4a..b16569e104 100644 --- a/tests/cluster/tests/16-transactions-on-replica.tcl +++ b/tests/cluster/tests/16-transactions-on-replica.tcl @@ -58,7 +58,7 @@ test "MULTI-EXEC with write operations is MOVED" { } test "read-only blocking operations from replica" { - set rd [redis_deferring_client redis 1] + set rd [valkey_deferring_client redis 1] $rd readonly $rd read $rd XREAD BLOCK 0 STREAMS k 0 diff --git a/tests/cluster/tests/17-diskless-load-swapdb.tcl b/tests/cluster/tests/17-diskless-load-swapdb.tcl index 7a56ec783b..eae95d3b07 100644 --- a/tests/cluster/tests/17-diskless-load-swapdb.tcl +++ b/tests/cluster/tests/17-diskless-load-swapdb.tcl @@ -51,7 +51,7 @@ test "Main db not affected when fail to diskless load" { # backlog size is very small, and dumping rdb will cost several seconds. set num 10000 set value [string repeat A 1024] - set rd [redis_deferring_client redis $master_id] + set rd [valkey_deferring_client redis $master_id] for {set j 0} {$j < $num} {incr j} { $rd set $j $value } diff --git a/tests/cluster/tests/25-pubsubshard-slot-migration.tcl b/tests/cluster/tests/25-pubsubshard-slot-migration.tcl index fd774a8d7b..4f8373b54d 100644 --- a/tests/cluster/tests/25-pubsubshard-slot-migration.tcl +++ b/tests/cluster/tests/25-pubsubshard-slot-migration.tcl @@ -30,7 +30,7 @@ test "Migrate a slot, verify client receives sunsubscribe on primary serving the array set nodefrom [$cluster masternode_for_slot $slot] array set nodeto [$cluster masternode_notfor_slot $slot] - set subscribeclient [redis_deferring_client_by_addr $nodefrom(host) $nodefrom(port)] + set subscribeclient [valkey_deferring_client_by_addr $nodefrom(host) $nodefrom(port)] $subscribeclient deferred 1 $subscribeclient ssubscribe $channelname @@ -64,7 +64,7 @@ test "Client subscribes to multiple channels, migrate a slot, verify client rece array set nodefrom [$cluster masternode_for_slot $slot] array set nodeto [$cluster masternode_notfor_slot $slot] - set subscribeclient [redis_deferring_client_by_addr $nodefrom(host) $nodefrom(port)] + set subscribeclient [valkey_deferring_client_by_addr $nodefrom(host) $nodefrom(port)] $subscribeclient deferred 1 $subscribeclient ssubscribe $channelname @@ -113,7 +113,7 @@ test "Migrate a slot, verify client receives sunsubscribe on replica serving the set replica_addr [get_addr_replica_serving_slot $slot] set replicahost [lindex $replica_addr 0] set replicaport [lindex $replica_addr 1] - set subscribeclient [redis_deferring_client_by_addr $replicahost $replicaport] + set subscribeclient [valkey_deferring_client_by_addr $replicahost $replicaport] $subscribeclient deferred 1 $subscribeclient ssubscribe $channelname @@ -148,7 +148,7 @@ test "Move a replica to another primary, verify client receives sunsubscribe on set replica_host [lindex $replica_addr 0] set replica_port [lindex $replica_addr 1] set replica_client [redis_client_by_addr $replica_host $replica_port] - set subscribeclient [redis_deferring_client_by_addr $replica_host $replica_port] + set subscribeclient [valkey_deferring_client_by_addr $replica_host $replica_port] $subscribeclient deferred 1 $subscribeclient ssubscribe $channelname @@ -174,7 +174,7 @@ test "Delete a slot, verify sunsubscribe message" { array set primary_client [$cluster masternode_for_slot $slot] - set subscribeclient [redis_deferring_client_by_addr $primary_client(host) $primary_client(port)] + set subscribeclient [valkey_deferring_client_by_addr $primary_client(host) $primary_client(port)] $subscribeclient deferred 1 $subscribeclient ssubscribe $channelname $subscribeclient read @@ -195,7 +195,7 @@ test "Reset cluster, verify sunsubscribe message" { array set primary_client [$cluster masternode_for_slot $slot] - set subscribeclient [redis_deferring_client_by_addr $primary_client(host) $primary_client(port)] + set subscribeclient [valkey_deferring_client_by_addr $primary_client(host) $primary_client(port)] $subscribeclient deferred 1 $subscribeclient ssubscribe $channelname $subscribeclient read diff --git a/tests/cluster/tests/26-pubsubshard.tcl b/tests/cluster/tests/26-pubsubshard.tcl index 34939acf7c..422c06bf5d 100644 --- a/tests/cluster/tests/26-pubsubshard.tcl +++ b/tests/cluster/tests/26-pubsubshard.tcl @@ -14,9 +14,9 @@ test "Pub/Sub shard basics" { array set notshardnode [$cluster masternode_notfor_slot $slot] set publishclient [redis_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeclient [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeclient2 [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set anotherclient [redis_deferring_client_by_addr $notshardnode(host) $notshardnode(port)] + set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeclient2 [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set anotherclient [valkey_deferring_client_by_addr $notshardnode(host) $notshardnode(port)] $subscribeclient ssubscribe channel.0 $subscribeclient read @@ -58,7 +58,7 @@ test "client can subscribe to multiple shard channels across different slots in test "sunsubscribe without specifying any channel would unsubscribe all shard channels subscribed" { set publishclient [redis_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeclient [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set sub_res [ssubscribe $subscribeclient [list "\{channel.0\}1" "\{channel.0\}2" "\{channel.0\}3"]] assert_equal [list 1 2 3] $sub_res @@ -78,9 +78,9 @@ test "Verify Pub/Sub and Pub/Sub shard no overlap" { array set notshardnode [$cluster masternode_notfor_slot $slot] set publishshardclient [redis_client_by_addr $publishnode(host) $publishnode(port)] - set publishclient [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeshardclient [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeclient [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set publishclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeshardclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] $subscribeshardclient deferred 1 $subscribeshardclient ssubscribe channel.0 @@ -109,9 +109,9 @@ test "Verify Pub/Sub and Pub/Sub shard no overlap" { } test "PUBSUB channels/shardchannels" { - set subscribeclient [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeclient2 [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set subscribeclient3 [redis_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeclient2 [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] + set subscribeclient3 [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set publishclient [redis_client_by_addr $publishnode(host) $publishnode(port)] ssubscribe $subscribeclient [list "\{channel.0\}1"] diff --git a/tests/instances.tcl b/tests/instances.tcl index 6b8efe4486..74e5491696 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -717,14 +717,14 @@ proc restart_instance {type id} { } } -proc redis_deferring_client {type id} { +proc valkey_deferring_client {type id} { set port [get_instance_attrib $type $id port] set host [get_instance_attrib $type $id host] set client [redis $host $port 1 $::tls] return $client } -proc redis_deferring_client_by_addr {host port} { +proc valkey_deferring_client_by_addr {host port} { set client [redis $host $port 1 $::tls] return $client } diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 5c24e71608..7218419c12 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -210,7 +210,7 @@ tags {"aof external:skip"} { start_server {overrides {appendonly {yes} appendfsync always}} { test {AOF fsync always barrier issue} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Set a sleep when aof is flushed, so that we have a chance to look # at the aof size and detect if the response of an incr command # arrives before the data was written (and hopefully fsynced) @@ -438,7 +438,7 @@ tags {"aof external:skip"} { append_to_aof [formatCommand select 9] append_to_aof [formatCommand eval {redis.call('set',KEYS[1],'y'); for i=1,1500000 do redis.call('ping') end return 'ok'} 1 x] } - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd debug loadaof $rd flush wait_for_condition 100 10 { diff --git a/tests/integration/corrupt-dump-fuzzer.tcl b/tests/integration/corrupt-dump-fuzzer.tcl index 0ed30ee5e7..65f5c673dc 100644 --- a/tests/integration/corrupt-dump-fuzzer.tcl +++ b/tests/integration/corrupt-dump-fuzzer.tcl @@ -14,7 +14,7 @@ if { ! [ catch { } proc generate_collections {suffix elements} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] for {set j 0} {$j < $elements} {incr j} { # add both string values and integers if {$j % 2 == 0} {set val $j} else {set val "_$j"} diff --git a/tests/integration/dismiss-mem.tcl b/tests/integration/dismiss-mem.tcl index 87f6e1dfc9..6860e52f61 100644 --- a/tests/integration/dismiss-mem.tcl +++ b/tests/integration/dismiss-mem.tcl @@ -61,7 +61,7 @@ start_server {tags {"dismiss external:skip"}} { for {set i 0} {$i < 100} {incr i} { r lpush mylist $item } - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd lrange mylist 0 -1 $rd flush after 100 @@ -74,7 +74,7 @@ start_server {tags {"dismiss external:skip"}} { test {dismiss client query buffer} { # Big pending query buffer set bigstr [string repeat A 8192] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd write "*2\r\n\$8192\r\n" $rd write $bigstr\r\n $rd flush diff --git a/tests/integration/failover.tcl b/tests/integration/failover.tcl index 21fa3d2815..70bb66284d 100644 --- a/tests/integration/failover.tcl +++ b/tests/integration/failover.tcl @@ -256,7 +256,7 @@ start_server {overrides {save {}}} { # We pause the target long enough to send a write command # during the pause. This write will not be interrupted. pause_process [srv -1 pid] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SET FOO BAR $node_0 failover to $node_1_host $node_1_port resume_process [srv -1 pid] diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index f70900c1a4..e3f92bf521 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -187,7 +187,7 @@ test {client freed during loading} { # connect and disconnect 5 clients set clients {} for {set j 0} {$j < 5} {incr j} { - lappend clients [redis_deferring_client] + lappend clients [valkey_deferring_client] } foreach rd $clients { $rd debug log bla @@ -262,7 +262,7 @@ start_server {overrides {save ""}} { # populate the db with 10k keys of 512B each (since we want to measure the COW size by # changing some keys and read the reported COW size, we are using small key size to prevent from # the "dismiss mechanism" free memory and reduce the COW size) - set rd [redis_deferring_client 0] + set rd [valkey_deferring_client 0] set size 500 ;# aim for the 512 bin (sds overhead) set cmd_count 10000 for {set k 0} {$k < $cmd_count} {incr k} { diff --git a/tests/integration/replication-buffer.tcl b/tests/integration/replication-buffer.tcl index 64b26ca021..c57b86897b 100644 --- a/tests/integration/replication-buffer.tcl +++ b/tests/integration/replication-buffer.tcl @@ -294,7 +294,7 @@ test {Replica client-output-buffer size is limited to backlog_limit/16 when no r # Before this fix (#11905), the test would trigger an assertion in 'o->used >= c->ref_block_pos' test {The update of replBufBlock's repl_offset is ok - Regression test for #11666} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set replid [status $master master_replid] set offset [status $master repl_backlog_first_byte_offset] $rd psync $replid $offset diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index de4d527f4e..2118a8acdb 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -108,7 +108,7 @@ start_server {tags {"repl external:skip"}} { test {BRPOPLPUSH replication, when blocking against empty list} { $A config resetstat - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd brpoplpush a b 5 r lpush a foo wait_for_condition 50 100 { @@ -122,7 +122,7 @@ start_server {tags {"repl external:skip"}} { test {BRPOPLPUSH replication, list exists} { $A config resetstat - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r lpush c 1 r lpush c 2 r lpush c 3 @@ -137,7 +137,7 @@ start_server {tags {"repl external:skip"}} { foreach whereto {left right} { test "BLMOVE ($wherefrom, $whereto) replication, when blocking against empty list" { $A config resetstat - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blmove a b $wherefrom $whereto 5 r lpush a foo wait_for_condition 50 100 { @@ -151,7 +151,7 @@ start_server {tags {"repl external:skip"}} { test "BLMOVE ($wherefrom, $whereto) replication, list exists" { $A config resetstat - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r lpush c 1 r lpush c 2 r lpush c 3 @@ -165,7 +165,7 @@ start_server {tags {"repl external:skip"}} { } test {BLPOP followed by role change, issue #2473} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blpop foo 0 ; # Block while B is a master # Turn B into master of A @@ -637,7 +637,7 @@ foreach testType {Successful Aborted} { } test {Busy script during async loading} { - set rd_replica [redis_deferring_client -1] + set rd_replica [valkey_deferring_client -1] $replica config set lua-time-limit 10 $rd_replica eval {while true do end} 0 after 200 @@ -1146,7 +1146,7 @@ test {replicaof right after disconnection} { fail "Can't turn the instance into a replica" } - set rd [redis_deferring_client -1] + set rd [valkey_deferring_client -1] $rd debug sleep 1 after 100 @@ -1344,7 +1344,7 @@ test {replica can handle EINTR if use diskless load} { start_server {tags {"repl" "external:skip"}} { test "replica do not write the reply to the replication link - SYNC (_addReplyToBufferOrList)" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set lines [count_log_lines 0] $rd sync @@ -1361,7 +1361,7 @@ start_server {tags {"repl" "external:skip"}} { } test "replica do not write the reply to the replication link - SYNC (addReplyDeferredLen)" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set lines [count_log_lines 0] $rd sync @@ -1378,7 +1378,7 @@ start_server {tags {"repl" "external:skip"}} { } test "replica do not write the reply to the replication link - PSYNC (_addReplyToBufferOrList)" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set lines [count_log_lines 0] $rd psync replicationid -1 @@ -1398,7 +1398,7 @@ start_server {tags {"repl" "external:skip"}} { } test "replica do not write the reply to the replication link - PSYNC (addReplyDeferredLen)" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set lines [count_log_lines 0] $rd psync replicationid -1 diff --git a/tests/integration/shutdown.tcl b/tests/integration/shutdown.tcl index b2ec32cbd1..b2fdb845a3 100644 --- a/tests/integration/shutdown.tcl +++ b/tests/integration/shutdown.tcl @@ -56,7 +56,7 @@ foreach how {sigterm shutdown} { exec kill -SIGTERM $master_pid } shutdown { - set rd [redis_deferring_client -1] + set rd [valkey_deferring_client -1] $rd shutdown } } @@ -152,8 +152,8 @@ test "Shutting down master waits for replica then fails" { $master incr k # Two clients call blocking SHUTDOWN in parallel. - set rd1 [redis_deferring_client -1] - set rd2 [redis_deferring_client -1] + set rd1 [valkey_deferring_client -1] + set rd2 [valkey_deferring_client -1] $rd1 shutdown $rd2 shutdown set info_clients [$master info clients] @@ -205,8 +205,8 @@ test "Shutting down master waits for replica then aborted" { $master incr k # Two clients call blocking SHUTDOWN in parallel. - set rd1 [redis_deferring_client -1] - set rd2 [redis_deferring_client -1] + set rd1 [valkey_deferring_client -1] + set rd2 [valkey_deferring_client -1] $rd1 shutdown $rd2 shutdown set info_clients [$master info clients] diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index a6a2b658b5..340fbd65e0 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -256,7 +256,7 @@ proc reconnect {args} { lset ::servers end+$level $srv } -proc redis_deferring_client {args} { +proc valkey_deferring_client {args} { set level 0 if {[llength $args] > 0 && [string is integer [lindex $args 0]]} { set level [lindex $args 0] diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index b69b1f40b2..2edac213e5 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -108,7 +108,7 @@ start_server {tags {"acl external:skip"}} { } {*NOPERM*channel*} test {By default, only default user is able to subscribe to any channel} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd AUTH default pwd $rd read $rd SUBSCRIBE foo @@ -124,7 +124,7 @@ start_server {tags {"acl external:skip"}} { } {*NOPERM*channel*} test {By default, only default user is able to subscribe to any shard channel} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd AUTH default pwd $rd read $rd SSUBSCRIBE foo @@ -140,7 +140,7 @@ start_server {tags {"acl external:skip"}} { } {*NOPERM*channel*} test {By default, only default user is able to subscribe to any pattern} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd AUTH default pwd $rd read $rd PSUBSCRIBE bar* @@ -209,7 +209,7 @@ start_server {tags {"acl external:skip"}} { } test {It's possible to allow subscribing to a subset of channels} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd AUTH psuser pspass $rd read $rd SUBSCRIBE foo:1 @@ -222,7 +222,7 @@ start_server {tags {"acl external:skip"}} { } {*NOPERM*channel*} test {It's possible to allow subscribing to a subset of shard channels} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd AUTH psuser pspass $rd read $rd SSUBSCRIBE foo:1 @@ -235,7 +235,7 @@ start_server {tags {"acl external:skip"}} { } {*NOPERM*channel*} test {It's possible to allow subscribing to a subset of channel patterns} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd AUTH psuser pspass $rd read $rd PSUBSCRIBE foo:1 @@ -248,7 +248,7 @@ start_server {tags {"acl external:skip"}} { } {*NOPERM*channel*} test {Subscribers are killed when revoked of channel permission} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r ACL setuser psuser resetchannels &foo:1 $rd AUTH psuser pspass $rd read @@ -262,7 +262,7 @@ start_server {tags {"acl external:skip"}} { } {0} test {Subscribers are killed when revoked of channel permission} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r ACL setuser psuser resetchannels &foo:1 $rd AUTH psuser pspass $rd read @@ -276,7 +276,7 @@ start_server {tags {"acl external:skip"}} { } {0} test {Subscribers are killed when revoked of pattern permission} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r ACL setuser psuser resetchannels &bar:* $rd AUTH psuser pspass $rd read @@ -290,7 +290,7 @@ start_server {tags {"acl external:skip"}} { } {0} test {Subscribers are killed when revoked of allchannels permission} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r ACL setuser psuser allchannels $rd AUTH psuser pspass $rd read @@ -304,7 +304,7 @@ start_server {tags {"acl external:skip"}} { } {0} test {Subscribers are pardoned if literal permissions are retained and/or gaining allchannels} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r ACL setuser psuser resetchannels &foo:1 &bar:* &orders $rd AUTH psuser pspass $rd read @@ -326,7 +326,7 @@ start_server {tags {"acl external:skip"}} { test {blocked command gets rejected when reprocessed after permission change} { r auth default "" r config resetstat - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r ACL setuser psuser reset on nopass +@all allkeys $rd AUTH psuser pspass $rd read @@ -754,7 +754,7 @@ start_server {tags {"acl external:skip"}} { } test {ACL LOG can distinguish the transaction context (2)} { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] r ACL SETUSER antirez +incr r AUTH antirez foo @@ -830,7 +830,7 @@ start_server {tags {"acl external:skip"}} { test {When default user is off, new connections are not authenticated} { r ACL setuser default off - catch {set rd1 [redis_deferring_client]} e + catch {set rd1 [valkey_deferring_client]} e r ACL setuser default on set e } {*NOAUTH*} @@ -1024,8 +1024,8 @@ start_server [list overrides [list "dir" $server_path "acl-pubsub-default" "allc reconnect r ACL SETUSER doug on nopass resetchannels &test* +@all ~* - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd1 AUTH alice alice $rd1 read @@ -1055,8 +1055,8 @@ start_server [list overrides [list "dir" $server_path "acl-pubsub-default" "allc reconnect r ACL SETUSER mortimer on >mortimer ~* &* +@all - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd1 AUTH alice alice $rd1 read diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index 2484a4d136..d40dc88c3f 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -257,7 +257,7 @@ start_server {} { test "client evicted due to output buf" { r flushdb r setrange k 200000 v - set rr [redis_deferring_client] + set rr [valkey_deferring_client] $rr client setname test_client $rr flush assert {[$rr read] == "OK"} @@ -325,10 +325,10 @@ start_server {} { r setrange k $obuf_size v set rr1 [redis_client] $rr1 client setname "qbuf-client" - set rr2 [redis_deferring_client] + set rr2 [valkey_deferring_client] $rr2 client setname "obuf-client1" assert_equal [$rr2 read] OK - set rr3 [redis_deferring_client] + set rr3 [valkey_deferring_client] $rr3 client setname "obuf-client2" assert_equal [$rr3 read] OK diff --git a/tests/unit/cluster/cli.tcl b/tests/unit/cluster/cli.tcl index b5d9e81de3..948edc585d 100644 --- a/tests/unit/cluster/cli.tcl +++ b/tests/unit/cluster/cli.tcl @@ -17,7 +17,7 @@ start_multiple_servers 3 [list overrides $base_conf] { set node2 [srv -1 client] set node3 [srv -2 client] set node3_pid [srv -2 pid] - set node3_rd [redis_deferring_client -2] + set node3_rd [valkey_deferring_client -2] test {Create 3 node cluster} { exec src/valkey-cli --cluster-yes --cluster create \ @@ -79,7 +79,7 @@ start_multiple_servers 3 [list overrides $base_conf] { } } - set node1_rd [redis_deferring_client 0] + set node1_rd [valkey_deferring_client 0] test "use previous hostip in \"cluster-preferred-endpoint-type unknown-endpoint\" mode" { diff --git a/tests/unit/cluster/links.tcl b/tests/unit/cluster/links.tcl index 4092d99833..1f840fd960 100644 --- a/tests/unit/cluster/links.tcl +++ b/tests/unit/cluster/links.tcl @@ -80,13 +80,13 @@ start_cluster 1 2 {tags {external:skip cluster}} { set channelname ch3 # subscribe on replica1 - set subscribeclient1 [redis_deferring_client -1] + set subscribeclient1 [valkey_deferring_client -1] $subscribeclient1 deferred 1 $subscribeclient1 SSUBSCRIBE $channelname $subscribeclient1 read # subscribe on replica2 - set subscribeclient2 [redis_deferring_client -2] + set subscribeclient2 [valkey_deferring_client -2] $subscribeclient2 deferred 1 $subscribeclient2 SSUBSCRIBE $channelname $subscribeclient2 read diff --git a/tests/unit/dump.tcl b/tests/unit/dump.tcl index dd75952903..9018270d67 100644 --- a/tests/unit/dump.tcl +++ b/tests/unit/dump.tcl @@ -285,7 +285,7 @@ start_server {tags {"dump"}} { assert {[$first exists key] == 1} assert {[$second exists key] == 0} - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd debug sleep 1.0 ; # Make second server unable to reply. set e {} catch {r -1 migrate $second_host $second_port key 9 500} e diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 58ac0c8888..4415b60e57 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -235,7 +235,7 @@ start_server {tags {"scripting"}} { } {x} test {FUNCTION - test function kill} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set busy-reply-threshold 10 r function load REPLACE [get_function_code lua test test {local a = 1 while true do a = a + 1 end}] $rd fcall test 0 @@ -249,7 +249,7 @@ start_server {tags {"scripting"}} { } test {FUNCTION - test script kill not working on function} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set busy-reply-threshold 10 r function load REPLACE [get_function_code lua test test {local a = 1 while true do a = a + 1 end}] $rd fcall test 0 @@ -264,7 +264,7 @@ start_server {tags {"scripting"}} { } test {FUNCTION - test function kill not working on eval} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set busy-reply-threshold 10 $rd eval {local a = 1 while true do a = a + 1 end} 0 after 200 diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index 6e2d381f57..b62ca86d77 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -60,7 +60,7 @@ start_server {tags {"info" "external:skip"}} { r config resetstat r CONFIG SET latency-tracking yes r CONFIG SET latency-tracking-info-percentiles "50.0 99.0 99.9" - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del list1{t} $rd blpop list1{t} 0 @@ -259,7 +259,7 @@ start_server {tags {"info" "external:skip"}} { test {errorstats: blocking commands} { r config resetstat - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set rd_id [$rd read] r del list1{t} @@ -394,8 +394,8 @@ start_server {tags {"info" "external:skip"}} { test {clients: pubsub clients} { set info [r info clients] assert_equal [getInfoProperty $info pubsub_clients] {0} - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] # basic count assert_equal {1} [ssubscribe $rd1 {chan1}] assert_equal {1} [subscribe $rd2 {chan2}] diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index f6c78ea75e..9ec8bb07b4 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -44,9 +44,9 @@ start_server {tags {"introspection"}} { # 3 retries of increasing sleep_time, i.e. start with 2s, then go 4s, 8s. set sleep_time 2 for {set i 0} {$i < 3} {incr i} { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] r debug sleep $sleep_time - set rd2 [redis_deferring_client] + set rd2 [valkey_deferring_client] r acl setuser dummy on nopass +ping $rd1 auth dummy "" $rd1 read @@ -80,16 +80,16 @@ start_server {tags {"introspection"}} { test {CLIENT KILL SKIPME YES/NO will kill all clients} { # Kill all clients except `me` - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] set connected_clients [s connected_clients] assert {$connected_clients >= 3} set res [r client kill skipme yes] assert {$res == $connected_clients - 1} # Kill all clients, including `me` - set rd3 [redis_deferring_client] - set rd4 [redis_deferring_client] + set rd3 [valkey_deferring_client] + set rd4 [valkey_deferring_client] set connected_clients [s connected_clients] assert {$connected_clients == 3} set res [r client kill skipme no] @@ -162,7 +162,7 @@ start_server {tags {"introspection"}} { } {} {needs:save} test "CLIENT REPLY OFF/ON: disable all commands reply" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # These replies were silenced. $rd client reply off @@ -178,7 +178,7 @@ start_server {tags {"introspection"}} { } test "CLIENT REPLY SKIP: skip the next command reply" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # The first pong reply was silenced. $rd client reply skip @@ -191,7 +191,7 @@ start_server {tags {"introspection"}} { } test "CLIENT REPLY ON: unset SKIP flag" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client reply skip $rd client reply on @@ -204,7 +204,7 @@ start_server {tags {"introspection"}} { } test {MONITOR can log executed commands} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd monitor assert_match {*OK*} [$rd read] r set foo bar @@ -215,7 +215,7 @@ start_server {tags {"introspection"}} { } {*"set" "foo"*"get" "foo"*} test {MONITOR can log commands issued by the scripting engine} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd monitor $rd read ;# Discard the OK r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar @@ -228,7 +228,7 @@ start_server {tags {"introspection"}} { r function load replace {#!lua name=test redis.register_function('test', function() return redis.call('set', 'foo', 'bar') end) } - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd monitor $rd read ;# Discard the OK r fcall test 0 @@ -238,7 +238,7 @@ start_server {tags {"introspection"}} { } test {MONITOR supports redacting command arguments} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd monitor $rd read ; # Discard the OK @@ -267,7 +267,7 @@ start_server {tags {"introspection"}} { } {0} {needs:repl} test {MONITOR correctly handles multi-exec cases} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd monitor $rd read ; # Discard the OK @@ -296,8 +296,8 @@ start_server {tags {"introspection"}} { # need to reconnect in order to reset the clients state reconnect - set rd [redis_deferring_client] - set bc [redis_deferring_client] + set rd [valkey_deferring_client] + set bc [valkey_deferring_client] r del mylist $rd monitor @@ -363,7 +363,7 @@ start_server {tags {"introspection"}} { } {*name=someothername*} test {After CLIENT SETNAME, connection can still be closed} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client setname foobar assert_equal [$rd read] "OK" assert_match {*foobar*} [r client list] diff --git a/tests/unit/limits.tcl b/tests/unit/limits.tcl index 3af151981e..a593eac7b9 100644 --- a/tests/unit/limits.tcl +++ b/tests/unit/limits.tcl @@ -9,7 +9,7 @@ start_server {tags {"limits network external:skip"} overrides {maxclients 10}} { catch { while {$c < 50} { incr c - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd ping $rd read after 100 diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl index bbf43c2f14..109707d1c6 100644 --- a/tests/unit/maxmemory.tcl +++ b/tests/unit/maxmemory.tcl @@ -56,7 +56,7 @@ start_server {tags {"maxmemory" "external:skip"}} { init_test $client_eviction for {set j 0} {$j < 20} {incr j} { - set rr [redis_deferring_client] + set rr [valkey_deferring_client] lappend clients $rr } @@ -85,7 +85,7 @@ start_server {tags {"maxmemory" "external:skip"}} { init_test $client_eviction for {set j 0} {$j < 30} {incr j} { - set rr [redis_deferring_client] + set rr [valkey_deferring_client] lappend clients $rr } @@ -349,12 +349,12 @@ proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} } # put the slave to sleep - set rd_slave [redis_deferring_client] + set rd_slave [valkey_deferring_client] pause_process $slave_pid # send some 10mb worth of commands that don't increase the memory usage if {$pipeline == 1} { - set rd_master [redis_deferring_client -1] + set rd_master [valkey_deferring_client -1] for {set k 0} {$k < $cmd_count} {incr k} { $rd_master setrange key:0 0 [string repeat A $payload_len] } @@ -406,7 +406,7 @@ proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} # test that slave buffer are counted correctly # we wanna use many small commands, and we don't wanna wait long -# so we need to use a pipeline (redis_deferring_client) +# so we need to use a pipeline (valkey_deferring_client) # that may cause query buffer to fill and induce eviction, so we disable it test_slave_buffers {slave buffer are counted correctly} 1000000 10 0 1 @@ -450,7 +450,7 @@ start_server {tags {"maxmemory external:skip"}} { # 10 clients listening on tracking messages set clients {} for {set j 0} {$j < 10} {incr j} { - lappend clients [redis_deferring_client] + lappend clients [valkey_deferring_client] } foreach rd $clients { $rd HELLO 3 diff --git a/tests/unit/memefficiency.tcl b/tests/unit/memefficiency.tcl index e6ae34e7df..525db407bf 100644 --- a/tests/unit/memefficiency.tcl +++ b/tests/unit/memefficiency.tcl @@ -1,6 +1,6 @@ proc test_memory_efficiency {range} { r flushall - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set base_mem [s used_memory] set written 0 for {set j 0} {$j < 10000} {incr j} { @@ -193,7 +193,7 @@ run_solo {defrag} { # Populate memory with interleaving script-key pattern of same size set dummy_script "--[string repeat x 400]\nreturn " - set rd [redis_deferring_client] + set rd [valkey_deferring_client] for {set j 0} {$j < $n} {incr j} { set val "$dummy_script[format "%06d" $j]" $rd script load $val @@ -286,7 +286,7 @@ run_solo {defrag} { r xreadgroup GROUP mygroup Alice COUNT 1 STREAMS stream > # create big keys with 10k items - set rd [redis_deferring_client] + set rd [valkey_deferring_client] for {set j 0} {$j < 10000} {incr j} { $rd hset bighash $j [concat "asdfasdfasdf" $j] $rd lpush biglist [concat "asdfasdfasdf" $j] @@ -418,8 +418,8 @@ run_solo {defrag} { # Populate memory with interleaving pubsub-key pattern of same size set n 50000 set dummy_channel "[string repeat x 400]" - set rd [redis_deferring_client] - set rd_pubsub [redis_deferring_client] + set rd [valkey_deferring_client] + set rd_pubsub [valkey_deferring_client] for {set j 0} {$j < $n} {incr j} { set channel_name "$dummy_channel[format "%06d" $j]" $rd_pubsub subscribe $channel_name @@ -518,7 +518,7 @@ run_solo {defrag} { r config set list-max-ziplist-size 5 ;# list of 500k items will have 100k quicklist nodes # create big keys with 10k items - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set expected_frag 1.7 # add a mass of list nodes to two lists (allocations are interlaced) @@ -637,7 +637,7 @@ run_solo {defrag} { } # add a mass of keys with 600 bytes values, fill the bin of 640 bytes which has 32 regs per slab. - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set keys 640000 for {set j 0} {$j < $keys} {incr j} { $rd setrange $j 600 x diff --git a/tests/unit/moduleapi/async_rm_call.tcl b/tests/unit/moduleapi/async_rm_call.tcl index d03cfc25c0..e88e8cf356 100644 --- a/tests/unit/moduleapi/async_rm_call.tcl +++ b/tests/unit/moduleapi/async_rm_call.tcl @@ -16,7 +16,7 @@ start_server {tags {"modules"}} { } test "Blpop on threaded async RM_Call" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd do_rm_call_async_on_thread blpop l 0 wait_for_blocked_clients_count 1 @@ -29,7 +29,7 @@ start_server {tags {"modules"}} { foreach cmd {do_rm_call_async do_rm_call_async_script_mode } { test "Blpop on async RM_Call using $cmd" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd $cmd blpop l 0 wait_for_blocked_clients_count 1 @@ -40,7 +40,7 @@ start_server {tags {"modules"}} { } test "Brpop on async RM_Call using $cmd" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd $cmd brpop l 0 wait_for_blocked_clients_count 1 @@ -51,7 +51,7 @@ start_server {tags {"modules"}} { } test "Brpoplpush on async RM_Call using $cmd" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd $cmd brpoplpush l1 l2 0 wait_for_blocked_clients_count 1 @@ -63,7 +63,7 @@ start_server {tags {"modules"}} { } {a} test "Blmove on async RM_Call using $cmd" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd $cmd blmove l1 l2 LEFT LEFT 0 wait_for_blocked_clients_count 1 @@ -75,7 +75,7 @@ start_server {tags {"modules"}} { } {a} test "Bzpopmin on async RM_Call using $cmd" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd $cmd bzpopmin s 0 wait_for_blocked_clients_count 1 @@ -86,7 +86,7 @@ start_server {tags {"modules"}} { } test "Bzpopmax on async RM_Call using $cmd" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd $cmd bzpopmax s 0 wait_for_blocked_clients_count 1 @@ -98,7 +98,7 @@ start_server {tags {"modules"}} { } test {Nested async RM_Call} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd do_rm_call_async do_rm_call_async do_rm_call_async do_rm_call_async blpop l 0 wait_for_blocked_clients_count 1 @@ -109,8 +109,8 @@ start_server {tags {"modules"}} { } test {Test multiple async RM_Call waiting on the same event} { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd1 do_rm_call_async do_rm_call_async do_rm_call_async do_rm_call_async blpop l 0 $rd2 do_rm_call_async do_rm_call_async do_rm_call_async do_rm_call_async blpop l 0 @@ -136,7 +136,7 @@ start_server {tags {"modules"}} { } test {async RM_Call inside async RM_Call callback} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd wait_and_do_rm_call blpop l 0 wait_for_blocked_clients_count 1 @@ -161,7 +161,7 @@ start_server {tags {"modules"}} { test {Become replica while having async RM_Call running} { r flushall - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd do_rm_call_async blpop l 0 wait_for_blocked_clients_count 1 @@ -182,7 +182,7 @@ start_server {tags {"modules"}} { test {Pipeline with blocking RM_Call} { r flushall - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set buf "" append buf "do_rm_call_async blpop l 0\r\n" append buf "ping\r\n" @@ -202,7 +202,7 @@ start_server {tags {"modules"}} { test {blocking RM_Call abort} { r flushall - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set client_id [$rd read] @@ -229,7 +229,7 @@ start_server {tags {"modules"}} { r flushall set repl [attach_to_replication_stream] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd do_rm_call_async blpop l 0 wait_for_blocked_clients_count 1 @@ -251,7 +251,7 @@ start_server {tags {"modules"}} { r flushall set repl [attach_to_replication_stream] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blpop_and_set_multiple_keys l x 1 y 2 wait_for_blocked_clients_count 1 @@ -277,7 +277,7 @@ start_server {tags {"modules"}} { r flushall set repl [attach_to_replication_stream] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd do_rm_call_async_no_replicate blpop l 0 wait_for_blocked_clients_count 1 @@ -307,7 +307,7 @@ start_server {tags {"modules"}} { r flushall set repl [attach_to_replication_stream] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blpop_and_set_multiple_keys l string_foo 1 string_bar 2 wait_for_blocked_clients_count 1 @@ -346,7 +346,7 @@ start_server {tags {"modules"}} { r DEBUG SET-ACTIVE-EXPIRE 0 set repl [attach_to_replication_stream] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blpop_and_set_multiple_keys l string_foo 1 string_bar 2 wait_for_blocked_clients_count 1 @@ -421,7 +421,7 @@ start_server {tags {"modules"}} { r module load $testmodule3 test {Test unblock handler on module blocked on keys} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r fsl.push l 1 $rd do_rm_call_async FSL.BPOPGT l 3 0 diff --git a/tests/unit/moduleapi/blockedclient.tcl b/tests/unit/moduleapi/blockedclient.tcl index abefaff274..d94ef5c5ba 100644 --- a/tests/unit/moduleapi/blockedclient.tcl +++ b/tests/unit/moduleapi/blockedclient.tcl @@ -114,7 +114,7 @@ foreach call_type {nested normal} { set busy_time_limit 50 set old_time_limit [lindex [r config get busy-reply-threshold] 1] r config set busy-reply-threshold $busy_time_limit - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # run command that blocks until released set start [clock clicks -milliseconds] @@ -171,7 +171,7 @@ foreach call_type {nested normal} { # trigger slow operation r set_slow_bg_operation 1 r hset hash foo bar - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set start [clock clicks -milliseconds] $rd do_bg_rm_call hgetall hash @@ -284,7 +284,7 @@ foreach call_type {nested normal} { test {block time is shorter than timer period} { # This command does not have the reply. - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd unblock_by_timer 100 10 # Wait for the client to unlock. after 120 diff --git a/tests/unit/moduleapi/blockonbackground.tcl b/tests/unit/moduleapi/blockonbackground.tcl index fcd7f1dd44..2d0296357a 100644 --- a/tests/unit/moduleapi/blockonbackground.tcl +++ b/tests/unit/moduleapi/blockonbackground.tcl @@ -96,7 +96,7 @@ start_server {tags {"modules"}} { } test "client unblock works only for modules with timeout support" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set id [$rd read] diff --git a/tests/unit/moduleapi/blockonkeys.tcl b/tests/unit/moduleapi/blockonkeys.tcl index 66a94dcd7c..9014e930cf 100644 --- a/tests/unit/moduleapi/blockonkeys.tcl +++ b/tests/unit/moduleapi/blockonkeys.tcl @@ -4,8 +4,8 @@ start_server {tags {"modules"}} { r module load $testmodule test "Module client blocked on keys: Circular BPOPPUSH" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] r del src dst @@ -23,7 +23,7 @@ start_server {tags {"modules"}} { } test "Module client blocked on keys: Self-referential BPOPPUSH" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] r del src @@ -35,7 +35,7 @@ start_server {tags {"modules"}} { } test "Module client blocked on keys: BPOPPUSH unblocked by timer" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] r del src dst @@ -68,14 +68,14 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (no metadata): Timeout} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpop k 1 assert_equal {Request timedout} [$rd read] } test {Module client blocked on keys (no metadata): Blocked} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpop k 0 wait_for_blocked_clients_count 1 r fsl.push k 34 @@ -90,7 +90,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Timeout} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] r fsl.push k 33 @@ -101,7 +101,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, case 1} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] r fsl.push k 33 @@ -115,7 +115,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, case 2} { r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r fsl.push k 33 @@ -128,7 +128,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, DEL} { r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r del k @@ -138,7 +138,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, FLUSHALL} { r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r flushall @@ -149,7 +149,7 @@ start_server {tags {"modules"}} { r select 9 r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r swapdb 0 9 @@ -164,7 +164,7 @@ start_server {tags {"modules"}} { r select 0 r lpush k 38 r select 9 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r swapdb 0 9 @@ -180,7 +180,7 @@ start_server {tags {"modules"}} { r select 0 r fsl.push k 34 r select 9 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r swapdb 0 9 @@ -198,7 +198,7 @@ start_server {tags {"modules"}} { r select 0 r fsl.push k 38 r select 9 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpopgt k 35 0 wait_for_blocked_clients_count 1 r swapdb 0 9 @@ -209,7 +209,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, CLIENT KILL} { r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] $rd fsl.bpopgt k 35 0 @@ -220,7 +220,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, CLIENT UNBLOCK TIMEOUT} { r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] $rd fsl.bpopgt k 35 0 @@ -232,7 +232,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys (with metadata): Blocked, CLIENT UNBLOCK ERROR} { r del k r fsl.push k 32 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] $rd fsl.bpopgt k 35 0 @@ -243,7 +243,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys, no timeout CB, CLIENT UNBLOCK TIMEOUT} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] $rd fsl.bpop k 0 NO_TO_CB @@ -254,7 +254,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys, no timeout CB, CLIENT UNBLOCK ERROR} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] $rd fsl.bpop k 0 NO_TO_CB @@ -265,7 +265,7 @@ start_server {tags {"modules"}} { test {Module client re-blocked on keys after woke up on wrong type} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd fsl.bpop k 0 wait_for_blocked_clients_count 1 r lpush k 12 @@ -279,7 +279,7 @@ start_server {tags {"modules"}} { test {Module client blocked on keys woken up by LPUSH} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blockonkeys.popall k wait_for_blocked_clients_count 1 r lpush k 42 squirrel banana @@ -289,7 +289,7 @@ start_server {tags {"modules"}} { test {Module client unblocks BLPOP} { r del k - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blpop k 3 wait_for_blocked_clients_count 1 r blockonkeys.lpush k 42 @@ -301,7 +301,7 @@ start_server {tags {"modules"}} { r del k r lpush k aa # Module client blocks to pop 5 elements from list - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blockonkeys.blpopn k 5 wait_for_blocked_clients_count 1 # Check that RM_SignalKeyAsReady() can wake up BLPOPN @@ -316,7 +316,7 @@ start_server {tags {"modules"}} { r del k r set somekey someval # Module client blocks to pop 5 elements from list - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blockonkeys.blpopn_or_unblock k 5 0 wait_for_blocked_clients_count 1 # will now cause the module to trigger pop but instead will unblock the client from the reply_callback @@ -342,7 +342,7 @@ start_server {tags {"modules"}} { wait_for_sync $replica test {WAIT command on module blocked client on keys} { - set rd [redis_deferring_client -1] + set rd [valkey_deferring_client -1] $rd set x y $rd read diff --git a/tests/unit/moduleapi/cluster.tcl b/tests/unit/moduleapi/cluster.tcl index d24082ec44..06878c1a01 100644 --- a/tests/unit/moduleapi/cluster.tcl +++ b/tests/unit/moduleapi/cluster.tcl @@ -19,7 +19,7 @@ start_cluster 3 0 [list config_lines $modules] { test "Run blocking command (blocked on key) on cluster node3" { # key9184688 is mapped to slot 10923 (first slot of node 3) - set node3_rd [redis_deferring_client -2] + set node3_rd [valkey_deferring_client -2] $node3_rd fsl.bpop key9184688 0 $node3_rd flush wait_for_condition 50 100 { @@ -30,7 +30,7 @@ start_cluster 3 0 [list config_lines $modules] { } test "Run blocking command (no keys) on cluster node2" { - set node2_rd [redis_deferring_client -1] + set node2_rd [valkey_deferring_client -1] $node2_rd block.block 0 $node2_rd flush @@ -83,7 +83,7 @@ start_cluster 3 0 [list config_lines $modules] { test "Sanity test push cmd after resharding" { assert_error {*MOVED*} {$node3 fsl.push key9184688 1} - set node1_rd [redis_deferring_client 0] + set node1_rd [valkey_deferring_client 0] $node1_rd fsl.bpop key9184688 0 $node1_rd flush @@ -106,7 +106,7 @@ start_cluster 3 0 [list config_lines $modules] { test "Run blocking command (blocked on key) again on cluster node1" { $node1 del key9184688 # key9184688 is mapped to slot 10923 which has been moved to node1 - set node1_rd [redis_deferring_client 0] + set node1_rd [valkey_deferring_client 0] $node1_rd fsl.bpop key9184688 0 $node1_rd flush @@ -118,7 +118,7 @@ start_cluster 3 0 [list config_lines $modules] { } test "Run blocking command (no keys) again on cluster node2" { - set node2_rd [redis_deferring_client -1] + set node2_rd [valkey_deferring_client -1] $node2_rd block.block 0 $node2_rd flush diff --git a/tests/unit/moduleapi/commandfilter.tcl b/tests/unit/moduleapi/commandfilter.tcl index 72b16ec978..52bd6f1cb0 100644 --- a/tests/unit/moduleapi/commandfilter.tcl +++ b/tests/unit/moduleapi/commandfilter.tcl @@ -127,7 +127,7 @@ test {Blocking Commands don't run through command filter when reprocessed} { r lpush list2{t} a b c d e - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # we're asking to pop from the left, but the command filter swaps the two arguments, # if it didn't swap it, we would end up with e d c b a 5 (5 being the left most of the following lpush) # but since we swap the arguments, we end up with 1 e d c b a (1 being the right most of it). diff --git a/tests/unit/moduleapi/datatype.tcl b/tests/unit/moduleapi/datatype.tcl index 951c060e7f..d83fd00da8 100644 --- a/tests/unit/moduleapi/datatype.tcl +++ b/tests/unit/moduleapi/datatype.tcl @@ -64,7 +64,7 @@ start_server {tags {"modules"}} { r config set busy-reply-threshold 5000 ;# make sure we're using a high default # trigger slow loading r datatype.slow_loading 1 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set start [clock clicks -milliseconds] $rd debug reload diff --git a/tests/unit/moduleapi/hooks.tcl b/tests/unit/moduleapi/hooks.tcl index 94b0f6f312..c07f29c846 100644 --- a/tests/unit/moduleapi/hooks.tcl +++ b/tests/unit/moduleapi/hooks.tcl @@ -8,7 +8,7 @@ tags "modules" { test {Test clients connection / disconnection hooks} { for {set j 0} {$j < 2} {incr j} { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 close } assert {[r hooks.event_count client-connected] > 1} @@ -16,7 +16,7 @@ tags "modules" { } test {Test module client change event for blocked client} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # select db other than 0 $rd select 1 # block on key diff --git a/tests/unit/moduleapi/keyspace_events.tcl b/tests/unit/moduleapi/keyspace_events.tcl index 1323b12966..9c1cfa8ba4 100644 --- a/tests/unit/moduleapi/keyspace_events.tcl +++ b/tests/unit/moduleapi/keyspace_events.tcl @@ -76,7 +76,7 @@ tags "modules" { test "Keyspace notifications: module events test" { r config set notify-keyspace-events Kd r del x - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r keyspace.notify x assert_equal {pmessage * __keyspace@9__:x notify} [$rd1 read] diff --git a/tests/unit/moduleapi/moduleauth.tcl b/tests/unit/moduleapi/moduleauth.tcl index a9eb0561c3..d7399d0ff1 100644 --- a/tests/unit/moduleapi/moduleauth.tcl +++ b/tests/unit/moduleapi/moduleauth.tcl @@ -247,8 +247,8 @@ start_server {tags {"modules"}} { test {module auth during blocking module auth} { r config resetstat r acl setuser foo >pwd on ~* &* +@all - set rd [redis_deferring_client] - set rd_two [redis_deferring_client] + set rd [valkey_deferring_client] + set rd_two [valkey_deferring_client] # Attempt blocking module auth. While this ongoing, attempt non blocking module auth from # moduleone/moduletwo and start another blocking module auth from another deferring client. @@ -289,7 +289,7 @@ start_server {tags {"modules"}} { test {Disabling Redis User during blocking module auth} { r config resetstat r acl setuser foo >pwd on ~* &* +@all - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Attempt blocking module auth and disable the user while module auth is in progress. $rd AUTH foo pwd @@ -306,7 +306,7 @@ start_server {tags {"modules"}} { test {Killing a client in the middle of blocking module auth} { r config resetstat r acl setuser foo >pwd on ~* &* +@all - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set cid [$rd read] @@ -337,7 +337,7 @@ start_server {tags {"modules"}} { test {test RM_RegisterAuthCallback Module API during blocking module auth} { r config resetstat r acl setuser foo >defaultpwd on ~* &* +@all - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Start the module auth attempt with the standard auth password for the user. This # will result in all module auth cbs attempted and then standard auth will be tried. @@ -365,7 +365,7 @@ start_server {tags {"modules"}} { test {Module unload during blocking module auth} { r config resetstat r module load $miscmodule - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r acl setuser foo >pwd on ~* &* +@all # Start a blocking module auth attempt. diff --git a/tests/unit/moduleapi/publish.tcl b/tests/unit/moduleapi/publish.tcl index a6304ea528..f0d67fd051 100644 --- a/tests/unit/moduleapi/publish.tcl +++ b/tests/unit/moduleapi/publish.tcl @@ -4,8 +4,8 @@ start_server {tags {"modules"}} { r module load $testmodule test {PUBLISH and SPUBLISH via a module} { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] assert_equal {1} [ssubscribe $rd1 {chan1}] assert_equal {1} [subscribe $rd2 {chan1}] diff --git a/tests/unit/moduleapi/rdbloadsave.tcl b/tests/unit/moduleapi/rdbloadsave.tcl index b0e6d54229..37841aa9aa 100644 --- a/tests/unit/moduleapi/rdbloadsave.tcl +++ b/tests/unit/moduleapi/rdbloadsave.tcl @@ -37,7 +37,7 @@ start_server {tags {"modules"}} { # cause a problem. # e.g. the server won't try to process next message of the current client # while it is in the command callback for that client . - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 test.rdbload blabla.rdb wait_for_condition 50 100 { diff --git a/tests/unit/moduleapi/stream.tcl b/tests/unit/moduleapi/stream.tcl index 7ad1a30598..92c058b51d 100644 --- a/tests/unit/moduleapi/stream.tcl +++ b/tests/unit/moduleapi/stream.tcl @@ -30,7 +30,7 @@ start_server {tags {"modules"}} { r del mystream # Blocking XREAD on an empty key - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 XREAD BLOCK 3000 STREAMS mystream $ # wait until client is actually blocked wait_for_condition 50 100 { @@ -42,7 +42,7 @@ start_server {tags {"modules"}} { assert_equal "{mystream {{$id {field 1 value a}}}}" [$rd1 read] # Blocking XREAD on an existing stream - set rd2 [redis_deferring_client] + set rd2 [valkey_deferring_client] $rd2 XREAD BLOCK 3000 STREAMS mystream $ # wait until client is actually blocked wait_for_condition 50 100 { diff --git a/tests/unit/moduleapi/test_lazyfree.tcl b/tests/unit/moduleapi/test_lazyfree.tcl index 8d2c55abcf..9e1e4680af 100644 --- a/tests/unit/moduleapi/test_lazyfree.tcl +++ b/tests/unit/moduleapi/test_lazyfree.tcl @@ -5,7 +5,7 @@ start_server {tags {"modules"}} { test "modules allocated memory can be reclaimed in the background" { set orig_mem [s used_memory] - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # LAZYFREE_THRESHOLD is 64 for {set i 0} {$i < 10000} {incr i} { diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 80765e69c7..16915fef3b 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -68,7 +68,7 @@ start_server {tags {"multi"}} { } {0 0} test {EXEC fails if there are errors while queueing commands #2} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del foo1{t} foo2{t} r multi r set foo1{t} bar1 @@ -523,7 +523,7 @@ start_server {tags {"multi"}} { } {OK} {needs:repl cluster:skip} test {DISCARD should not fail during OOM} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd config set maxmemory 1 assert {[$rd read] eq {OK}} r multi @@ -539,7 +539,7 @@ start_server {tags {"multi"}} { test {MULTI and script timeout} { # check that if MULTI arrives during timeout, it is either refused, or # allowed to pass, and we don't end up executing half of the transaction - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] set r2 [redis_client] r config set lua-time-limit 10 r set xx 1 @@ -564,7 +564,7 @@ start_server {tags {"multi"}} { test {EXEC and script timeout} { # check that if EXEC arrives during timeout, we don't end up executing # half of the transaction, and also that we exit the multi state - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] set r2 [redis_client] r config set lua-time-limit 10 r set xx 1 @@ -589,7 +589,7 @@ start_server {tags {"multi"}} { test {MULTI-EXEC body and script timeout} { # check that we don't run an incomplete transaction due to some commands # arriving during busy script - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] set r2 [redis_client] r config set lua-time-limit 10 r set xx 1 @@ -614,7 +614,7 @@ start_server {tags {"multi"}} { test {just EXEC and script timeout} { # check that if EXEC arrives during timeout, we don't end up executing # actual commands during busy script, and also that we exit the multi state - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] set r2 [redis_client] r config set lua-time-limit 10 r set xx 1 diff --git a/tests/unit/obuf-limits.tcl b/tests/unit/obuf-limits.tcl index 42185fa3d9..b0fd184afe 100644 --- a/tests/unit/obuf-limits.tcl +++ b/tests/unit/obuf-limits.tcl @@ -29,7 +29,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { test {Client output buffer hard limit is enforced} { r config set client-output-buffer-limit {pubsub 100000 0 0} - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 subscribe foo set reply [$rd1 read] @@ -58,7 +58,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { test $test_name { r config set client-output-buffer-limit "pubsub 0 100000 $soft_limit_time" set soft_limit_time [expr $soft_limit_time*1000] - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 client setname test_client set reply [$rd1 read] @@ -124,7 +124,7 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { } set orig_mem [s used_memory] # Set client name and get all items - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client setname mybiglist assert {[$rd read] eq "OK"} $rd lrange mylist 0 -1 @@ -149,8 +149,8 @@ start_server {tags {"obuf-limits external:skip logreqres:skip"}} { r config set client-output-buffer-limit {normal 100000 0 0} set value [string repeat "x" 10000] r set bigkey $value - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd2 client setname multicommands assert_equal "OK" [$rd2 read] diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index 422fc76d6a..31e4e563b9 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -308,7 +308,7 @@ start_server {tags {"other"}} { } {} {needs:reset} test {RESET clears MONITOR state} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd monitor assert_equal [$rd read] "OK" diff --git a/tests/unit/pause.tcl b/tests/unit/pause.tcl index e30f922e67..d27f5775c4 100644 --- a/tests/unit/pause.tcl +++ b/tests/unit/pause.tcl @@ -1,7 +1,7 @@ start_server {tags {"pause network"}} { test "Test read commands are not blocked by client pause" { r client PAUSE 100000 WRITE - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd GET FOO $rd PING $rd INFO @@ -24,7 +24,7 @@ start_server {tags {"pause network"}} { # paused only WRITE. This is because the first 'PAUSE ALL' command is # more restrictive than the second 'PAUSE WRITE' and pause-client feature # preserve most restrictive configuration among multiple settings. - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SET FOO BAR set test_start_time [clock milliseconds] @@ -40,7 +40,7 @@ start_server {tags {"pause network"}} { r client PAUSE 60000 WRITE r client PAUSE 10 WRITE after 100 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SET FOO BAR wait_for_blocked_clients_count 1 100 10 @@ -52,7 +52,7 @@ start_server {tags {"pause network"}} { test "Test write commands are paused by RO" { r client PAUSE 60000 WRITE - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SET FOO BAR wait_for_blocked_clients_count 1 50 100 @@ -66,13 +66,13 @@ start_server {tags {"pause network"}} { r client PAUSE 100000 WRITE # Test that pfcount, which can replicate, is also blocked - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd PFCOUNT pause-hll wait_for_blocked_clients_count 1 50 100 # Test that publish, which adds the message to the replication # stream is blocked. - set rd2 [redis_deferring_client] + set rd2 [valkey_deferring_client] $rd2 publish foo bar wait_for_blocked_clients_count 2 50 100 @@ -97,7 +97,7 @@ start_server {tags {"pause network"}} { } test "Test write multi-execs are blocked by pause RO" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd MULTI assert_equal [$rd read] "OK" $rd SET FOO BAR @@ -112,8 +112,8 @@ start_server {tags {"pause network"}} { test "Test scripts are blocked by pause RO" { r client PAUSE 60000 WRITE - set rd [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd EVAL "return 1" 0 # test a script with a shebang and no flags for coverage @@ -194,8 +194,8 @@ start_server {tags {"pause network"}} { } test "Test write scripts in multi-exec are blocked by pause RO" { - set rd [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd [valkey_deferring_client] + set rd2 [valkey_deferring_client] # one with a shebang $rd MULTI @@ -240,7 +240,7 @@ start_server {tags {"pause network"}} { test "Test multiple clients can be queued up and unblocked" { r client PAUSE 60000 WRITE - set clients [list [redis_deferring_client] [redis_deferring_client] [redis_deferring_client]] + set clients [list [valkey_deferring_client] [valkey_deferring_client] [valkey_deferring_client]] foreach client $clients { $client SET FOO BAR } @@ -294,7 +294,7 @@ start_server {tags {"pause network"}} { r SET FOO2{t} BAR r exec - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SET FOO3{t} BAR wait_for_blocked_clients_count 1 50 100 diff --git a/tests/unit/protocol.tcl b/tests/unit/protocol.tcl index e3b4115a8a..cd7dbe9e5a 100644 --- a/tests/unit/protocol.tcl +++ b/tests/unit/protocol.tcl @@ -234,7 +234,7 @@ start_server {tags {"protocol network"}} { start_server {tags {"regression"}} { test "Regression for a crash with blocking ops and pipelining" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set fd [r channel] set proto "*3\r\n\$5\r\nBLPOP\r\n\$6\r\nnolist\r\n\$1\r\n0\r\n" puts -nonewline $fd $proto$proto diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl index 3797b00c7f..5a2439814f 100644 --- a/tests/unit/pubsub.tcl +++ b/tests/unit/pubsub.tcl @@ -6,7 +6,7 @@ start_server {tags {"pubsub network"}} { } foreach resp {2 3} { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] if {[lsearch $::denytags "resp3"] >= 0} { if {$resp == 3} {continue} } elseif {$::force_resp3} { @@ -42,7 +42,7 @@ start_server {tags {"pubsub network"}} { } test "PUBLISH/SUBSCRIBE basics" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] # subscribe to two channels assert_equal {1 2} [subscribe $rd1 {chan1 chan2}] @@ -67,8 +67,8 @@ start_server {tags {"pubsub network"}} { } test "PUBLISH/SUBSCRIBE with two clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] assert_equal {1} [subscribe $rd1 {chan1}] assert_equal {1} [subscribe $rd2 {chan1}] @@ -82,7 +82,7 @@ start_server {tags {"pubsub network"}} { } test "PUBLISH/SUBSCRIBE after UNSUBSCRIBE without arguments" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1 2 3} [subscribe $rd1 {chan1 chan2 chan3}] unsubscribe $rd1 assert_equal 0 [r publish chan1 hello] @@ -94,7 +94,7 @@ start_server {tags {"pubsub network"}} { } test "SUBSCRIBE to one channel more than once" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1 1 1} [subscribe $rd1 {chan1 chan1 chan1}] assert_equal 1 [r publish chan1 hello] assert_equal {message chan1 hello} [$rd1 read] @@ -104,7 +104,7 @@ start_server {tags {"pubsub network"}} { } test "UNSUBSCRIBE from non-subscribed channels" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {0 0 0} [unsubscribe $rd1 {foo bar quux}] # clean up clients @@ -112,7 +112,7 @@ start_server {tags {"pubsub network"}} { } test "PUBLISH/PSUBSCRIBE basics" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] # subscribe to two patterns assert_equal {1 2} [psubscribe $rd1 {foo.* bar.*}] @@ -140,8 +140,8 @@ start_server {tags {"pubsub network"}} { } test "PUBLISH/PSUBSCRIBE with two clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 {chan.*}] assert_equal {1} [psubscribe $rd2 {chan.*}] @@ -155,7 +155,7 @@ start_server {tags {"pubsub network"}} { } test "PUBLISH/PSUBSCRIBE after PUNSUBSCRIBE without arguments" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1 2 3} [psubscribe $rd1 {chan1.* chan2.* chan3.*}] punsubscribe $rd1 assert_equal 0 [r publish chan1.hi hello] @@ -167,7 +167,7 @@ start_server {tags {"pubsub network"}} { } test "PubSub messages with CLIENT REPLY OFF" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd hello 3 $rd read ;# Discard the hello reply @@ -191,7 +191,7 @@ start_server {tags {"pubsub network"}} { } {0} {resp3} test "PUNSUBSCRIBE from non-subscribed channels" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {0 0 0} [punsubscribe $rd1 {foo.* bar.* quux.*}] # clean up clients @@ -203,8 +203,8 @@ start_server {tags {"pubsub network"}} { } {abc 0 def 0} test "NUMPATs returns the number of unique patterns" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] # Three unique patterns and one that overlaps psubscribe $rd1 "foo*" @@ -223,7 +223,7 @@ start_server {tags {"pubsub network"}} { } test "Mix SUBSCRIBE and PSUBSCRIBE" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [subscribe $rd1 {foo.bar}] assert_equal {2} [psubscribe $rd1 {foo.*}] @@ -249,7 +249,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: we receive keyspace notifications" { r config set notify-keyspace-events KA - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 CLIENT REPLY OFF ;# Make sure it works even if replies are silenced assert_equal {1} [psubscribe $rd1 *] r set foo bar @@ -259,7 +259,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: we receive keyevent notifications" { r config set notify-keyspace-events EA - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 CLIENT REPLY SKIP ;# Make sure it works even if replies are silenced assert_equal {1} [psubscribe $rd1 *] r set foo bar @@ -269,7 +269,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: we can receive both kind of events" { r config set notify-keyspace-events KEA - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] $rd1 CLIENT REPLY ON ;# Just coverage assert_equal {OK} [$rd1 read] assert_equal {1} [psubscribe $rd1 *] @@ -282,7 +282,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: we are able to mask events" { r config set notify-keyspace-events KEl r del mylist - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r set foo bar r lpush mylist a @@ -294,7 +294,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: general events test" { r config set notify-keyspace-events KEg - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r set foo bar r expire foo 1 @@ -309,7 +309,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: list events test" { r config set notify-keyspace-events KEl r del mylist - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r lpush mylist a r rpush mylist a @@ -326,7 +326,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: set events test" { r config set notify-keyspace-events Ks r del myset - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r sadd myset a b c d r srem myset x @@ -341,7 +341,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: zset events test" { r config set notify-keyspace-events Kz r del myzset - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r zadd myzset 1 a 2 b r zrem myzset x @@ -356,7 +356,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: hash events test" { r config set notify-keyspace-events Kh r del myhash - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r hmset myhash yes 1 no 0 r hincrby myhash yes 10 @@ -368,7 +368,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: stream events test" { r config set notify-keyspace-events Kt r del mystream - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r xgroup create mystream mygroup $ mkstream r xgroup createconsumer mystream mygroup Bob @@ -392,7 +392,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: expired events (triggered expire)" { r config set notify-keyspace-events Ex r del foo - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r psetex foo 100 1 wait_for_condition 50 100 { @@ -407,7 +407,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: expired events (background expire)" { r config set notify-keyspace-events Ex r del foo - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r psetex foo 100 1 assert_equal "pmessage * __keyevent@${db}__:expired foo" [$rd1 read] @@ -418,7 +418,7 @@ start_server {tags {"pubsub network"}} { r config set notify-keyspace-events Ee r config set maxmemory-policy allkeys-lru r flushdb - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r set foo bar r config set maxmemory 1 @@ -441,7 +441,7 @@ start_server {tags {"pubsub network"}} { test "Keyspace notifications: new key test" { r config set notify-keyspace-events En - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [psubscribe $rd1 *] r set foo bar # second set of foo should not cause a 'new' event diff --git a/tests/unit/pubsubshard.tcl b/tests/unit/pubsubshard.tcl index 6e3fb61c1c..d56f36ffaa 100644 --- a/tests/unit/pubsubshard.tcl +++ b/tests/unit/pubsubshard.tcl @@ -1,6 +1,6 @@ start_server {tags {"pubsubshard external:skip"}} { test "SPUBLISH/SSUBSCRIBE basics" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] # subscribe to two channels assert_equal {1} [ssubscribe $rd1 {chan1}] @@ -26,8 +26,8 @@ start_server {tags {"pubsubshard external:skip"}} { } test "SPUBLISH/SSUBSCRIBE with two clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] assert_equal {1} [ssubscribe $rd1 {chan1}] assert_equal {1} [ssubscribe $rd2 {chan1}] @@ -41,7 +41,7 @@ start_server {tags {"pubsubshard external:skip"}} { } test "SPUBLISH/SSUBSCRIBE after UNSUBSCRIBE without arguments" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1} [ssubscribe $rd1 {chan1}] assert_equal {2} [ssubscribe $rd1 {chan2}] assert_equal {3} [ssubscribe $rd1 {chan3}] @@ -55,7 +55,7 @@ start_server {tags {"pubsubshard external:skip"}} { } test "SSUBSCRIBE to one channel more than once" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {1 1 1} [ssubscribe $rd1 {chan1 chan1 chan1}] assert_equal 1 [r SPUBLISH chan1 hello] assert_equal {smessage chan1 hello} [$rd1 read] @@ -65,7 +65,7 @@ start_server {tags {"pubsubshard external:skip"}} { } test "SUNSUBSCRIBE from non-subscribed channels" { - set rd1 [redis_deferring_client] + set rd1 [valkey_deferring_client] assert_equal {0} [sunsubscribe $rd1 {foo}] assert_equal {0} [sunsubscribe $rd1 {bar}] assert_equal {0} [sunsubscribe $rd1 {quux}] @@ -79,8 +79,8 @@ start_server {tags {"pubsubshard external:skip"}} { } {abc 0 def 0} test "SPUBLISH/SSUBSCRIBE with two clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] assert_equal {1} [ssubscribe $rd1 {chan1}] assert_equal {1} [ssubscribe $rd2 {chan1}] @@ -94,8 +94,8 @@ start_server {tags {"pubsubshard external:skip"}} { } test "SPUBLISH/SSUBSCRIBE with PUBLISH/SUBSCRIBE" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] assert_equal {1} [ssubscribe $rd1 {chan1}] assert_equal {1} [subscribe $rd2 {chan1}] @@ -111,7 +111,7 @@ start_server {tags {"pubsubshard external:skip"}} { } test "PubSubShard with CLIENT REPLY OFF" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd hello 3 $rd read ;# Discard the hello reply @@ -151,8 +151,8 @@ start_server {tags {"pubsubshard external:skip"}} { } test {publish message to master and receive on replica} { - set rd0 [redis_deferring_client node_0_host node_0_port] - set rd1 [redis_deferring_client node_1_host node_1_port] + set rd0 [valkey_deferring_client node_0_host node_0_port] + set rd1 [valkey_deferring_client node_1_host node_1_port] assert_equal {1} [ssubscribe $rd1 {chan1}] $rd0 SPUBLISH chan1 hello diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index b45099519d..65927dffa6 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -770,7 +770,7 @@ start_server {tags {"scripting"}} { r script flush ;# reset Lua VM r set x 0 # Use a non blocking client to speedup the loop. - set rd [redis_deferring_client] + set rd [valkey_deferring_client] for {set j 0} {$j < 10000} {incr j} { run_script_on_connection $rd {return redis.call("incr",KEYS[1])} 1 x } @@ -1138,7 +1138,7 @@ start_server {tags {"scripting"}} { # instance at all. start_server {tags {"scripting"}} { test {Timedout read-only scripts can be killed by SCRIPT KILL} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set lua-time-limit 10 run_script_on_connection $rd {while true do end} 0 after 200 @@ -1151,7 +1151,7 @@ start_server {tags {"scripting"}} { } test {Timedout read-only scripts can be killed by SCRIPT KILL even when use pcall} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set lua-time-limit 10 run_script_on_connection $rd {local f = function() while 1 do redis.call('ping') end end while 1 do pcall(f) end} 0 @@ -1179,7 +1179,7 @@ start_server {tags {"scripting"}} { } test {Timedout script does not cause a false dead client} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set lua-time-limit 10 # senging (in a pipeline): @@ -1240,8 +1240,8 @@ start_server {tags {"scripting"}} { r config set appendonly yes # create clients, and set one to block waiting for key 'x' - set rd [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd [valkey_deferring_client] + set rd2 [valkey_deferring_client] set r3 [redis_client] $rd2 blpop x 0 wait_for_blocked_clients_count 1 @@ -1280,7 +1280,7 @@ start_server {tags {"scripting"}} { } {OK} {external:skip needs:debug} test {Timedout scripts that modified data can't be killed by SCRIPT KILL} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r config set lua-time-limit 10 run_script_on_connection $rd {redis.call('set',KEYS[1],'y'); while true do end} 1 x after 200 @@ -1300,7 +1300,7 @@ start_server {tags {"scripting"}} { assert_match {BUSY*} $e catch {r shutdown nosave} # Make sure the server was killed - catch {set rd [redis_deferring_client]} e + catch {set rd [valkey_deferring_client]} e assert_match {*connection refused*} $e } {} {external:skip} } @@ -1348,7 +1348,7 @@ start_server {tags {"scripting"}} { } ;# is_eval test "Replication of script multiple pushes to list with BLPOP" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd brpop a 0 run_script { redis.call("lpush",KEYS[1],"1"); @@ -2125,7 +2125,7 @@ start_server {tags {"scripting"}} { # run a slow script that does one write, then waits for INFO to indicate # that the replica dropped, and then runs another write - set rd [redis_deferring_client -1] + set rd [valkey_deferring_client -1] $rd eval { redis.call('set','x',"script value") while true do diff --git a/tests/unit/shutdown.tcl b/tests/unit/shutdown.tcl index 7504851a13..79606c5aea 100644 --- a/tests/unit/shutdown.tcl +++ b/tests/unit/shutdown.tcl @@ -22,7 +22,7 @@ start_server {tags {"shutdown external:skip"}} { catch {r shutdown nosave} # Make sure the server was killed - catch {set rd [redis_deferring_client]} e + catch {set rd [valkey_deferring_client]} e assert_match {*connection refused*} $e # Temp rdb file must be deleted diff --git a/tests/unit/slowlog.tcl b/tests/unit/slowlog.tcl index e7f82ce7f9..547fa2d452 100644 --- a/tests/unit/slowlog.tcl +++ b/tests/unit/slowlog.tcl @@ -143,7 +143,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { assert_equal {INCRBYFLOAT A 1.0} [lindex [lindex [r slowlog get] 0] 3] # blocked BLPOP is replicated as LPOP - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd blpop l 0 wait_for_blocked_clients_count 1 50 100 r multi @@ -231,7 +231,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { # Cleanup first r del mylist # create a test client - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # config the slowlog and reset r config set slowlog-log-slower-than 0 diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl index ee28c0a918..427cc580dd 100644 --- a/tests/unit/tracking.tcl +++ b/tests/unit/tracking.tcl @@ -2,7 +2,7 @@ start_server {tags {"tracking network logreqres:skip"}} { # Create a deferred client we'll use to redirect invalidation # messages to. - set rd_redirection [redis_deferring_client] + set rd_redirection [valkey_deferring_client] $rd_redirection client id set redir_id [$rd_redirection read] $rd_redirection subscribe __redis__:invalidate @@ -10,7 +10,7 @@ start_server {tags {"tracking network logreqres:skip"}} { # Create another client that's not used as a redirection client # We should always keep this client's buffer clean - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Client to be used for SET and GET commands # We don't read this client's buffer @@ -24,8 +24,8 @@ start_server {tags {"tracking network logreqres:skip"}} { r CLIENT TRACKING off $rd QUIT $rd_redirection QUIT - set rd [redis_deferring_client] - set rd_redirection [redis_deferring_client] + set rd [valkey_deferring_client] + set rd_redirection [valkey_deferring_client] $rd_redirection client id set redir_id [$rd_redirection read] $rd_redirection subscribe __redis__:invalidate @@ -269,7 +269,7 @@ start_server {tags {"tracking network logreqres:skip"}} { assert_equal PONG [r read] # Reinstantiating after QUIT - set rd_redirection [redis_deferring_client] + set rd_redirection [valkey_deferring_client] $rd_redirection CLIENT ID set redir_id [$rd_redirection read] $rd_redirection SUBSCRIBE __redis__:invalidate @@ -814,7 +814,7 @@ start_server {tags {"tracking network logreqres:skip"}} { test {RESP3 based basic redirect invalidation with client reply off} { clean_all - set rd_redir [redis_deferring_client] + set rd_redir [valkey_deferring_client] $rd_redir hello 3 $rd_redir read @@ -880,7 +880,7 @@ start_server {tags {"tracking network logreqres:skip"}} { # run the full tracking unit in that mode start_server {tags {"tracking network"}} { test {Coverage: Basic CLIENT CACHING} { - set rd_redirection [redis_deferring_client] + set rd_redirection [valkey_deferring_client] $rd_redirection client id set redir_id [$rd_redirection read] assert_equal {OK} [r CLIENT TRACKING on OPTIN REDIRECT $redir_id] diff --git a/tests/unit/type/list.tcl b/tests/unit/type/list.tcl index 5ea62cb910..d9870b8062 100644 --- a/tests/unit/type/list.tcl +++ b/tests/unit/type/list.tcl @@ -645,7 +645,7 @@ foreach {type large} [array get largevalue] { foreach {type large} [array get largevalue] { foreach {pop} {BLPOP BLMPOP_LEFT} { test "$pop: single existing list - $type" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_$type blist "a b $large c d" bpop_command $rd $pop blist 1 @@ -671,7 +671,7 @@ foreach {type large} [array get largevalue] { } test "$pop: multiple existing lists - $type" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_$type blist1{t} "a $large c" create_$type blist2{t} "d $large f" @@ -700,7 +700,7 @@ foreach {type large} [array get largevalue] { } test "$pop: second list has an entry - $type" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist1{t} create_$type blist2{t} "d $large f" @@ -722,7 +722,7 @@ foreach {type large} [array get largevalue] { r del target{t} r rpush target{t} bar - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_$type blist{t} "a b $large c d" $rd brpoplpush blist{t} target{t} 1 @@ -739,7 +739,7 @@ foreach {type large} [array get largevalue] { r del target{t} r rpush target{t} bar - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_$type blist{t} "a b $large c d" $rd blmove blist{t} target{t} $wherefrom $whereto 1 @@ -766,7 +766,7 @@ foreach {type large} [array get largevalue] { foreach {pop} {BLPOP BLMPOP_LEFT} { test "$pop, LPUSH + DEL should not awake blocked client" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del list bpop_command $rd $pop list 0 @@ -783,7 +783,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "$pop, LPUSH + DEL + SET should not awake blocked client" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del list bpop_command $rd $pop list 0 @@ -802,7 +802,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "BLPOP with same key multiple times should work (issue #801)" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del list1{t} list2{t} # Data arriving after the BLPOP. @@ -827,7 +827,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { foreach {pop} {BLPOP BLMPOP_LEFT} { test "MULTI/EXEC is isolated from the point of view of $pop" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del list bpop_command $rd $pop list 0 @@ -843,7 +843,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "$pop with variadic LPUSH" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist bpop_command $rd $pop blist 0 wait_for_blocked_client @@ -855,7 +855,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "BRPOPLPUSH with zero timeout should block indefinitely" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} target{t} r rpush target{t} bar $rd brpoplpush blist{t} target{t} 0 @@ -869,7 +869,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { foreach wherefrom {left right} { foreach whereto {left right} { test "BLMOVE $wherefrom $whereto with zero timeout should block indefinitely" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} target{t} r rpush target{t} bar $rd blmove blist{t} target{t} $wherefrom $whereto 0 @@ -889,8 +889,8 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { foreach wherefrom {left right} { foreach whereto {left right} { test "BLMOVE ($wherefrom, $whereto) with a client BLPOPing the target list" { - set rd [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd [valkey_deferring_client] + set rd2 [valkey_deferring_client] r del blist{t} target{t} $rd2 blpop target{t} 0 wait_for_blocked_clients_count 1 @@ -907,7 +907,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "BRPOPLPUSH with wrong source type" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} target{t} r set blist{t} nolist $rd brpoplpush blist{t} target{t} 1 @@ -916,7 +916,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "BRPOPLPUSH with wrong destination type" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} target{t} r set target{t} nolist r lpush blist{t} foo @@ -924,7 +924,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { assert_error "WRONGTYPE*" {$rd read} $rd close - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} target{t} r set target{t} nolist $rd brpoplpush blist{t} target{t} 0 @@ -936,7 +936,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "BRPOPLPUSH maintains order of elements after failure" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} target{t} r set target{t} nolist $rd brpoplpush blist{t} target{t} 0 @@ -948,8 +948,8 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } {a b c} test "BRPOPLPUSH with multiple blocked clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] r del blist{t} target1{t} target2{t} r set target1{t} nolist $rd1 brpoplpush blist{t} target1{t} 0 @@ -966,10 +966,10 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "BLMPOP with multiple blocked clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] - set rd3 [redis_deferring_client] - set rd4 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] + set rd3 [valkey_deferring_client] + set rd4 [valkey_deferring_client] r del blist{t} blist2{t} $rd1 blmpop 0 2 blist{t} blist2{t} left count 1 @@ -999,8 +999,8 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "Linked LMOVEs" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] r del list1{t} list2{t} list3{t} @@ -1019,8 +1019,8 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "Circular BRPOPLPUSH" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] r del list1{t} list2{t} @@ -1038,7 +1038,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "Self-referential BRPOPLPUSH" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist{t} @@ -1066,8 +1066,8 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } {foo bar {} {} {bar foo}} test "PUSH resulting from BRPOPLPUSH affect WATCH" { - set blocked_client [redis_deferring_client] - set watching_client [redis_deferring_client] + set blocked_client [valkey_deferring_client] + set watching_client [valkey_deferring_client] r del srclist{t} dstlist{t} somekey{t} r set somekey{t} somevalue $blocked_client brpoplpush srclist{t} dstlist{t} 0 @@ -1087,8 +1087,8 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } {} test "BRPOPLPUSH does not affect WATCH while still blocked" { - set blocked_client [redis_deferring_client] - set watching_client [redis_deferring_client] + set blocked_client [valkey_deferring_client] + set watching_client [valkey_deferring_client] r del srclist{t} dstlist{t} somekey{t} r set somekey{t} somevalue $blocked_client brpoplpush srclist{t} dstlist{t} 0 @@ -1109,7 +1109,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } {somevalue} test {BRPOPLPUSH timeout} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd brpoplpush foo_list{t} bar_list{t} 1 wait_for_blocked_clients_count 1 @@ -1124,7 +1124,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { r select 1 r rpush k hello r select 9 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd brpop k 5 wait_for_blocked_clients_count 1 r swapdb 1 9 @@ -1138,7 +1138,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { r select 1 r rpush k hello r pexpire k 100 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd deferred 0 $rd select 9 set id [$rd client id] @@ -1184,7 +1184,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { r flushall r debug set-active-expire 0 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set id [$rd read] $rd brpop k 0 @@ -1224,7 +1224,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { test {BLPOP unblock but the key is expired and then block again - reprocessing command} { r flushall r debug set-active-expire 0 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set start [clock milliseconds] $rd blpop mylist 1 @@ -1251,7 +1251,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { foreach {pop} {BLPOP BLMPOP_LEFT} { test "$pop when new key is moved into place" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del foo{t} bpop_command $rd $pop foo{t} 0 @@ -1264,7 +1264,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } {foo{t} hij} test "$pop when result key is created by SORT..STORE" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # zero out list from previous test without explicit delete r lpop foo{t} @@ -1291,7 +1291,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { foreach {pop} {BLPOP BRPOP BLMPOP_LEFT BLMPOP_RIGHT} { test "$pop: with single empty list argument" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist1 bpop_command $rd $pop blist1 1 wait_for_blocked_client @@ -1302,14 +1302,14 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "$pop: with negative timeout" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] bpop_command $rd $pop blist1 -1 assert_error "ERR *is negative*" {$rd read} $rd close } test "$pop: with non-integer timeout" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist1 bpop_command $rd $pop blist1 0.1 r rpush blist1 foo @@ -1321,7 +1321,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { test "$pop: with zero timeout should block indefinitely" { # To test this, use a timeout of 0 and wait a second. # The blocking pop should still be waiting for a push. - set rd [redis_deferring_client] + set rd [valkey_deferring_client] bpop_command $rd $pop blist1 0 wait_for_blocked_client r rpush blist1 foo @@ -1332,7 +1332,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { test "$pop: with 0.001 timeout should not block indefinitely" { # Use a timeout of 0.001 and wait for the number of blocked clients to equal 0. # Validate the empty read from the deferring client. - set rd [redis_deferring_client] + set rd [valkey_deferring_client] bpop_command $rd $pop blist1 0.001 wait_for_blocked_clients_count 0 assert_equal {} [$rd read] @@ -1340,7 +1340,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "$pop: second argument is not a list" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist1{t} blist2{t} r set blist2{t} nolist{t} bpop_command_two_key $rd $pop blist1{t} blist2{t} 1 @@ -1349,7 +1349,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "$pop: timeout" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist1{t} blist2{t} bpop_command_two_key $rd $pop blist1{t} blist2{t} 1 wait_for_blocked_client @@ -1358,7 +1358,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test "$pop: arguments are empty" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del blist1{t} blist2{t} bpop_command_two_key $rd $pop blist1{t} blist2{t} 1 @@ -1393,7 +1393,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} { } test {BLMPOP propagate as pop with count command to replica} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set repl [attach_to_replication_stream] # BLMPOP without being blocked. @@ -2009,8 +2009,8 @@ foreach {type large} [array get largevalue] { } test "Regression for bug 593 - chaining BRPOPLPUSH with other blocking cmds" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd1 brpoplpush a{t} b{t} 0 $rd1 brpoplpush a{t} b{t} 0 @@ -2025,7 +2025,7 @@ foreach {type large} [array get largevalue] { test "BLPOP/BLMOVE should increase dirty" { r del lst{t} lst1{t} - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set dirty [s rdb_changes_since_last_save] $rd blpop lst{t} 0 @@ -2049,7 +2049,7 @@ foreach {type large} [array get largevalue] { foreach {pop} {BLPOP BLMPOP_RIGHT} { test "client unblock tests" { r del l - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set id [$rd read] @@ -2261,8 +2261,8 @@ foreach {pop} {BLPOP BLMPOP_RIGHT} { } {12 0 9223372036854775808 2147483647 32767 127} test "Unblock fairness is kept while pipelining" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] # delete the list in case already exists r del mylist @@ -2296,9 +2296,9 @@ foreach {pop} {BLPOP BLMPOP_RIGHT} { } test "Unblock fairness is kept during nested unblock" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] - set rd3 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] + set rd3 [valkey_deferring_client] # delete the list in case already exists r del l1{t} l2{t} l3{t} @@ -2334,7 +2334,7 @@ foreach {pop} {BLPOP BLMPOP_RIGHT} { r del mylist # create a test client - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # reset the server stats r config resetstat @@ -2357,7 +2357,7 @@ foreach {pop} {BLPOP BLMPOP_RIGHT} { r del mylist # create a test client - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd client id set id [$rd read] @@ -2380,9 +2380,9 @@ foreach {pop} {BLPOP BLMPOP_RIGHT} { r del src{t} dst{t} key1{t} key2{t} key3{t} set repl [attach_to_replication_stream] - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] - set rd3 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] + set rd3 [valkey_deferring_client] $rd1 blmove src{t} dst{t} left right 0 wait_for_blocked_clients_count 1 diff --git a/tests/unit/type/stream-cgroups.tcl b/tests/unit/type/stream-cgroups.tcl index a86488a78c..2cd812e521 100644 --- a/tests/unit/type/stream-cgroups.tcl +++ b/tests/unit/type/stream-cgroups.tcl @@ -221,7 +221,7 @@ start_server { assert {[lindex $res 0 1 0] == {666-0 {f v}}} r XADD mystream 667 f2 v2 r XDEL mystream 667 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 10 STREAMS mystream ">" wait_for_blocked_clients_count 0 assert {[$rd read] == {}} ;# before the fix, client didn't even block, but was served synchronously with {mystream {}} @@ -232,7 +232,7 @@ start_server { r DEL mystream r XADD mystream 666 f v r XGROUP CREATE mystream mygroup $ - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" wait_for_blocked_clients_count 1 r DEL mystream @@ -244,7 +244,7 @@ start_server { r DEL mystream r XADD mystream 666 f v r XGROUP CREATE mystream mygroup $ - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" wait_for_blocked_clients_count 1 r SET mystream val1 @@ -256,7 +256,7 @@ start_server { r DEL mystream r XADD mystream 666 f v r XGROUP CREATE mystream mygroup $ - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" wait_for_blocked_clients_count 1 r MULTI @@ -271,7 +271,7 @@ start_server { r DEL mystream r XADD mystream 666 f v r XGROUP CREATE mystream mygroup $ - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" wait_for_blocked_clients_count 1 r FLUSHALL @@ -286,7 +286,7 @@ start_server { r DEL mystream r XADD mystream 666 f v r XGROUP CREATE mystream mygroup $ - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SELECT 9 $rd read $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" @@ -304,7 +304,7 @@ start_server { r DEL mystream r XADD mystream 666 f v r XGROUP CREATE mystream mygroup $ - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd SELECT 9 $rd read $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" @@ -325,7 +325,7 @@ start_server { test {Blocking XREAD: key deleted} { r DEL mystream r XADD mystream 666 f v - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 0 STREAMS mystream "$" wait_for_blocked_clients_count 1 r DEL mystream @@ -339,7 +339,7 @@ start_server { test {Blocking XREAD: key type changed with SET} { r DEL mystream r XADD mystream 666 f v - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 0 STREAMS mystream "$" wait_for_blocked_clients_count 1 r SET mystream val1 @@ -352,7 +352,7 @@ start_server { } test {Blocking XREADGROUP for stream that ran dry (issue #5299)} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Add a entry then delete it, now stream's last_id is 666. r DEL mystream @@ -378,7 +378,7 @@ start_server { } test "Blocking XREADGROUP will ignore BLOCK if ID is not >" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Add a entry then delete it, now stream's last_id is 666. r DEL mystream @@ -427,8 +427,8 @@ start_server { } test {Blocking XREADGROUP for stream key that has clients blocked on list} { - set rd [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd [valkey_deferring_client] + set rd2 [valkey_deferring_client] # First delete the stream r DEL mystream @@ -479,9 +479,9 @@ start_server { r DEL mystream r XGROUP CREATE mystream mygroup $ MKSTREAM - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] - set rd3 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] + set rd3 [valkey_deferring_client] $rd1 xreadgroup GROUP mygroup myuser COUNT 10 BLOCK 10000 STREAMS mystream > $rd2 xreadgroup GROUP mygroup myuser COUNT 10 BLOCK 10000 STREAMS mystream > @@ -502,8 +502,8 @@ start_server { r DEL mystream r XGROUP CREATE mystream mygroup $ MKSTREAM - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] $rd1 xreadgroup GROUP mygroup myuser BLOCK 0 STREAMS mystream > wait_for_blocked_clients_count 1 @@ -530,7 +530,7 @@ start_server { r config resetstat r del mystream r XGROUP CREATE mystream mygroup $ MKSTREAM - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream ">" wait_for_blocked_clients_count 1 r XGROUP DESTROY mystream mygroup @@ -546,7 +546,7 @@ start_server { test {RENAME can unblock XREADGROUP with data} { r del mystream{t} r XGROUP CREATE mystream{t} mygroup $ MKSTREAM - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream{t} ">" wait_for_blocked_clients_count 1 r XGROUP CREATE mystream2{t} mygroup $ MKSTREAM @@ -559,7 +559,7 @@ start_server { test {RENAME can unblock XREADGROUP with -NOGROUP} { r del mystream{t} r XGROUP CREATE mystream{t} mygroup $ MKSTREAM - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Alice BLOCK 0 STREAMS mystream{t} ">" wait_for_blocked_clients_count 1 r XADD mystream2{t} 100 f1 v1 @@ -1015,7 +1015,7 @@ start_server { r XGROUP CREATE mystream mygroup $ MKSTREAM r XADD mystream * f1 v1 r XREADGROUP GROUP mygroup Alice NOACK STREAMS mystream ">" - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Bob BLOCK 0 NOACK STREAMS mystream ">" wait_for_blocked_clients_count 1 r XADD mystream * f2 v2 @@ -1036,7 +1036,7 @@ start_server { r XGROUP CREATE mystream mygroup $ MKSTREAM r XADD mystream * f v r XREADGROUP GROUP mygroup Alice NOACK STREAMS mystream ">" - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREADGROUP GROUP mygroup Bob BLOCK 0 NOACK STREAMS mystream ">" wait_for_blocked_clients_count 1 r XGROUP CREATECONSUMER mystream mygroup Charlie diff --git a/tests/unit/type/stream.tcl b/tests/unit/type/stream.tcl index 68648aab7e..0c56dcd32c 100644 --- a/tests/unit/type/stream.tcl +++ b/tests/unit/type/stream.tcl @@ -337,7 +337,7 @@ start_server { test {Blocking XREAD waiting new data} { r XADD s2{t} * old abcd1234 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 20000 STREAMS s1{t} s2{t} s3{t} $ $ $ wait_for_blocked_client r XADD s2{t} * new abcd1234 @@ -348,7 +348,7 @@ start_server { } test {Blocking XREAD waiting old data} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 20000 STREAMS s1{t} s2{t} s3{t} $ 0-0 $ r XADD s2{t} * foo abcd1234 set res [$rd read] @@ -362,7 +362,7 @@ start_server { r XADD s1 666 f v r XADD s1 667 f2 v2 r XDEL s1 667 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 10 STREAMS s1 666 after 20 assert {[$rd read] == {}} ;# before the fix, client didn't even block, but was served synchronously with {s1 {}} @@ -370,7 +370,7 @@ start_server { } test "Blocking XREAD for stream that ran dry (issue #5299)" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] # Add a entry then delete it, now stream's last_id is 666. r DEL mystream @@ -444,7 +444,7 @@ start_server { r DEL lestream # read last entry from stream, blocking - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 20000 STREAMS lestream + wait_for_blocked_client @@ -511,7 +511,7 @@ start_server { } test "XREAD: XADD + DEL should not awake client" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del s1 $rd XREAD BLOCK 20000 STREAMS s1 $ wait_for_blocked_clients_count 1 @@ -527,7 +527,7 @@ start_server { } test "XREAD: XADD + DEL + LPUSH should not awake client" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del s1 $rd XREAD BLOCK 20000 STREAMS s1 $ wait_for_blocked_clients_count 1 @@ -546,7 +546,7 @@ start_server { test {XREAD with same stream name multiple times should work} { r XADD s2 * old abcd1234 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 20000 STREAMS s2 s2 s2 $ $ $ wait_for_blocked_clients_count 1 r XADD s2 * new abcd1234 @@ -558,7 +558,7 @@ start_server { test {XREAD + multiple XADD inside transaction} { r XADD s2 * old abcd1234 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 20000 STREAMS s2 s2 s2 $ $ $ wait_for_blocked_clients_count 1 r MULTI @@ -682,7 +682,7 @@ start_server { test {XREAD streamID edge (blocking)} { r del x - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd XREAD BLOCK 0 STREAMS x 1-18446744073709551615 wait_for_blocked_clients_count 1 r XADD x 1-1 f v diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index fd24e418fd..f6c643a5ef 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -1166,7 +1166,7 @@ start_server {tags {"zset"}} { foreach {popmin popmax} {BZPOPMIN BZPOPMAX BZMPOP_MIN BZMPOP_MAX} { test "$popmin/$popmax with a single existing sorted set - $encoding" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_zset zset {0 a 1 b 2 c 3 d} verify_bzpop_response $rd $popmin zset 5 0 {zset a 0} {zset {{a 0}}} @@ -1178,7 +1178,7 @@ start_server {tags {"zset"}} { } test "$popmin/$popmax with multiple existing sorted sets - $encoding" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_zset z1{t} {0 a 1 b 2 c} create_zset z2{t} {3 d 4 e 5 f} @@ -1195,7 +1195,7 @@ start_server {tags {"zset"}} { } test "$popmin/$popmax second sorted set has members - $encoding" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del z1{t} create_zset z2{t} {3 d 4 e 5 f} @@ -1228,7 +1228,7 @@ start_server {tags {"zset"}} { foreach {popmin popmax} {BZPOPMIN BZPOPMAX BZMPOP_MIN BZMPOP_MAX} { test "$popmin/$popmax - $encoding RESP3" { r hello 3 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] create_zset zset {0 a 1 b 2 c 3 d} verify_bzpop_response $rd $popmin zset 5 0 {zset a 0} {zset {{a 0}}} @@ -1334,7 +1334,7 @@ start_server {tags {"zset"}} { } {} {needs:repl} foreach resp {3 2} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] if {[lsearch $::denytags "resp3"] >= 0} { if {$resp == 3} {continue} @@ -1952,7 +1952,7 @@ start_server {tags {"zset"}} { foreach {pop} {BZPOPMIN BZMPOP_MIN} { test "$pop, ZADD + DEL should not awake blocked client" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del zset bzpop_command $rd $pop zset 0 @@ -1970,7 +1970,7 @@ start_server {tags {"zset"}} { } test "$pop, ZADD + DEL + SET should not awake blocked client" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del zset bzpop_command $rd $pop zset 0 @@ -1992,7 +1992,7 @@ start_server {tags {"zset"}} { test {BZPOPMIN unblock but the key is expired and then block again - reprocessing command} { r flushall r debug set-active-expire 0 - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set start [clock milliseconds] $rd bzpopmin zset{t} 1 @@ -2018,7 +2018,7 @@ start_server {tags {"zset"}} { } {0} {needs:debug} test "BZPOPMIN with same key multiple times should work" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del z1{t} z2{t} # Data arriving after the BZPOPMIN. @@ -2043,7 +2043,7 @@ start_server {tags {"zset"}} { foreach {pop} {BZPOPMIN BZMPOP_MIN} { test "MULTI/EXEC is isolated from the point of view of $pop" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del zset bzpop_command $rd $pop zset 0 @@ -2060,7 +2060,7 @@ start_server {tags {"zset"}} { } test "$pop with variadic ZADD" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del zset if {$::valgrind} {after 100} bzpop_command $rd $pop zset 0 @@ -2074,7 +2074,7 @@ start_server {tags {"zset"}} { } test "$pop with zero timeout should block indefinitely" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] r del zset bzpop_command $rd $pop zset 0 wait_for_blocked_client @@ -2132,10 +2132,10 @@ start_server {tags {"zset"}} { } test "BZMPOP with multiple blocked clients" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] - set rd3 [redis_deferring_client] - set rd4 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] + set rd3 [valkey_deferring_client] + set rd4 [valkey_deferring_client] r del myzset{t} myzset2{t} $rd1 bzmpop 0 2 myzset{t} myzset2{t} min count 1 @@ -2167,7 +2167,7 @@ start_server {tags {"zset"}} { } test "BZMPOP propagate as pop with count command to replica" { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] set repl [attach_to_replication_stream] # BZMPOP without being blocked. @@ -2213,8 +2213,8 @@ start_server {tags {"zset"}} { } {} {needs:repl} test "BZMPOP should not blocks on non key arguments - #10762" { - set rd1 [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd1 [valkey_deferring_client] + set rd2 [valkey_deferring_client] r del myzset myzset2 myzset3 $rd1 bzmpop 0 1 myzset min count 10 diff --git a/tests/unit/wait.tcl b/tests/unit/wait.tcl index 0f20ef87e9..dfd0be7483 100644 --- a/tests/unit/wait.tcl +++ b/tests/unit/wait.tcl @@ -70,8 +70,8 @@ start_server {} { } test {WAIT replica multiple clients unblock - reuse last result} { - set rd [redis_deferring_client -1] - set rd2 [redis_deferring_client -1] + set rd [valkey_deferring_client -1] + set rd2 [valkey_deferring_client -1] pause_process $slave_pid @@ -125,7 +125,7 @@ tags {"wait aof network external:skip"} { test {WAITAOF local wait and then stop aof} { r config set appendfsync no - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd incr foo $rd read $rd waitaof 1 0 0 @@ -187,7 +187,7 @@ tags {"wait aof network external:skip"} { $replica config set appendfsync no test {WAITAOF on demoted master gets unblocked with an error} { - set rd [redis_deferring_client] + set rd [valkey_deferring_client] $rd incr foo $rd read $rd waitaof 0 1 0 @@ -268,8 +268,8 @@ tags {"wait aof network external:skip"} { } test {WAITAOF replica multiple clients unblock - reuse last result} { - set rd [redis_deferring_client -1] - set rd2 [redis_deferring_client -1] + set rd [valkey_deferring_client -1] + set rd2 [valkey_deferring_client -1] pause_process $replica_pid @@ -311,7 +311,7 @@ tags {"wait aof network external:skip"} { } test {WAITAOF master without backlog, wait is released when the replica finishes full-sync} { - set rd [redis_deferring_client -1] + set rd [valkey_deferring_client -1] $rd incr foo $rd read $rd waitaof 0 1 0 @@ -401,8 +401,8 @@ tags {"wait aof network external:skip"} { } # add some writes and block a client on each master - set rd [redis_deferring_client -3] - set rd2 [redis_deferring_client -1] + set rd [valkey_deferring_client -3] + set rd2 [valkey_deferring_client -1] $rd set boo 11 $rd2 set boo 22 $rd read @@ -454,8 +454,8 @@ start_server {} { } test {WAIT and WAITAOF replica multiple clients unblock - reuse last result} { - set rd [redis_deferring_client] - set rd2 [redis_deferring_client] + set rd [valkey_deferring_client] + set rd2 [valkey_deferring_client] $master config set appendonly yes $replica1 config set appendonly yes From 03650e91b7c72b4d0981e2b96ebf2ddf1514a21e Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Tue, 9 Apr 2024 08:21:06 -0700 Subject: [PATCH 83/98] Revert the default PID file back to the real default (#275) The default pid file is created at /var/run/redis.pid based on the code at https://github.com/valkey-io/valkey/blob/da831c0d2242251be84a5d7f14f954c6c7fa8ee8/src/server.h#L132. Until we update it, we should reflect that in the conf file. Signed-off-by: Madelyn Olson --- valkey.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/valkey.conf b/valkey.conf index 33442b340d..d3073bc21e 100644 --- a/valkey.conf +++ b/valkey.conf @@ -329,7 +329,7 @@ daemonize no # # When the server runs non daemonized, no pid file is created if none is # specified in the configuration. When the server is daemonized, the pid file -# is used even if not specified, defaulting to "/var/run/valkey.pid". +# is used even if not specified, defaulting to "/var/run/redis.pid". # # Creating a pid file is best effort: if the server is not able to create it # nothing bad happens, the server will start and run normally. From 4a8b4f422963db0df984b17dae81e32bf5cd2c5c Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Wed, 10 Apr 2024 14:59:45 +0800 Subject: [PATCH 84/98] Rename redis.info to valkey.info in LCOV (#259) Signed-off-by: Vitah Lin --- src/.gitignore | 2 +- src/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index aee7aacf09..8cd1198194 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,5 +1,5 @@ *.gcda *.gcno *.gcov -redis.info +valkey.info lcov-html diff --git a/src/Makefile b/src/Makefile index ad22fd8fad..4799fa2f58 100644 --- a/src/Makefile +++ b/src/Makefile @@ -518,8 +518,8 @@ check: test lcov: $(MAKE) gcov @(set -e; cd ..; ./runtest --clients 1) - @geninfo -o redis.info . - @genhtml --legend -o lcov-html redis.info + @geninfo -o valkey.info . + @genhtml --legend -o lcov-html valkey.info .PHONY: lcov From 05d16579e612c7670787ce3f2c3f5c91e0914afe Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Wed, 10 Apr 2024 05:03:08 -0400 Subject: [PATCH 85/98] Rename redis in valkey-cli file comments and prints (#222) Updated to Valkey in valkey-cli.c file's comments and prints. * The output of valkey-cli --help * The output of the cli built-in HELP command * The prompt in interactive valkey-cli -s unixsocket * The history file and the default rc file (changed filename) --------- Signed-off-by: Shivshankar-Reddy --- src/valkey-cli.c | 68 ++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/valkey-cli.c b/src/valkey-cli.c index cfc3fcaaff..08759896c9 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -75,9 +75,9 @@ #define REDIS_CLI_KEEPALIVE_INTERVAL 15 /* seconds */ #define REDIS_CLI_DEFAULT_PIPE_TIMEOUT 30 /* seconds */ #define REDIS_CLI_HISTFILE_ENV "REDISCLI_HISTFILE" -#define REDIS_CLI_HISTFILE_DEFAULT ".rediscli_history" +#define CLI_HISTFILE_DEFAULT ".valkeycli_history" #define REDIS_CLI_RCFILE_ENV "REDISCLI_RCFILE" -#define REDIS_CLI_RCFILE_DEFAULT ".redisclirc" +#define CLI_RCFILE_DEFAULT ".valkeyclirc" #define REDIS_CLI_AUTH_ENV "REDISCLI_AUTH" #define REDIS_CLI_CLUSTER_YES_ENV "REDISCLI_CLUSTER_YES" @@ -321,7 +321,7 @@ static void cliRefreshPrompt(void) { sds prompt = sdsempty(); if (config.hostsocket != NULL) { - prompt = sdscatfmt(prompt,"redis %s",config.hostsocket); + prompt = sdscatfmt(prompt,"valkey %s",config.hostsocket); } else { char addr[256]; formatAddr(addr, sizeof(addr), config.conn_info.hostip, config.conn_info.hostport); @@ -840,7 +840,7 @@ static size_t cliLegacyCountCommands(struct commandDocs *commands, sds version) * Stores the result in config.server_version. * When not connected, or not possible, returns NULL. */ static sds cliGetServerVersion(void) { - static const char *key = "\nredis_version:"; + static const char *key = "\nvalkey_version:"; redisReply *serverInfo = NULL; char *pos; @@ -858,7 +858,7 @@ static sds cliGetServerVersion(void) { assert(serverInfo->type == REDIS_REPLY_STRING || serverInfo->type == REDIS_REPLY_VERB); sds info = serverInfo->str; - /* Finds the first appearance of "redis_version" in the INFO SERVER reply. */ + /* Finds the first appearance of "valkey_version" in the INFO SERVER reply. */ pos = strstr(info, key); if (pos) { pos += strlen(key); @@ -954,17 +954,17 @@ static void cliOutputCommandHelp(struct commandDocs *help, int group) { static void cliOutputGenericHelp(void) { sds version = cliVersion(); printf( - "redis-cli %s\n" - "To get help about Redis commands type:\n" + "valkey-cli %s\n" + "To get help about Valkey commands type:\n" " \"help @\" to get a list of commands in \n" " \"help \" for help on \n" " \"help \" to get a list of possible help topics\n" " \"quit\" to exit\n" "\n" - "To set redis-cli preferences:\n" + "To set valkey-cli preferences:\n" " \":set hints\" enable online hints\n" " \":set nohints\" disable online hints\n" - "Set your preferences in ~/.redisclirc\n", + "Set your preferences in ~/.valkeyclirc\n", version ); sdsfree(version); @@ -1672,7 +1672,7 @@ static int cliConnect(int flags) { if (context->err) { if (!(flags & CC_QUIET)) { - fprintf(stderr,"Could not connect to Redis at "); + fprintf(stderr,"Could not connect to Valkey at "); if (config.hostsocket == NULL || (config.cluster_mode && config.cluster_reissue_command)) { @@ -2685,7 +2685,7 @@ static int parseOptions(int argc, char **argv) { } else if (!strcmp(argv[i],"--user") && !lastarg) { config.conn_info.user = sdsnew(argv[++i]); } else if (!strcmp(argv[i],"-u") && !lastarg) { - parseRedisUri(argv[++i],"redis-cli",&config.conn_info,&config.tls); + parseRedisUri(argv[++i],"valkey-cli",&config.conn_info,&config.tls); if (config.conn_info.hostport < 0 || config.conn_info.hostport > 65535) { fprintf(stderr, "Invalid server port.\n"); exit(1); @@ -3091,17 +3091,17 @@ version,tls_usage); " Use filename of \"-\" to write to stdout.\n" " --functions-rdb Like --rdb but only get the functions (not the keys)\n" " when getting the RDB dump file.\n" -" --pipe Transfer raw Redis protocol from stdin to server.\n" +" --pipe Transfer raw RESP protocol from stdin to server.\n" " --pipe-timeout In --pipe mode, abort with error if after sending all data.\n" " no reply is received within seconds.\n" " Default timeout: %d. Use 0 to wait forever.\n", REDIS_CLI_DEFAULT_PIPE_TIMEOUT); fprintf(target, -" --bigkeys Sample Redis keys looking for keys with many elements (complexity).\n" -" --memkeys Sample Redis keys looking for keys consuming a lot of memory.\n" -" --memkeys-samples Sample Redis keys looking for keys consuming a lot of memory.\n" +" --bigkeys Sample keys looking for keys with many elements (complexity).\n" +" --memkeys Sample keys looking for keys consuming a lot of memory.\n" +" --memkeys-samples Sample keys looking for keys consuming a lot of memory.\n" " And define number of key elements to sample\n" -" --hotkeys Sample Redis keys looking for hot keys.\n" +" --hotkeys Sample keys looking for hot keys.\n" " only works when maxmemory-policy is *lfu.\n" " --scan List all keys using the SCAN command.\n" " --pattern Keys pattern when using the --scan, --bigkeys or --hotkeys\n" @@ -3112,7 +3112,7 @@ version,tls_usage); " --intrinsic-latency Run a test to measure intrinsic system latency.\n" " The test will run for the specified amount of seconds.\n" " --eval Send an EVAL command using the Lua script at .\n" -" --ldb Used with --eval enable the Redis Lua debugger.\n" +" --ldb Used with --eval enable the Server Lua debugger.\n" " --ldb-sync-mode Like --ldb but uses the synchronous Lua debugger, in\n" " this mode the server is blocked and script changes are\n" " not rolled back from the server memory.\n" @@ -3238,27 +3238,27 @@ static sds *cliSplitArgs(char *line, int *argc) { } /* Set the CLI preferences. This function is invoked when an interactive - * ":command" is called, or when reading ~/.redisclirc file, in order to + * ":command" is called, or when reading ~/.valkeyclirc file, in order to * set user preferences. */ void cliSetPreferences(char **argv, int argc, int interactive) { if (!strcasecmp(argv[0],":set") && argc >= 2) { if (!strcasecmp(argv[1],"hints")) pref.hints = 1; else if (!strcasecmp(argv[1],"nohints")) pref.hints = 0; else { - printf("%sunknown redis-cli preference '%s'\n", - interactive ? "" : ".redisclirc: ", + printf("%sunknown valkey-cli preference '%s'\n", + interactive ? "" : ".valkeyclirc: ", argv[1]); } } else { - printf("%sunknown redis-cli internal command '%s'\n", - interactive ? "" : ".redisclirc: ", + printf("%sunknown valkey-cli internal command '%s'\n", + interactive ? "" : ".valkeyclirc: ", argv[0]); } } -/* Load the ~/.redisclirc file if any. */ +/* Load the ~/.valkeyclirc file if any. */ void cliLoadPreferences(void) { - sds rcfile = getDotfilePath(REDIS_CLI_RCFILE_ENV,REDIS_CLI_RCFILE_DEFAULT); + sds rcfile = getDotfilePath(REDIS_CLI_RCFILE_ENV,CLI_RCFILE_DEFAULT); if (rcfile == NULL) return; FILE *fp = fopen(rcfile,"r"); char buf[1024]; @@ -3379,7 +3379,7 @@ static void repl(void) { /* Only use history and load the rc file when stdin is a tty. */ if (isatty(fileno(stdin))) { - historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,REDIS_CLI_HISTFILE_DEFAULT); + historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,CLI_HISTFILE_DEFAULT); //keep in-memory history always regardless if history file can be determined history = 1; if (historyfile != NULL) { @@ -3424,7 +3424,7 @@ static void repl(void) { repeat = strtol(argv[0], &endptr, 10); if (argc > 1 && *endptr == '\0') { if (errno == ERANGE || errno == EINVAL || repeat <= 0) { - fputs("Invalid redis-cli repeat command option value.\n", stdout); + fputs("Invalid valkey-cli repeat command option value.\n", stdout); sdsfreesplitres(argv, argc); linenoiseFree(line); continue; @@ -4026,7 +4026,7 @@ static sds clusterManagerGetNodeRDBFilename(clusterManagerNode *node) { sds filename = sdsnew(config.cluster_manager_command.backup_dir); if (filename[sdslen(filename) - 1] != '/') filename = sdscat(filename, "/"); - filename = sdscatprintf(filename, "redis-node-%s-%d-%s.rdb", node->ip, + filename = sdscatprintf(filename, "valkey-node-%s-%d-%s.rdb", node->ip, node->port, node->name); return filename; } @@ -4102,7 +4102,7 @@ static int clusterManagerNodeConnect(clusterManagerNode *node) { } } if (node->context->err) { - fprintf(stderr,"Could not connect to Redis at "); + fprintf(stderr,"Could not connect to Valkey at "); fprintf(stderr,"%s:%d: %s\n", node->ip, node->port, node->context->errstr); redisFree(node->context); @@ -5974,7 +5974,7 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) { CLUSTER_MANAGER_CMD_FLAG_FIX_WITH_UNREACHABLE_MASTERS; if (cluster_manager.unreachable_masters > 0 && !force_fix) { - clusterManagerLogWarn("*** Fixing slots coverage with %d unreachable masters is dangerous: redis-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters); + clusterManagerLogWarn("*** Fixing slots coverage with %d unreachable masters is dangerous: valkey-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters); exit(1); } @@ -6176,7 +6176,7 @@ static int clusterManagerFixOpenSlot(int slot) { CLUSTER_MANAGER_CMD_FLAG_FIX_WITH_UNREACHABLE_MASTERS; if (cluster_manager.unreachable_masters > 0 && !force_fix) { - clusterManagerLogWarn("*** Fixing open slots with %d unreachable masters is dangerous: redis-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters); + clusterManagerLogWarn("*** Fixing open slots with %d unreachable masters is dangerous: valkey-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters); exit(1); } @@ -6487,7 +6487,7 @@ static int clusterManagerFixOpenSlot(int slot) { } else { unhandled_case: success = 0; - clusterManagerLogErr("[ERR] Sorry, redis-cli can't fix this slot " + clusterManagerLogErr("[ERR] Sorry, valkey-cli can't fix this slot " "yet (work in progress). Slot is set as " "migrating in %s, as importing in %s, " "owner is %s:%d\n", migrating_str, @@ -6942,7 +6942,7 @@ static int clusterManagerCommandCreate(int argc, char **argv) { if (masters_count < 3) { clusterManagerLogErr( "*** ERROR: Invalid configuration for cluster creation.\n" - "*** Redis Cluster requires at least 3 master nodes.\n" + "*** Valkey Cluster requires at least 3 master nodes.\n" "*** This is not possible with %d nodes and %d replicas per node.", node_len, replicas); clusterManagerLogErr("\n*** At least %d nodes are required.\n", @@ -7265,7 +7265,7 @@ static int clusterManagerCommandAddNode(int argc, char **argv) { reply = CLUSTER_MANAGER_COMMAND(refnode, "FUNCTION DUMP"); if (!clusterManagerCheckRedisReply(refnode, reply, &err)) { clusterManagerLogInfo(">>> Failed retrieving Functions from the cluster, " - "skip this step as Redis version do not support function command (error = '%s')\n", err? err : "NULL reply"); + "skip this step as Valkey version do not support function command (error = '%s')\n", err? err : "NULL reply"); if (err) zfree(err); } else { assert(reply->type == REDIS_REPLY_STRING); @@ -7919,7 +7919,7 @@ static int clusterManagerCommandImport(int argc, char **argv) { redisContext *src_ctx = redisConnectWrapper(src_ip, src_port, config.connect_timeout); if (src_ctx->err) { success = 0; - fprintf(stderr,"Could not connect to Redis at %s:%d: %s.\n", src_ip, + fprintf(stderr,"Could not connect to Valkey at %s:%d: %s.\n", src_ip, src_port, src_ctx->errstr); goto cleanup; } From a054862b72eb1761ba8102f34a60807163beffaa Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Wed, 10 Apr 2024 10:18:47 -0400 Subject: [PATCH 86/98] Rename redis_client* procedure to valkey_client* in test environment (#276) Renamed redis-client* procedure to valkey_client* Signed-off-by: Shivshankar-Reddy --- .../tests/25-pubsubshard-slot-migration.tcl | 2 +- tests/cluster/tests/26-pubsubshard.tcl | 8 +++--- tests/instances.tcl | 4 +-- tests/test_helper.tcl | 2 +- tests/unit/acl-v2.tcl | 2 +- tests/unit/client-eviction.tcl | 26 +++++++++---------- tests/unit/cluster/cli.tcl | 6 ++--- tests/unit/info.tcl | 2 +- tests/unit/introspection.tcl | 2 +- tests/unit/maxmemory.tcl | 2 +- tests/unit/moduleapi/commandfilter.tcl | 2 +- tests/unit/moduleapi/misc.tcl | 4 +-- tests/unit/multi.tcl | 18 ++++++------- tests/unit/networking.tcl | 2 +- tests/unit/pause.tcl | 6 ++--- tests/unit/querybuf.tcl | 6 ++--- tests/unit/replybufsize.tcl | 2 +- tests/unit/scripting.tcl | 6 ++--- tests/unit/tracking.tcl | 4 +-- tests/unit/type/set.tcl | 2 +- tests/unit/wait.tcl | 2 +- 21 files changed, 55 insertions(+), 55 deletions(-) diff --git a/tests/cluster/tests/25-pubsubshard-slot-migration.tcl b/tests/cluster/tests/25-pubsubshard-slot-migration.tcl index 4f8373b54d..2f6cc6fba8 100644 --- a/tests/cluster/tests/25-pubsubshard-slot-migration.tcl +++ b/tests/cluster/tests/25-pubsubshard-slot-migration.tcl @@ -147,7 +147,7 @@ test "Move a replica to another primary, verify client receives sunsubscribe on set replica_addr [get_addr_replica_serving_slot $slot] set replica_host [lindex $replica_addr 0] set replica_port [lindex $replica_addr 1] - set replica_client [redis_client_by_addr $replica_host $replica_port] + set replica_client [valkey_client_by_addr $replica_host $replica_port] set subscribeclient [valkey_deferring_client_by_addr $replica_host $replica_port] $subscribeclient deferred 1 diff --git a/tests/cluster/tests/26-pubsubshard.tcl b/tests/cluster/tests/26-pubsubshard.tcl index 422c06bf5d..aa51548ae3 100644 --- a/tests/cluster/tests/26-pubsubshard.tcl +++ b/tests/cluster/tests/26-pubsubshard.tcl @@ -13,7 +13,7 @@ test "Pub/Sub shard basics" { array set publishnode [$cluster masternode_for_slot $slot] array set notshardnode [$cluster masternode_notfor_slot $slot] - set publishclient [redis_client_by_addr $publishnode(host) $publishnode(port)] + set publishclient [valkey_client_by_addr $publishnode(host) $publishnode(port)] set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set subscribeclient2 [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set anotherclient [valkey_deferring_client_by_addr $notshardnode(host) $notshardnode(port)] @@ -57,7 +57,7 @@ test "client can subscribe to multiple shard channels across different slots in } test "sunsubscribe without specifying any channel would unsubscribe all shard channels subscribed" { - set publishclient [redis_client_by_addr $publishnode(host) $publishnode(port)] + set publishclient [valkey_client_by_addr $publishnode(host) $publishnode(port)] set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set sub_res [ssubscribe $subscribeclient [list "\{channel.0\}1" "\{channel.0\}2" "\{channel.0\}3"]] @@ -77,7 +77,7 @@ test "Verify Pub/Sub and Pub/Sub shard no overlap" { array set publishnode [$cluster masternode_for_slot $slot] array set notshardnode [$cluster masternode_notfor_slot $slot] - set publishshardclient [redis_client_by_addr $publishnode(host) $publishnode(port)] + set publishshardclient [valkey_client_by_addr $publishnode(host) $publishnode(port)] set publishclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set subscribeshardclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] @@ -112,7 +112,7 @@ test "PUBSUB channels/shardchannels" { set subscribeclient [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set subscribeclient2 [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] set subscribeclient3 [valkey_deferring_client_by_addr $publishnode(host) $publishnode(port)] - set publishclient [redis_client_by_addr $publishnode(host) $publishnode(port)] + set publishclient [valkey_client_by_addr $publishnode(host) $publishnode(port)] ssubscribe $subscribeclient [list "\{channel.0\}1"] ssubscribe $subscribeclient2 [list "\{channel.0\}2"] diff --git a/tests/instances.tcl b/tests/instances.tcl index 74e5491696..08f05aa55f 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -729,14 +729,14 @@ proc valkey_deferring_client_by_addr {host port} { return $client } -proc redis_client {type id} { +proc valkey_client {type id} { set port [get_instance_attrib $type $id port] set host [get_instance_attrib $type $id host] set client [redis $host $port 0 $::tls] return $client } -proc redis_client_by_addr {host port} { +proc valkey_client_by_addr {host port} { set client [redis $host $port 0 $::tls] return $client } diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 340fbd65e0..ff2620f6e8 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -278,7 +278,7 @@ proc valkey_deferring_client {args} { return $client } -proc redis_client {args} { +proc valkey_client {args} { set level 0 if {[llength $args] > 0 && [string is integer [lindex $args 0]]} { set level [lindex $args 0] diff --git a/tests/unit/acl-v2.tcl b/tests/unit/acl-v2.tcl index b259c27163..9827c0ba02 100644 --- a/tests/unit/acl-v2.tcl +++ b/tests/unit/acl-v2.tcl @@ -1,5 +1,5 @@ start_server {tags {"acl external:skip"}} { - set r2 [redis_client] + set r2 [valkey_client] test {Test basic multiple selectors} { r ACL SETUSER selector-1 on -@all resetkeys nopass $r2 auth selector-1 password diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index d40dc88c3f..afcdcd1323 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -20,7 +20,7 @@ proc client_exists {name} { } proc gen_client {} { - set rr [redis_client] + set rr [valkey_client] set name "tst_[randstring 4 4 simplealpha]" $rr client setname $name assert {[client_exists $name]} @@ -134,7 +134,7 @@ start_server {} { test "client evicted due to watched key list" { r flushdb - set rr [redis_client] + set rr [valkey_client] # Since watched key list is a small overhead this test uses a minimal maxmemory-clients config set temp_maxmemory_clients 200000 @@ -161,7 +161,7 @@ start_server {} { r config set maxmemory-clients $temp_maxmemory_clients # Test eviction due to pubsub patterns - set rr [redis_client] + set rr [valkey_client] # Add patterns until list maxes out maxmemory clients and causes client eviction catch { for {set j 0} {$j < $temp_maxmemory_clients} {incr j} { @@ -172,7 +172,7 @@ start_server {} { $rr close # Test eviction due to pubsub channels - set rr [redis_client] + set rr [valkey_client] # Subscribe to global channels until list maxes out maxmemory clients and causes client eviction catch { for {set j 0} {$j < $temp_maxmemory_clients} {incr j} { @@ -183,7 +183,7 @@ start_server {} { $rr close # Test eviction due to sharded pubsub channels - set rr [redis_client] + set rr [valkey_client] # Subscribe to sharded pubsub channels until list maxes out maxmemory clients and causes client eviction catch { for {set j 0} {$j < $temp_maxmemory_clients} {incr j} { @@ -199,8 +199,8 @@ start_server {} { test "client evicted due to tracking redirection" { r flushdb - set rr [redis_client] - set redirected_c [redis_client] + set rr [valkey_client] + set redirected_c [valkey_client] $redirected_c client setname redirected_client set redir_id [$redirected_c client id] $redirected_c SUBSCRIBE __redis__:invalidate @@ -232,7 +232,7 @@ start_server {} { test "client evicted due to client tracking prefixes" { r flushdb - set rr [redis_client] + set rr [valkey_client] # Since tracking prefixes list is a small overhead this test uses a minimal maxmemory-clients config set temp_maxmemory_clients 200000 @@ -323,7 +323,7 @@ start_server {} { r flushdb set obuf_size [expr {$obuf_limit + [mb 1]}] r setrange k $obuf_size v - set rr1 [redis_client] + set rr1 [valkey_client] $rr1 client setname "qbuf-client" set rr2 [valkey_deferring_client] $rr2 client setname "obuf-client1" @@ -381,7 +381,7 @@ start_server {} { # Make multiple clients consume together roughly 1mb less than maxmemory_clients set rrs {} for {set j 0} {$j < $client_count} {incr j} { - set rr [redis_client] + set rr [valkey_client] lappend rrs $rr $rr client setname client$j $rr write [join [list "*2\r\n\$$qbsize\r\n" [string repeat v $qbsize]] ""] @@ -420,7 +420,7 @@ start_server {} { set max_client_mem 0 set rrs {} for {set j 0} {$j < $client_count} {incr j} { - set rr [redis_client] + set rr [valkey_client] lappend rrs $rr $rr client setname client$j $rr write [join [list "*2\r\n\$$client_mem\r\n" [string repeat v $client_mem]] ""] @@ -486,7 +486,7 @@ start_server {} { set size [lindex $sizes $i] for {set j 0} {$j < $clients_per_size} {incr j} { - set rr [redis_client] + set rr [valkey_client] lappend rrs $rr $rr client setname client-$i $rr write [join [list "*2\r\n\$$size\r\n" [string repeat v $size]] ""] @@ -543,7 +543,7 @@ start_server {} { test "client total memory grows during $type" { r setrange k [mb 1] v - set rr [redis_client] + set rr [valkey_client] $rr client setname test_client if {$type eq "client no-evict"} { $rr client no-evict on diff --git a/tests/unit/cluster/cli.tcl b/tests/unit/cluster/cli.tcl index 948edc585d..892085747d 100644 --- a/tests/unit/cluster/cli.tcl +++ b/tests/unit/cluster/cli.tcl @@ -160,8 +160,8 @@ start_multiple_servers 3 [list overrides $base_conf] { # Test that functions are propagated on add-node start_multiple_servers 5 [list overrides $base_conf] { - set node4_rd [redis_client -3] - set node5_rd [redis_client -4] + set node4_rd [valkey_client -3] + set node5_rd [valkey_client -4] test {Functions are added to new node on valkey-cli cluster add-node} { exec src/valkey-cli --cluster-yes --cluster create \ @@ -261,7 +261,7 @@ test {Migrate the last slot away from a node using valkey-cli} { fail "Cluster doesn't stabilize" } - set newnode_r [redis_client -3] + set newnode_r [valkey_client -3] set newnode_id [$newnode_r CLUSTER MYID] # Find out which node has the key "foo" by asking the new node for a diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index b62ca86d77..17dc6a1861 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -424,7 +424,7 @@ start_server {tags {"info" "external:skip"}} { } test {clients: watching clients} { - set r2 [redis_client] + set r2 [valkey_client] assert_equal [s watching_clients] 0 assert_equal [s total_watched_keys] 0 assert_match {*watch=0*} [r client info] diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 9ec8bb07b4..8341fd95e2 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -667,7 +667,7 @@ start_server {tags {"introspection"}} { } # Make sure we can still communicate with the server (on the original port) - set r1 [redis_client] + set r1 [valkey_client] assert_equal [$r1 ping] "PONG" $r1 close } diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl index 109707d1c6..19b05cc9cb 100644 --- a/tests/unit/maxmemory.tcl +++ b/tests/unit/maxmemory.tcl @@ -114,7 +114,7 @@ start_server {tags {"maxmemory" "external:skip"}} { init_test $client_eviction for {set j 0} {$j < 20} {incr j} { - set rr [redis_client] + set rr [valkey_client] lappend clients $rr } diff --git a/tests/unit/moduleapi/commandfilter.tcl b/tests/unit/moduleapi/commandfilter.tcl index 52bd6f1cb0..bad68189a0 100644 --- a/tests/unit/moduleapi/commandfilter.tcl +++ b/tests/unit/moduleapi/commandfilter.tcl @@ -148,7 +148,7 @@ test {Filtering based on client id} { start_server {tags {"modules"}} { r module load $testmodule log-key 0 - set rr [redis_client] + set rr [valkey_client] set cid [$rr client id] r unfilter_clientid $cid diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index 7bee0ea2b5..559ed61aaf 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -119,7 +119,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { } test {tracking with rm_call sanity} { - set rd_trk [redis_client] + set rd_trk [valkey_client] $rd_trk HELLO 3 $rd_trk CLIENT TRACKING on r MSET key1{t} 1 key2{t} 1 @@ -134,7 +134,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { } test {tracking with rm_call with script} { - set rd_trk [redis_client] + set rd_trk [valkey_client] $rd_trk HELLO 3 $rd_trk CLIENT TRACKING on r MSET key1{t} 1 key2{t} 1 diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 16915fef3b..0e2e74c2b6 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -1,5 +1,5 @@ proc wait_for_dbsize {size} { - set r2 [redis_client] + set r2 [valkey_client] wait_for_condition 50 100 { [$r2 dbsize] == $size } else { @@ -540,7 +540,7 @@ start_server {tags {"multi"}} { # check that if MULTI arrives during timeout, it is either refused, or # allowed to pass, and we don't end up executing half of the transaction set rd1 [valkey_deferring_client] - set r2 [redis_client] + set r2 [valkey_client] r config set lua-time-limit 10 r set xx 1 $rd1 eval {while true do end} 0 @@ -565,7 +565,7 @@ start_server {tags {"multi"}} { # check that if EXEC arrives during timeout, we don't end up executing # half of the transaction, and also that we exit the multi state set rd1 [valkey_deferring_client] - set r2 [redis_client] + set r2 [valkey_client] r config set lua-time-limit 10 r set xx 1 catch { $r2 multi; } e @@ -590,7 +590,7 @@ start_server {tags {"multi"}} { # check that we don't run an incomplete transaction due to some commands # arriving during busy script set rd1 [valkey_deferring_client] - set r2 [redis_client] + set r2 [valkey_client] r config set lua-time-limit 10 r set xx 1 catch { $r2 multi; } e @@ -615,7 +615,7 @@ start_server {tags {"multi"}} { # check that if EXEC arrives during timeout, we don't end up executing # actual commands during busy script, and also that we exit the multi state set rd1 [valkey_deferring_client] - set r2 [redis_client] + set r2 [valkey_client] r config set lua-time-limit 10 r set xx 1 catch { $r2 multi; } e @@ -637,7 +637,7 @@ start_server {tags {"multi"}} { test {exec with write commands and state change} { # check that exec that contains write commands fails if server state changed since they were queued - set r1 [redis_client] + set r1 [valkey_client] r set xx 1 r multi r incr xx @@ -654,7 +654,7 @@ start_server {tags {"multi"}} { test {exec with read commands and stale replica state change} { # check that exec that contains read commands fails if server state changed since they were queued r config set replica-serve-stale-data no - set r1 [redis_client] + set r1 [valkey_client] r set xx 1 # check that GET and PING are disallowed on stale replica, even if the replica becomes stale only after queuing. @@ -685,7 +685,7 @@ start_server {tags {"multi"}} { } {0} {needs:repl cluster:skip} test {EXEC with only read commands should not be rejected when OOM} { - set r2 [redis_client] + set r2 [valkey_client] r set x value r multi @@ -704,7 +704,7 @@ start_server {tags {"multi"}} { } {0} {needs:config-maxmemory} test {EXEC with at least one use-memory command should fail} { - set r2 [redis_client] + set r2 [valkey_client] r multi r set x 1 diff --git a/tests/unit/networking.tcl b/tests/unit/networking.tcl index 5224fa00a6..2a8694d437 100644 --- a/tests/unit/networking.tcl +++ b/tests/unit/networking.tcl @@ -109,7 +109,7 @@ start_server {config "minimal.conf" tags {"external:skip"}} { assert_equal "" [lindex [r CONFIG GET bind] 1] # No additional clients can connect - catch {redis_client} err + catch {valkey_client} err assert_match {*connection refused*} $err # CONFIG REWRITE handles empty bindaddr diff --git a/tests/unit/pause.tcl b/tests/unit/pause.tcl index d27f5775c4..3698e9e064 100644 --- a/tests/unit/pause.tcl +++ b/tests/unit/pause.tcl @@ -86,7 +86,7 @@ start_server {tags {"pause network"}} { test "Test read/admin multi-execs are not blocked by pause RO" { r SET FOO BAR r client PAUSE 100000 WRITE - set rr [redis_client] + set rr [valkey_client] assert_equal [$rr MULTI] "OK" assert_equal [$rr PING] "QUEUED" assert_equal [$rr GET FOO] "QUEUED" @@ -141,7 +141,7 @@ start_server {tags {"pause network"}} { } r client PAUSE 6000000 WRITE - set rr [redis_client] + set rr [valkey_client] # test an eval that's for sure not in the script cache assert_equal [$rr EVAL {#!lua flags=no-writes @@ -177,7 +177,7 @@ start_server {tags {"pause network"}} { test "Test read-only scripts in multi-exec are not blocked by pause RO" { r SET FOO BAR r client PAUSE 100000 WRITE - set rr [redis_client] + set rr [valkey_client] assert_equal [$rr MULTI] "OK" assert_equal [$rr EVAL {#!lua flags=no-writes return 12 diff --git a/tests/unit/querybuf.tcl b/tests/unit/querybuf.tcl index f4859dd278..27a94604a2 100644 --- a/tests/unit/querybuf.tcl +++ b/tests/unit/querybuf.tcl @@ -24,7 +24,7 @@ start_server {tags {"querybuf slow"}} { # The test will run at least 2s to check if client query # buffer will be resized when client idle 2s. test "query buffer resized correctly" { - set rd [redis_client] + set rd [valkey_client] $rd client setname test_client set orig_test_client_qbuf [client_query_buffer test_client] # Make sure query buff has less than the peak resize threshold (PROTO_RESIZE_THRESHOLD) 32k @@ -45,7 +45,7 @@ start_server {tags {"querybuf slow"}} { r debug pause-cron 1 # Memory will increase by more than 32k due to client query buffer. - set rd [redis_client] + set rd [valkey_client] $rd client setname test_client # Create a large query buffer (more than PROTO_RESIZE_THRESHOLD - 32k) @@ -73,7 +73,7 @@ start_server {tags {"querybuf slow"}} { } {0} {needs:debug} test "query buffer resized correctly with fat argv" { - set rd [redis_client] + set rd [valkey_client] $rd client setname test_client $rd write "*3\r\n\$3\r\nset\r\n\$1\r\na\r\n\$1000000\r\n" $rd flush diff --git a/tests/unit/replybufsize.tcl b/tests/unit/replybufsize.tcl index 933189eb33..ae3b914ea6 100644 --- a/tests/unit/replybufsize.tcl +++ b/tests/unit/replybufsize.tcl @@ -15,7 +15,7 @@ start_server {tags {"replybufsize"}} { r debug replybuffer peak-reset-time 100 # Create a simple idle test client - variable tc [redis_client] + variable tc [valkey_client] $tc client setname test_client # make sure the client is idle for 1 seconds to make it shrink the reply buffer diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 65927dffa6..c365f09c82 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -1242,7 +1242,7 @@ start_server {tags {"scripting"}} { # create clients, and set one to block waiting for key 'x' set rd [valkey_deferring_client] set rd2 [valkey_deferring_client] - set r3 [redis_client] + set r3 [valkey_client] $rd2 blpop x 0 wait_for_blocked_clients_count 1 @@ -2058,8 +2058,8 @@ start_server {tags {"scripting"}} { # temporarily set the server to master, so it doesn't block the queuing # and we can test the evaluation of the flags on exec r replicaof no one - set rr [redis_client] - set rr2 [redis_client] + set rr [valkey_client] + set rr2 [valkey_client] $rr multi $rr2 multi diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl index 427cc580dd..313293dcb7 100644 --- a/tests/unit/tracking.tcl +++ b/tests/unit/tracking.tcl @@ -14,7 +14,7 @@ start_server {tags {"tracking network logreqres:skip"}} { # Client to be used for SET and GET commands # We don't read this client's buffer - set rd_sg [redis_client] + set rd_sg [valkey_client] proc clean_all {} { uplevel { @@ -396,7 +396,7 @@ start_server {tags {"tracking network logreqres:skip"}} { } test {BCAST with prefix collisions throw errors} { - set r [redis_client] + set r [valkey_client] catch {$r CLIENT TRACKING ON BCAST PREFIX FOOBAR PREFIX FOO} output assert_match {ERR Prefix 'FOOBAR'*'FOO'*} $output diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl index c194ee278d..944c3d3d98 100644 --- a/tests/unit/type/set.tcl +++ b/tests/unit/type/set.tcl @@ -1224,7 +1224,7 @@ foreach type {single multiple single_multiple} { r multi r sadd dstset{t} c - set r2 [redis_client] + set r2 [valkey_client] $r2 smove srcset{t} dstset{t} a # The dstset is actually unchanged, multi should success diff --git a/tests/unit/wait.tcl b/tests/unit/wait.tcl index dfd0be7483..6b85bc8416 100644 --- a/tests/unit/wait.tcl +++ b/tests/unit/wait.tcl @@ -353,7 +353,7 @@ tags {"wait aof network external:skip"} { test {WAITAOF master client didn't send any write command} { $master config set repl-ping-replica-period 1 - set client [redis_client -1] + set client [valkey_client -1] after 1200 ;# wait for PING assert_equal [$master waitaof 1 1 0] {1 1} $client close From f8cec23a9bb1f2dd68c761f1598c4bfff99c632d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Wed, 10 Apr 2024 18:14:58 +0200 Subject: [PATCH 87/98] Delete old deprecated cli program redis-trib (#281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Actually, this script doesn't do anything except printing that it is replaced by redis-cli. Signed-off-by: Viktor Söderqvist --- src/redis-trib.rb | 129 ----------------------- tests/cluster/tests/helpers/onlydots.tcl | 4 +- 2 files changed, 2 insertions(+), 131 deletions(-) delete mode 100755 src/redis-trib.rb diff --git a/src/redis-trib.rb b/src/redis-trib.rb deleted file mode 100755 index b1af83069b..0000000000 --- a/src/redis-trib.rb +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env ruby - -def colorized(str, color) - return str if !(ENV['TERM'] || '')["xterm"] - color_code = { - white: 29, - bold: '29;1', - black: 30, - red: 31, - green: 32, - yellow: 33, - blue: 34, - magenta: 35, - cyan: 36, - gray: 37 - }[color] - return str if !color_code - "\033[#{color_code}m#{str}\033[0m" -end - -class String - - %w(white bold black red green yellow blue magenta cyan gray).each{|color| - color = :"#{color}" - define_method(color){ - colorized(self, color) - } - } - -end - -COMMANDS = %w(create check info fix reshard rebalance add-node - del-node set-timeout call import help) - -ALLOWED_OPTIONS={ - "create" => {"replicas" => true}, - "add-node" => {"slave" => false, "master-id" => true}, - "import" => {"from" => :required, "copy" => false, "replace" => false}, - "reshard" => {"from" => true, "to" => true, "slots" => true, "yes" => false, "timeout" => true, "pipeline" => true}, - "rebalance" => {"weight" => [], "auto-weights" => false, "use-empty-masters" => false, "timeout" => true, "simulate" => false, "pipeline" => true, "threshold" => true}, - "fix" => {"timeout" => 0}, -} - -def parse_options(cmd) - cmd = cmd.downcase - idx = 0 - options = {} - args = [] - while (arg = ARGV.shift) - if arg[0..1] == "--" - option = arg[2..-1] - - # --verbose is a global option - if option == "--verbose" - options['verbose'] = true - next - end - if ALLOWED_OPTIONS[cmd] == nil || - ALLOWED_OPTIONS[cmd][option] == nil - next - end - if ALLOWED_OPTIONS[cmd][option] != false - value = ARGV.shift - next if !value - else - value = true - end - - # If the option is set to [], it's a multiple arguments - # option. We just queue every new value into an array. - if ALLOWED_OPTIONS[cmd][option] == [] - options[option] = [] if !options[option] - options[option] << value - else - options[option] = value - end - else - next if arg[0,1] == '-' - args << arg - end - end - - return options,args -end - -def command_example(cmd, args, opts) - cmd = "redis-cli --cluster #{cmd}" - args.each{|a| - a = a.to_s - a = a.inspect if a[' '] - cmd << " #{a}" - } - opts.each{|opt, val| - opt = " --cluster-#{opt.downcase}" - if val != true - val = val.join(' ') if val.is_a? Array - opt << " #{val}" - end - cmd << opt - } - cmd -end - -$command = ARGV.shift -$opts, $args = parse_options($command) if $command - -puts "WARNING: redis-trib.rb is not longer available!".yellow -puts "You should use #{'redis-cli'.bold} instead." -puts '' -puts "All commands and features belonging to redis-trib.rb "+ - "have been moved\nto redis-cli." -puts "In order to use them you should call redis-cli with the #{'--cluster'.bold}" -puts "option followed by the subcommand name, arguments and options." -puts '' -puts "Use the following syntax:" -puts "redis-cli --cluster SUBCOMMAND [ARGUMENTS] [OPTIONS]".bold -puts '' -puts "Example:" -if $command - example = command_example $command, $args, $opts -else - example = "redis-cli --cluster info 127.0.0.1:7000" -end -puts example.bold -puts '' -puts "To get help about all subcommands, type:" -puts "redis-cli --cluster help".bold -puts '' -exit 1 diff --git a/tests/cluster/tests/helpers/onlydots.tcl b/tests/cluster/tests/helpers/onlydots.tcl index 4a6d1aee08..0d69ef1b43 100644 --- a/tests/cluster/tests/helpers/onlydots.tcl +++ b/tests/cluster/tests/helpers/onlydots.tcl @@ -1,7 +1,7 @@ # Read the standard input and only shows dots in the output, filtering out # all the other characters. Designed to avoid bufferization so that when -# we get the output of redis-trib and want to show just the dots, we'll see -# the dots as soon as redis-trib will output them. +# we get the output of a program and want to show just the dots, we'll see +# the dots as soon as the program outputs them. fconfigure stdin -buffering none From 2e460466257c088d5d7f56b58ed7158d38a9ffb2 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Wed, 10 Apr 2024 16:50:52 -0400 Subject: [PATCH 88/98] Rename macros in valkey-cli.c and redis_strlcpy to valkey (#284) Signed-off-by: Shivshankar-Reddy --- src/anet.c | 4 ++-- src/cluster_legacy.c | 4 ++-- src/config.c | 2 +- src/fmacros.h | 2 +- src/module.c | 4 ++-- src/rdb.c | 2 +- src/strl.c | 2 +- src/util.c | 48 ++++++++++++++++++++++---------------------- src/util.h | 2 +- src/valkey-cli.c | 46 +++++++++++++++++++++--------------------- 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/anet.c b/src/anet.c index 0a05fb5624..8349895ccc 100644 --- a/src/anet.c +++ b/src/anet.c @@ -501,7 +501,7 @@ int anetUnixGenericConnect(char *err, const char *path, int flags) return ANET_ERR; sa.sun_family = AF_LOCAL; - redis_strlcpy(sa.sun_path,path,sizeof(sa.sun_path)); + valkey_strlcpy(sa.sun_path,path,sizeof(sa.sun_path)); if (flags & ANET_CONNECT_NONBLOCK) { if (anetNonBlock(err,s) != ANET_OK) { close(s); @@ -613,7 +613,7 @@ int anetUnixServer(char *err, char *path, mode_t perm, int backlog) memset(&sa,0,sizeof(sa)); sa.sun_family = AF_LOCAL; - redis_strlcpy(sa.sun_path,path,sizeof(sa.sun_path)); + valkey_strlcpy(sa.sun_path,path,sizeof(sa.sun_path)); if (anetListen(err,s,(struct sockaddr*)&sa,sizeof(sa),backlog,perm) == ANET_ERR) return ANET_ERR; return s; diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 01c531aaa0..843e6299c9 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -883,7 +883,7 @@ void clusterUpdateMyselfIp(void) { * duplicating the string. This way later we can check if * the address really changed. */ prev_ip = zstrdup(prev_ip); - redis_strlcpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN); + valkey_strlcpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN); } else { myself->ip[0] = '\0'; /* Force autodetection. */ } @@ -3526,7 +3526,7 @@ static void clusterBuildMessageHdr(clusterMsg *hdr, int type, size_t msglen) { * first byte is zero, they'll do auto discovery. */ memset(hdr->myip,0,NET_IP_STR_LEN); if (server.cluster_announce_ip) { - redis_strlcpy(hdr->myip,server.cluster_announce_ip,NET_IP_STR_LEN); + valkey_strlcpy(hdr->myip,server.cluster_announce_ip,NET_IP_STR_LEN); } /* Handle cluster-announce-[tls-|bus-]port. */ diff --git a/src/config.c b/src/config.c index 588a35cf86..d3da3f94e5 100644 --- a/src/config.c +++ b/src/config.c @@ -1997,7 +1997,7 @@ static int enumConfigSet(standardConfig *config, sds *argv, int argc, const char } sdsrange(enumerr,0,-3); /* Remove final ", ". */ - redis_strlcpy(loadbuf, enumerr, LOADBUF_SIZE); + valkey_strlcpy(loadbuf, enumerr, LOADBUF_SIZE); sdsfree(enumerr); *err = loadbuf; diff --git a/src/fmacros.h b/src/fmacros.h index c5da4b7345..e629d1be2f 100644 --- a/src/fmacros.h +++ b/src/fmacros.h @@ -64,7 +64,7 @@ * will error on stdlib definitions in files as well*/ #if (__GNUC__ && __GNUC__ >= 4) && !defined __APPLE__ int sprintf(char *str, const char *format, ...) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of snprintf instead"))); -char *strcpy(char *restrict dest, const char *src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redis_strlcpy instead"))); +char *strcpy(char *restrict dest, const char *src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of valkey_strlcpy instead"))); char *strcat(char *restrict dest, const char *restrict src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redis_strlcat instead"))); #endif diff --git a/src/module.c b/src/module.c index d43feba28f..961525b58e 100644 --- a/src/module.c +++ b/src/module.c @@ -9056,7 +9056,7 @@ int VM_GetClusterNodeInfo(ValkeyModuleCtx *ctx, const char *id, char *ip, char * return VALKEYMODULE_ERR; } - if (ip) redis_strlcpy(ip, clusterNodeIp(node),NET_IP_STR_LEN); + if (ip) valkey_strlcpy(ip, clusterNodeIp(node),NET_IP_STR_LEN); if (master_id) { /* If the information is not available, the function will set the @@ -12627,7 +12627,7 @@ int moduleVerifyResourceName(const char *name) { static char configerr[CONFIG_ERR_SIZE]; static void propagateErrorString(ValkeyModuleString *err_in, const char **err) { if (err_in) { - redis_strlcpy(configerr, err_in->ptr, CONFIG_ERR_SIZE); + valkey_strlcpy(configerr, err_in->ptr, CONFIG_ERR_SIZE); decrRefCount(err_in); *err = configerr; } diff --git a/src/rdb.c b/src/rdb.c index 22dd658e18..0bf4513247 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1614,7 +1614,7 @@ void rdbRemoveTempFile(pid_t childpid, int from_signal) { /* Generate temp rdb file name using async-signal safe functions. */ ll2string(pid, sizeof(pid), childpid); - redis_strlcpy(tmpfile, "temp-", sizeof(tmpfile)); + valkey_strlcpy(tmpfile, "temp-", sizeof(tmpfile)); redis_strlcat(tmpfile, pid, sizeof(tmpfile)); redis_strlcat(tmpfile, ".rdb", sizeof(tmpfile)); diff --git a/src/strl.c b/src/strl.c index f73cf796c2..e36faaab64 100644 --- a/src/strl.c +++ b/src/strl.c @@ -21,7 +21,7 @@ * Returns strlen(src); if retval >= dsize, truncation occurred. */ size_t -redis_strlcpy(char *dst, const char *src, size_t dsize) +valkey_strlcpy(char *dst, const char *src, size_t dsize) { const char *osrc = src; size_t nleft = dsize; diff --git a/src/util.c b/src/util.c index b5ef5ea2b4..00e774209f 100644 --- a/src/util.c +++ b/src/util.c @@ -1385,53 +1385,53 @@ static void test_string2ll(void) { long long v; /* May not start with +. */ - redis_strlcpy(buf,"+1",sizeof(buf)); + valkey_strlcpy(buf,"+1",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 0); /* Leading space. */ - redis_strlcpy(buf," 1",sizeof(buf)); + valkey_strlcpy(buf," 1",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 0); /* Trailing space. */ - redis_strlcpy(buf,"1 ",sizeof(buf)); + valkey_strlcpy(buf,"1 ",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 0); /* May not start with 0. */ - redis_strlcpy(buf,"01",sizeof(buf)); + valkey_strlcpy(buf,"01",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 0); - redis_strlcpy(buf,"-1",sizeof(buf)); + valkey_strlcpy(buf,"-1",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == -1); - redis_strlcpy(buf,"0",sizeof(buf)); + valkey_strlcpy(buf,"0",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == 0); - redis_strlcpy(buf,"1",sizeof(buf)); + valkey_strlcpy(buf,"1",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == 1); - redis_strlcpy(buf,"99",sizeof(buf)); + valkey_strlcpy(buf,"99",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == 99); - redis_strlcpy(buf,"-99",sizeof(buf)); + valkey_strlcpy(buf,"-99",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == -99); - redis_strlcpy(buf,"-9223372036854775808",sizeof(buf)); + valkey_strlcpy(buf,"-9223372036854775808",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == LLONG_MIN); - redis_strlcpy(buf,"-9223372036854775809",sizeof(buf)); /* overflow */ + valkey_strlcpy(buf,"-9223372036854775809",sizeof(buf)); /* overflow */ assert(string2ll(buf,strlen(buf),&v) == 0); - redis_strlcpy(buf,"9223372036854775807",sizeof(buf)); + valkey_strlcpy(buf,"9223372036854775807",sizeof(buf)); assert(string2ll(buf,strlen(buf),&v) == 1); assert(v == LLONG_MAX); - redis_strlcpy(buf,"9223372036854775808",sizeof(buf)); /* overflow */ + valkey_strlcpy(buf,"9223372036854775808",sizeof(buf)); /* overflow */ assert(string2ll(buf,strlen(buf),&v) == 0); } @@ -1440,46 +1440,46 @@ static void test_string2l(void) { long v; /* May not start with +. */ - redis_strlcpy(buf,"+1",sizeof(buf)); + valkey_strlcpy(buf,"+1",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 0); /* May not start with 0. */ - redis_strlcpy(buf,"01",sizeof(buf)); + valkey_strlcpy(buf,"01",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 0); - redis_strlcpy(buf,"-1",sizeof(buf)); + valkey_strlcpy(buf,"-1",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == -1); - redis_strlcpy(buf,"0",sizeof(buf)); + valkey_strlcpy(buf,"0",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == 0); - redis_strlcpy(buf,"1",sizeof(buf)); + valkey_strlcpy(buf,"1",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == 1); - redis_strlcpy(buf,"99",sizeof(buf)); + valkey_strlcpy(buf,"99",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == 99); - redis_strlcpy(buf,"-99",sizeof(buf)); + valkey_strlcpy(buf,"-99",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == -99); #if LONG_MAX != LLONG_MAX - redis_strlcpy(buf,"-2147483648",sizeof(buf)); + valkey_strlcpy(buf,"-2147483648",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == LONG_MIN); - redis_strlcpy(buf,"-2147483649",sizeof(buf)); /* overflow */ + valkey_strlcpy(buf,"-2147483649",sizeof(buf)); /* overflow */ assert(string2l(buf,strlen(buf),&v) == 0); - redis_strlcpy(buf,"2147483647",sizeof(buf)); + valkey_strlcpy(buf,"2147483647",sizeof(buf)); assert(string2l(buf,strlen(buf),&v) == 1); assert(v == LONG_MAX); - redis_strlcpy(buf,"2147483648",sizeof(buf)); /* overflow */ + valkey_strlcpy(buf,"2147483648",sizeof(buf)); /* overflow */ assert(string2l(buf,strlen(buf),&v) == 0); #endif } diff --git a/src/util.h b/src/util.h index 727a7a909c..79fe743f43 100644 --- a/src/util.h +++ b/src/util.h @@ -97,7 +97,7 @@ int snprintf_async_signal_safe(char *to, size_t n, const char *fmt, ...) #else int snprintf_async_signal_safe(char *to, size_t n, const char *fmt, ...); #endif -size_t redis_strlcpy(char *dst, const char *src, size_t dsize); +size_t valkey_strlcpy(char *dst, const char *src, size_t dsize); size_t redis_strlcat(char *dst, const char *src, size_t dsize); #ifdef SERVER_TEST diff --git a/src/valkey-cli.c b/src/valkey-cli.c index 08759896c9..f905100cd0 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -72,14 +72,14 @@ #define OUTPUT_CSV 2 #define OUTPUT_JSON 3 #define OUTPUT_QUOTED_JSON 4 -#define REDIS_CLI_KEEPALIVE_INTERVAL 15 /* seconds */ -#define REDIS_CLI_DEFAULT_PIPE_TIMEOUT 30 /* seconds */ -#define REDIS_CLI_HISTFILE_ENV "REDISCLI_HISTFILE" +#define CLI_KEEPALIVE_INTERVAL 15 /* seconds */ +#define CLI_DEFAULT_PIPE_TIMEOUT 30 /* seconds */ +#define CLI_HISTFILE_ENV "REDISCLI_HISTFILE" #define CLI_HISTFILE_DEFAULT ".valkeycli_history" -#define REDIS_CLI_RCFILE_ENV "REDISCLI_RCFILE" +#define CLI_RCFILE_ENV "REDISCLI_RCFILE" #define CLI_RCFILE_DEFAULT ".valkeyclirc" -#define REDIS_CLI_AUTH_ENV "REDISCLI_AUTH" -#define REDIS_CLI_CLUSTER_YES_ENV "REDISCLI_CLUSTER_YES" +#define CLI_AUTH_ENV "REDISCLI_AUTH" +#define CLI_CLUSTER_YES_ENV "REDISCLI_CLUSTER_YES" #define CLUSTER_MANAGER_SLOTS 16384 #define CLUSTER_MANAGER_PORT_INCR 10000 /* same as CLUSTER_PORT_INCR */ @@ -296,7 +296,7 @@ static long getLongInfoField(char *info, char *field); /*------------------------------------------------------------------------------ * Utility functions *--------------------------------------------------------------------------- */ -size_t redis_strlcpy(char *dst, const char *src, size_t dsize); +size_t valkey_strlcpy(char *dst, const char *src, size_t dsize); static void cliPushHandler(void *, void *); @@ -1693,7 +1693,7 @@ static int cliConnect(int flags) { * in order to prevent timeouts caused by the execution of long * commands. At the same time this improves the detection of real * errors. */ - anetKeepAlive(NULL, context->fd, REDIS_CLI_KEEPALIVE_INTERVAL); + anetKeepAlive(NULL, context->fd, CLI_KEEPALIVE_INTERVAL); /* State of the current connection. */ config.current_resp3 = 0; @@ -2985,12 +2985,12 @@ static int parseOptions(int argc, char **argv) { static void parseEnv(void) { /* Set auth from env, but do not overwrite CLI arguments if passed */ - char *auth = getenv(REDIS_CLI_AUTH_ENV); + char *auth = getenv(CLI_AUTH_ENV); if (auth != NULL && config.conn_info.auth == NULL) { config.conn_info.auth = auth; } - char *cluster_yes = getenv(REDIS_CLI_CLUSTER_YES_ENV); + char *cluster_yes = getenv(CLI_CLUSTER_YES_ENV); if (cluster_yes != NULL && !strcmp(cluster_yes, "1")) { config.cluster_manager_command.flags |= CLUSTER_MANAGER_CMD_FLAG_YES; } @@ -3032,13 +3032,13 @@ static void usage(int err) { " Default timeout is 0, meaning no limit, depending on the OS.\n" " -s Server socket (overrides hostname and port).\n" " -a Password to use when connecting to the server.\n" -" You can also use the " REDIS_CLI_AUTH_ENV " environment\n" +" You can also use the " CLI_AUTH_ENV " environment\n" " variable to pass this password more safely\n" " (if both are used, this argument takes precedence).\n" " --user Used to send ACL style 'AUTH username pass'. Needs -a.\n" " --pass Alias of -a for consistency with the new --user option.\n" " --askpass Force user to input password with mask from STDIN.\n" -" If this argument is used, '-a' and " REDIS_CLI_AUTH_ENV "\n" +" If this argument is used, '-a' and " CLI_AUTH_ENV "\n" " environment variable will be ignored.\n" " -u Server URI on format redis://user:password@host:port/dbnum\n" " User, password and dbnum are optional. For authentication\n" @@ -3095,7 +3095,7 @@ version,tls_usage); " --pipe-timeout In --pipe mode, abort with error if after sending all data.\n" " no reply is received within seconds.\n" " Default timeout: %d. Use 0 to wait forever.\n", - REDIS_CLI_DEFAULT_PIPE_TIMEOUT); + CLI_DEFAULT_PIPE_TIMEOUT); fprintf(target, " --bigkeys Sample keys looking for keys with many elements (complexity).\n" " --memkeys Sample keys looking for keys consuming a lot of memory.\n" @@ -3258,7 +3258,7 @@ void cliSetPreferences(char **argv, int argc, int interactive) { /* Load the ~/.valkeyclirc file if any. */ void cliLoadPreferences(void) { - sds rcfile = getDotfilePath(REDIS_CLI_RCFILE_ENV,CLI_RCFILE_DEFAULT); + sds rcfile = getDotfilePath(CLI_RCFILE_ENV,CLI_RCFILE_DEFAULT); if (rcfile == NULL) return; FILE *fp = fopen(rcfile,"r"); char buf[1024]; @@ -3379,7 +3379,7 @@ static void repl(void) { /* Only use history and load the rc file when stdin is a tty. */ if (isatty(fileno(stdin))) { - historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,CLI_HISTFILE_DEFAULT); + historyfile = getDotfilePath(CLI_HISTFILE_ENV,CLI_HISTFILE_DEFAULT); //keep in-memory history always regardless if history file can be determined history = 1; if (historyfile != NULL) { @@ -4043,7 +4043,7 @@ static int clusterManagerCheckRedisReply(clusterManagerNode *n, if (is_err) { if (err != NULL) { *err = zmalloc((r->len + 1) * sizeof(char)); - redis_strlcpy(*err, r->str,(r->len + 1)); + valkey_strlcpy(*err, r->str,(r->len + 1)); } else CLUSTER_MANAGER_PRINT_REPLY_ERROR(n, r->str); } return 0; @@ -4113,7 +4113,7 @@ static int clusterManagerNodeConnect(clusterManagerNode *node) { * in order to prevent timeouts caused by the execution of long * commands. At the same time this improves the detection of real * errors. */ - anetKeepAlive(NULL, node->context->fd, REDIS_CLI_KEEPALIVE_INTERVAL); + anetKeepAlive(NULL, node->context->fd, CLI_KEEPALIVE_INTERVAL); if (config.conn_info.auth) { redisReply *reply; if (config.conn_info.user == NULL) @@ -4203,7 +4203,7 @@ static redisReply *clusterManagerGetNodeRedisInfo(clusterManagerNode *node, if (info->type == REDIS_REPLY_ERROR) { if (err != NULL) { *err = zmalloc((info->len + 1) * sizeof(char)); - redis_strlcpy(*err, info->str,(info->len + 1)); + valkey_strlcpy(*err, info->str,(info->len + 1)); } freeReplyObject(info); return NULL; @@ -4780,7 +4780,7 @@ static int clusterManagerSetSlot(clusterManagerNode *node1, success = 0; if (err != NULL) { *err = zmalloc((reply->len + 1) * sizeof(char)); - redis_strlcpy(*err, reply->str,(reply->len + 1)); + valkey_strlcpy(*err, reply->str,(reply->len + 1)); } else CLUSTER_MANAGER_PRINT_REPLY_ERROR(node1, reply->str); goto cleanup; } @@ -5054,7 +5054,7 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source, success = 0; if (err != NULL) { *err = zmalloc((reply->len + 1) * sizeof(char)); - redis_strlcpy(*err, reply->str,(reply->len + 1)); + valkey_strlcpy(*err, reply->str,(reply->len + 1)); CLUSTER_MANAGER_PRINT_REPLY_ERROR(source, *err); } goto next; @@ -5166,7 +5166,7 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source, if (migrate_reply != NULL) { if (err) { *err = zmalloc((migrate_reply->len + 1) * sizeof(char)); - redis_strlcpy(*err, migrate_reply->str, (migrate_reply->len + 1)); + valkey_strlcpy(*err, migrate_reply->str, (migrate_reply->len + 1)); } printf("\n"); CLUSTER_MANAGER_PRINT_REPLY_ERROR(source, @@ -5283,7 +5283,7 @@ static int clusterManagerFlushNodeConfig(clusterManagerNode *node, char **err) { if (reply == NULL || (is_err = (reply->type == REDIS_REPLY_ERROR))) { if (is_err && err != NULL) { *err = zmalloc((reply->len + 1) * sizeof(char)); - redis_strlcpy(*err, reply->str, (reply->len + 1)); + valkey_strlcpy(*err, reply->str, (reply->len + 1)); } success = 0; /* If the cluster did not already joined it is possible that @@ -9881,7 +9881,7 @@ int main(int argc, char **argv) { config.pattern = NULL; config.rdb_filename = NULL; config.pipe_mode = 0; - config.pipe_timeout = REDIS_CLI_DEFAULT_PIPE_TIMEOUT; + config.pipe_timeout = CLI_DEFAULT_PIPE_TIMEOUT; config.bigkeys = 0; config.memkeys = 0; config.hotkeys = 0; From b669af0eabe602850fc02f0cdc452ce071f9adda Mon Sep 17 00:00:00 2001 From: Daniel House <76451671+daniel-house@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:00:27 -0400 Subject: [PATCH 89/98] Rename 'redis_tls_ctx' and 'redis_tls_client_ctx' global variables (#268) Signed-off-by: Daniel House Signed-off-by: daniel-house Co-authored-by: Daniel House --- src/sentinel.c | 8 ++++---- src/tls.c | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/sentinel.c b/src/sentinel.c index ad2ebdd510..ac1039b2ee 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -45,8 +45,8 @@ extern char **environ; #if USE_OPENSSL == 1 /* BUILD_YES */ -extern SSL_CTX *redis_tls_ctx; -extern SSL_CTX *redis_tls_client_ctx; +extern SSL_CTX *valkey_tls_ctx; +extern SSL_CTX *valkey_tls_client_ctx; #endif #define REDIS_SENTINEL_PORT 26379 @@ -2377,8 +2377,8 @@ void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char static int instanceLinkNegotiateTLS(redisAsyncContext *context) { #if USE_OPENSSL == 1 /* BUILD_YES */ - if (!redis_tls_ctx) return C_ERR; - SSL *ssl = SSL_new(redis_tls_client_ctx ? redis_tls_client_ctx : redis_tls_ctx); + if (!valkey_tls_ctx) return C_ERR; + SSL *ssl = SSL_new(valkey_tls_client_ctx ? valkey_tls_client_ctx : valkey_tls_ctx); if (!ssl) return C_ERR; if (redisInitiateSSL(&context->c, ssl) == REDIS_ERR) { diff --git a/src/tls.c b/src/tls.c index 54eaf255dc..ad35ca2c2f 100644 --- a/src/tls.c +++ b/src/tls.c @@ -58,8 +58,8 @@ #define REDIS_TLS_PROTO_DEFAULT (REDIS_TLS_PROTO_TLSv1_2) #endif -SSL_CTX *redis_tls_ctx = NULL; -SSL_CTX *redis_tls_client_ctx = NULL; +SSL_CTX *valkey_tls_ctx = NULL; +SSL_CTX *valkey_tls_client_ctx = NULL; static int parseProtocolsConfig(const char *str) { int i, count = 0; @@ -170,13 +170,13 @@ static void tlsInit(void) { } static void tlsCleanup(void) { - if (redis_tls_ctx) { - SSL_CTX_free(redis_tls_ctx); - redis_tls_ctx = NULL; + if (valkey_tls_ctx) { + SSL_CTX_free(valkey_tls_ctx); + valkey_tls_ctx = NULL; } - if (redis_tls_client_ctx) { - SSL_CTX_free(redis_tls_client_ctx); - redis_tls_client_ctx = NULL; + if (valkey_tls_client_ctx) { + SSL_CTX_free(valkey_tls_client_ctx); + valkey_tls_client_ctx = NULL; } #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) @@ -284,7 +284,7 @@ static SSL_CTX *createSSLContext(serverTLSContextConfig *ctx_config, int protoco * leave the SSL_CTX unchanged if fails. * @priv: config of serverTLSContextConfig. * @reconfigure: if true, ignore the previous configure; if false, only - * configure from @ctx_config if redis_tls_ctx is NULL. + * configure from @ctx_config if valkey_tls_ctx is NULL. */ static int tlsConfigure(void *priv, int reconfigure) { serverTLSContextConfig *ctx_config = (serverTLSContextConfig *)priv; @@ -292,7 +292,7 @@ static int tlsConfigure(void *priv, int reconfigure) { SSL_CTX *ctx = NULL; SSL_CTX *client_ctx = NULL; - if (!reconfigure && redis_tls_ctx) { + if (!reconfigure && valkey_tls_ctx) { return C_OK; } @@ -402,10 +402,10 @@ static int tlsConfigure(void *priv, int reconfigure) { if (!client_ctx) goto error; } - SSL_CTX_free(redis_tls_ctx); - SSL_CTX_free(redis_tls_client_ctx); - redis_tls_ctx = ctx; - redis_tls_client_ctx = client_ctx; + SSL_CTX_free(valkey_tls_ctx); + SSL_CTX_free(valkey_tls_client_ctx); + valkey_tls_ctx = ctx; + valkey_tls_client_ctx = client_ctx; return C_OK; @@ -457,9 +457,9 @@ typedef struct tls_connection { } tls_connection; static connection *createTLSConnection(int client_side) { - SSL_CTX *ctx = redis_tls_ctx; - if (client_side && redis_tls_client_ctx) - ctx = redis_tls_client_ctx; + SSL_CTX *ctx = valkey_tls_ctx; + if (client_side && valkey_tls_client_ctx) + ctx = valkey_tls_client_ctx; tls_connection *conn = zcalloc(sizeof(tls_connection)); conn->c.type = &CT_TLS; conn->c.fd = -1; From f4f1bd6fde4ce1c03e14e11db87b2512cc9f5c75 Mon Sep 17 00:00:00 2001 From: Roshan Khatri <117414976+roshkhatri@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:35:08 -0700 Subject: [PATCH 90/98] Revert update of RedisModuleEvent_MasterLinkChange (#289) ValkeyModuleEvent_MasterLinkChange was updated to use more inclusive language, but it was done in the compatibility layer as well (RedisModuleEvent_). --------- Signed-off-by: Roshan Khatri --- src/redismodule.h | 2 +- tests/modules/hooks.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redismodule.h b/src/redismodule.h index 9c3d06d69d..14cc595598 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -712,7 +712,7 @@ #define RedisModuleEvent_Shutdown ValkeyModuleEvent_Shutdown #define RedisModuleEvent_ReplicaChange ValkeyModuleEvent_ReplicaChange #define RedisModuleEvent_CronLoop ValkeyModuleEvent_CronLoop -#define RedisModuleEvent_PrimaryLinkChange ValkeyModuleEvent_PrimaryLinkChange +#define RedisModuleEvent_MasterLinkChange ValkeyModuleEvent_PrimaryLinkChange #define RedisModuleEvent_ModuleChange ValkeyModuleEvent_ModuleChange #define RedisModuleEvent_LoadingProgress ValkeyModuleEvent_LoadingProgress #define RedisModuleEvent_SwapDB ValkeyModuleEvent_SwapDB diff --git a/tests/modules/hooks.c b/tests/modules/hooks.c index 24449d0d34..a1f5f536b0 100644 --- a/tests/modules/hooks.c +++ b/tests/modules/hooks.c @@ -422,7 +422,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_ReplicaChange, replicationChangeCallback); RedisModule_SubscribeToServerEvent(ctx, - RedisModuleEvent_PrimaryLinkChange, rasterLinkChangeCallback); + RedisModuleEvent_MasterLinkChange, rasterLinkChangeCallback); /* persistence related hooks */ RedisModule_SubscribeToServerEvent(ctx, From f0113a4105ce03ecd1f875ffed5252d6304edbd5 Mon Sep 17 00:00:00 2001 From: Daniel House <76451671+daniel-house@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:06:04 -0400 Subject: [PATCH 91/98] Clarify the usage of Valkey in a comment (#233) Signed-off-by: Daniel House --- src/sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sort.c b/src/sort.c index dea9bb73e3..f830de83b7 100644 --- a/src/sort.c +++ b/src/sort.c @@ -185,7 +185,7 @@ int sortCompare(const void *s1, const void *s2) { return server.sort_desc ? -cmp : cmp; } -/* The SORT command is the most complex command in the server. Warning: this code +/* The SORT command is the most complex command in Valkey. Warning: this code * is optimized for speed and a bit less for readability */ void sortCommandGeneric(client *c, int readonly) { list *operations; From 697524252993f849f0ade560fa46625623fa7ed5 Mon Sep 17 00:00:00 2001 From: bentotten <59932872+bentotten@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:18:20 -0700 Subject: [PATCH 92/98] Update comment in cluster_legacy.h (#277) Update comment suggesting clusterMsgPingExtTypes to clusterMsgPingtypes as clusterMsgPingExtTypes does not exist Signed-off-by: Ben Totten --- src/cluster_legacy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index 9caf07bae3..791998e31a 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -161,7 +161,7 @@ typedef struct { typedef struct { uint32_t length; /* Total length of this extension message (including this header) */ - uint16_t type; /* Type of this extension message (see clusterMsgPingExtTypes) */ + uint16_t type; /* Type of this extension message (see clusterMsgPingtypes) */ uint16_t unused; /* 16 bits of padding to make this structure 8 byte aligned. */ union { clusterMsgPingExtHostname hostname; @@ -208,7 +208,7 @@ union clusterMsgData { typedef struct { char sig[4]; /* Signature "RCmb" (Cluster message bus). */ uint32_t totlen; /* Total length of this message */ - uint16_t ver; /* Protocol version, currently set to 1. */ + uint16_t ver; /* Protocol version, currently set to CLUSTER_PROTO_VER. */ uint16_t port; /* Primary port number (TCP or TLS). */ uint16_t type; /* Message type */ uint16_t count; /* Only used for some kind of messages. */ From 4be97ebcbe3dab40324ab70fa56d25544dc3f619 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Thu, 11 Apr 2024 16:34:32 -0400 Subject: [PATCH 93/98] update valkey in serverLog messeges in server.c file (#231) Updated keyword "Redis" to "Valkey" in log messeges in server.c file Signed-off-by: Shivshankar-Reddy --- src/server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server.c b/src/server.c index a6069c0161..e30338e452 100644 --- a/src/server.c +++ b/src/server.c @@ -6698,7 +6698,7 @@ void loadDataFromDisk(void) { void serverOutOfMemoryHandler(size_t allocation_size) { serverLog(LL_WARNING,"Out Of Memory allocating %zu bytes!", allocation_size); - serverPanic("Redis aborting for OUT OF MEMORY. Allocating %zu bytes!", + serverPanic("Valkey aborting for OUT OF MEMORY. Allocating %zu bytes!", allocation_size); } @@ -6811,10 +6811,10 @@ static int serverSupervisedUpstart(void) { static int serverSupervisedSystemd(void) { #ifndef HAVE_LIBSYSTEMD serverLog(LL_WARNING, - "systemd supervision requested or auto-detected, but Redis is compiled without libsystemd support!"); + "systemd supervision requested or auto-detected, but Valkey is compiled without libsystemd support!"); return 0; #else - if (serverCommunicateSystemd("STATUS=Redis is loading...\n") <= 0) + if (serverCommunicateSystemd("STATUS=Valkey is loading...\n") <= 0) return 0; serverLog(LL_NOTICE, "Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit."); @@ -7151,7 +7151,7 @@ int main(int argc, char **argv) { serverLog(LL_WARNING, "Failed to test the kernel for a bug that could lead to data corruption during background save. " "Your system could be affected, please report this error."); if (!checkIgnoreWarning("ARM64-COW-BUG")) { - serverLog(LL_WARNING,"Redis will now exit to prevent data corruption. " + serverLog(LL_WARNING,"Valkey will now exit to prevent data corruption. " "Note that it is possible to suppress this warning by setting the following config: ignore-warnings ARM64-COW-BUG"); exit(1); } From c36f67a3ecca1d511a005c4140a8388bed81f24a Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Thu, 11 Apr 2024 16:59:52 -0400 Subject: [PATCH 94/98] Fix a minor issue for Redis brand name in Sentinel.conf (#300) Signed-off-by: hwware --- sentinel.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentinel.conf b/sentinel.conf index 36a21e9331..a395ad16c0 100644 --- a/sentinel.conf +++ b/sentinel.conf @@ -141,7 +141,7 @@ sentinel down-after-milliseconds mymaster 30000 # # user worker +@admin +@connection ~* on >ffa9203c493aa99 # -# For more information about ACL configuration please refer to the Redis +# For more information about ACL configuration please refer to the Valkey # website at https://valkey.io/topics/acl and valkey server configuration # template valkey.conf. From 3d887df2659c39f714028dce82f05805cb76dd87 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:12:28 -0700 Subject: [PATCH 95/98] Add links for security issues (#299) Add an initial security release page. In the fullness of time I would like to also include our version support here, but until that has been decided I would like to keep this simple and just include links. --------- Signed-off-by: Madelyn Olson --- SECURITY.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 285b6d3d62..2b095e5349 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,8 +1,6 @@ -# Security Policy - -Valkey is under development, more information will become available. - ## Reporting a Vulnerability -If you believe you've discovered a serious vulnerability, please contact Madelyn -at placeholderkv@gmail.com +If you believe you've discovered a security vulnerability, please contact the Valkey team at security@lists.valkey.io. +Please *DO NOT* create an issue. +We follow a responsible disclore procedure, so depending on the severity of the issue we may notify Valkey vendors about the issue before releasing it publicly. +If you would like to be added to our list of vendors, please reach out to the Valkey team at maintainers@lists.valkey.io. From 644692db79e522d5eb23eafe6199ccbfbcf321ad Mon Sep 17 00:00:00 2001 From: Parth <661497+parthpatel@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:54:39 -0700 Subject: [PATCH 96/98] Fixing a lua debugger bug that prevented use of 'server' for server.call invocations. (#303) * Tested it on local instance. This was originally part of https://github.com/valkey-io/valkey/pull/288 but I am pushing this separately, so that we can easily merge it into the upcoming release. ``` lua debugger> server ping ping "+PONG" lua debugger> redis ping ping "+PONG" ``` * I also searched for lua debugger related unit tests to add coverage for this but did not find any relevant test to modify. Leaving it at that for now. --------- Signed-off-by: Parth Patel <661497+parthpatel@users.noreply.github.com> --- src/eval.c | 2 +- tests/unit/scripting.tcl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 587fb3b7af..0a97bb2536 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1677,7 +1677,7 @@ ldbLog(sdsnew(" next line of code.")); luaPushError(lua, "script aborted for user request"); luaError(lua); } else if (argc > 1 && - (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) { + (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],REDIS_API_NAME) || !strcasecmp(argv[0],SERVER_API_NAME))) { ldbRedis(lua,argv,argc); ldbSendLogs(); } else if ((!strcasecmp(argv[0],"p") || !strcasecmp(argv[0],"print"))) { diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index c365f09c82..3fd4190ba8 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -1547,6 +1547,19 @@ start_server {tags {"scripting needs:debug external:skip"}} { reconnect assert_equal [r ping] {PONG} } + + test {Test scripting debug lua server invocations} { + r script debug sync + r eval {return 'hello'} 0 + set cmd "*2\r\n\$6\r\nserver\r\n\$4\r\nping\r\n" + r write $cmd + r flush + set ret [r read] + puts $ret + assert_match {*PONG*} $ret + reconnect + assert_equal [r ping] {PONG} + } } start_server {tags {"scripting external:skip"}} { From 7b58f080a871aa82909e17df02d096e703908446 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Fri, 12 Apr 2024 16:05:39 +0100 Subject: [PATCH 97/98] Fix typo in SECURITY.md (#309) Fix typo: "disclore" to "disclosure" in SECURITY.md Signed-off-by: Tom Morris --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index 2b095e5349..085697a0be 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,5 +2,5 @@ If you believe you've discovered a security vulnerability, please contact the Valkey team at security@lists.valkey.io. Please *DO NOT* create an issue. -We follow a responsible disclore procedure, so depending on the severity of the issue we may notify Valkey vendors about the issue before releasing it publicly. +We follow a responsible disclosure procedure, so depending on the severity of the issue we may notify Valkey vendors about the issue before releasing it publicly. If you would like to be added to our list of vendors, please reach out to the Valkey team at maintainers@lists.valkey.io. From 1c282a9306b6623ae258f365d1b759fdd4a4ade9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Fri, 12 Apr 2024 17:24:22 +0200 Subject: [PATCH 98/98] Set permissions for Github Actions in CI (#312) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This sets the default permission for current CI workflows to only be able to read from the repository (scope: "contents"). When a used Github Action require additional permissions (like CodeQL) we grant that permission on job-level instead. This means that a compromised action will not be able to modify the repo or even steal secrets since all other permission-scopes are implicit set to "none", i.e. not permitted. This is recommended by [OpenSSF](https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions). This PR includes a small fix for the possibility of missing server logs artifacts, found while verifying the permission. The `upload-artifact@v3` action will replace artifacts which already exists. Since both CI-jobs `test-external-standalone` and `test-external-nodebug` uses the same artifact name, when both jobs fail, we only get logs from the last finished job. This can be avoided by using unique artifact names. This PR is part of #211 More about permissions and scope can be found here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions --------- Signed-off-by: Björn Svensson --- .github/workflows/ci.yml | 3 +++ .github/workflows/codeql-analysis.yml | 5 +++++ .github/workflows/coverity.yml | 2 ++ .github/workflows/daily.yml | 2 ++ .github/workflows/external.yml | 7 +++++-- .github/workflows/reply-schemas-linter.yml | 3 +++ .github/workflows/spell-check.yml | 3 +++ 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bd01183f2..137bd195c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ name: CI on: [push, pull_request] +permissions: + contents: read + jobs: test-ubuntu-latest: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4c7484b99b..5055e6b8dc 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -6,11 +6,16 @@ on: # run weekly new vulnerability was added to the database - cron: '0 0 * * 0' +permissions: + contents: read + jobs: analyze: name: Analyze runs-on: ubuntu-latest if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey' + permissions: + security-events: write strategy: fail-fast: false diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 791bb275b2..d63ba6ab53 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -6,6 +6,8 @@ on: - cron: '0 0 * * *' # Support manual execution workflow_dispatch: +permissions: + contents: read jobs: coverity: if: github.repository == 'valkey-io/valkey' diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index a4ecf31ecf..178d9b7ceb 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -28,6 +28,8 @@ on: description: 'git branch or sha to use' default: 'unstable' +permissions: + contents: read jobs: diff --git a/.github/workflows/external.yml b/.github/workflows/external.yml index bd6b438394..8111c5e6cd 100644 --- a/.github/workflows/external.yml +++ b/.github/workflows/external.yml @@ -6,6 +6,9 @@ on: schedule: - cron: '0 0 * * *' +permissions: + contents: read + jobs: test-external-standalone: runs-on: ubuntu-latest @@ -29,7 +32,7 @@ jobs: if: ${{ failure() }} uses: actions/upload-artifact@v3 with: - name: test-external-server-log + name: test-external-standalone-log path: external-server.log test-external-cluster: @@ -81,5 +84,5 @@ jobs: if: ${{ failure() }} uses: actions/upload-artifact@v3 with: - name: test-external-server-log + name: test-external-nodebug-log path: external-server.log diff --git a/.github/workflows/reply-schemas-linter.yml b/.github/workflows/reply-schemas-linter.yml index a57a97ab3d..eb14a27204 100644 --- a/.github/workflows/reply-schemas-linter.yml +++ b/.github/workflows/reply-schemas-linter.yml @@ -8,6 +8,9 @@ on: paths: - 'src/commands/*.json' +permissions: + contents: read + jobs: reply-schemas-linter: runs-on: ubuntu-latest diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index e146b79c94..b4bc62e7b0 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -9,6 +9,9 @@ on: push: pull_request: +permissions: + contents: read + jobs: build: name: Spellcheck