@@ -384,6 +384,8 @@ example "write deny-oom". The set of flags are:
384384* ** "internal"** : Internal command, one that should not be exposed to the user connections.
385385 For example, module commands that are called by the modules,
386386 commands that do not perform ACL validations (relying on earlier checks)
387+ * ** "touches-arbitrary-keys"** : This command may modify arbitrary keys (i.e. not provided via argv).
388+ This flag is used so we don't wrap the replicated commands with MULTI/EXEC.
387389
388390The last three parameters specify which arguments of the new command are
389391Redis keys. See [ https://redis.io/commands/command ] ( https://redis.io/commands/command ) for more information.
@@ -5047,9 +5049,11 @@ is interested in. This can be an ORed mask of any of the following flags:
50475049 - ` REDISMODULE_NOTIFY_NEW ` : New key notification
50485050 - ` REDISMODULE_NOTIFY_OVERWRITTEN ` : Overwritten events
50495051 - ` REDISMODULE_NOTIFY_TYPE_CHANGED ` : Type-changed events
5052+ - ` REDISMODULE_NOTIFY_KEY_TRIMMED ` : Key trimmed events after a slot migration operation
50505053 - ` REDISMODULE_NOTIFY_ALL ` : All events (Excluding ` REDISMODULE_NOTIFY_KEYMISS ` ,
5051- REDISMODULE_NOTIFY_NEW, REDISMODULE_NOTIFY_OVERWRITTEN
5052- and REDISMODULE_NOTIFY_TYPE_CHANGED)
5054+ REDISMODULE_NOTIFY_NEW, REDISMODULE_NOTIFY_OVERWRITTEN,
5055+ REDISMODULE_NOTIFY_TYPE_CHANGED
5056+ and REDISMODULE_NOTIFY_KEY_TRIMMED)
50535057 - ` REDISMODULE_NOTIFY_LOADED ` : A special notification available only for modules,
50545058 indicates that the key was loaded from persistence.
50555059 Notice, when this event fires, the given key
@@ -5096,7 +5100,7 @@ See [https://redis.io/docs/latest/develop/use/keyspace-notifications/](https://r
50965100 int types,
50975101 RedisModuleNotificationFunc callback);
50985102
5099- ** Available since:** unreleased
5103+ ** Available since:** 8.2.0
51005104
51015105
51025106[ ` RedisModule_UnsubscribeFromKeyspaceEvents ` ] ( #RedisModule_UnsubscribeFromKeyspaceEvents ) - Unregister a module's callback from keyspace notifications for specific event types.
@@ -5341,6 +5345,18 @@ With the following effects:
53415345Returns the cluster slot of a key, similar to the ` CLUSTER KEYSLOT ` command.
53425346This function works even if cluster mode is not enabled.
53435347
5348+ <span id =" RedisModule_ClusterKeySlotC " ></span >
5349+
5350+ ### ` RedisModule_ClusterKeySlotC `
5351+
5352+ unsigned int RedisModule_ClusterKeySlotC(const char *keystr, size_t keylen);
5353+
5354+ ** Available since:** unreleased
5355+
5356+ Like [ ` RedisModule_ClusterKeySlot ` ] ( #RedisModule_ClusterKeySlot ) , but gets a char pointer and a length.
5357+ Returns the cluster slot of a key, similar to the ` CLUSTER KEYSLOT ` command.
5358+ This function works even if cluster mode is not enabled.
5359+
53445360<span id =" RedisModule_ClusterCanonicalKeyNameInSlot " ></span >
53455361
53465362### ` RedisModule_ClusterCanonicalKeyNameInSlot `
@@ -5353,6 +5369,86 @@ Returns a short string that can be used as a key or as a hash tag in a key,
53535369such that the key maps to the given cluster slot. Returns NULL if slot is not
53545370a valid slot.
53555371
5372+ <span id =" RedisModule_ClusterCanAccessKeysInSlot " ></span >
5373+
5374+ ### ` RedisModule_ClusterCanAccessKeysInSlot `
5375+
5376+ int RedisModule_ClusterCanAccessKeysInSlot(int slot);
5377+
5378+ ** Available since:** unreleased
5379+
5380+ Returns 1 if keys in the specified slot can be accessed by this node, 0 otherwise.
5381+
5382+ This function returns 1 in the following cases:
5383+ - The slot is owned by this node or by its master if this node is a replica
5384+ - The slot is being imported under the old slot migration approach (CLUSTER SETSLOT <slot > IMPORTING ..)
5385+ - Not in cluster mode (all slots are accessible)
5386+
5387+ Returns 0 for:
5388+ - Invalid slot numbers (< 0 or >= 16384)
5389+ - Slots owned by other nodes
5390+
5391+ <span id =" RedisModule_ClusterPropagateForSlotMigration " ></span >
5392+
5393+ ### ` RedisModule_ClusterPropagateForSlotMigration `
5394+
5395+ int RedisModule_ClusterPropagateForSlotMigration(RedisModuleCtx *ctx,
5396+ const char *cmdname,
5397+ const char *fmt,
5398+ ...);
5399+
5400+ ** Available since:** unreleased
5401+
5402+ Propagate commands along with slot migration.
5403+
5404+ This function allows modules to add commands that will be sent to the
5405+ destination node before the actual slot migration begins. It should only be
5406+ called during the ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_MIGRATE_MODULE_PROPAGATE ` event.
5407+
5408+ This function can be called multiple times within the same event to
5409+ replicate multiple commands. All commands will be sent before the
5410+ actual slot data migration begins.
5411+
5412+ Note: This function is only available in the fork child process just before
5413+ slot snapshot delivery begins.
5414+
5415+ On success ` REDISMODULE_OK ` is returned, otherwise
5416+ ` REDISMODULE_ERR ` is returned and errno is set to the following values:
5417+
5418+ * EINVAL: function arguments or format specifiers are invalid.
5419+ * EBADF: not called in the correct context, e.g. not called in the ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_MIGRATE_MODULE_PROPAGATE ` event.
5420+ * ENOENT: command does not exist.
5421+ * ENOTSUP: command is cross-slot.
5422+ * ERANGE: command contains keys that are not within the migrating slot range.
5423+
5424+ <span id =" RedisModule_ClusterGetLocalSlotRanges " ></span >
5425+
5426+ ### ` RedisModule_ClusterGetLocalSlotRanges `
5427+
5428+ RedisModuleSlotRangeArray *RedisModule_ClusterGetLocalSlotRanges(RedisModuleCtx *ctx);
5429+
5430+ ** Available since:** unreleased
5431+
5432+ Returns the locally owned slot ranges for the node.
5433+
5434+ An optional ` ctx ` can be provided to enable auto-memory management.
5435+ If cluster mode is disabled, the array will include all slots (0–16383).
5436+ If the node is a replica, the slot ranges of its master are returned.
5437+
5438+ The returned array must be freed with [ ` RedisModule_ClusterFreeSlotRanges() ` ] ( #RedisModule_ClusterFreeSlotRanges ) .
5439+
5440+ <span id =" RedisModule_ClusterFreeSlotRanges " ></span >
5441+
5442+ ### ` RedisModule_ClusterFreeSlotRanges `
5443+
5444+ void RedisModule_ClusterFreeSlotRanges(RedisModuleCtx *ctx,
5445+ RedisModuleSlotRangeArray *slots);
5446+
5447+ ** Available since:** unreleased
5448+
5449+ Frees a slot range array returned by [ ` RedisModule_ClusterGetLocalSlotRanges() ` ] ( #RedisModule_ClusterGetLocalSlotRanges ) .
5450+ Pass the ` ctx ` pointer only if the array was created with a context.
5451+
53565452<span id =" section-modules-timers-api " ></span >
53575453
53585454## Modules Timers API
@@ -7261,6 +7357,63 @@ Here is a list of events you can use as 'eid' and related sub events:
72617357
72627358 RedisModuleKey *key; // Key name
72637359
7360+ * ` RedisModuleEvent_ClusterSlotMigration `
7361+
7362+ Called when an atomic slot migration (ASM) event happens.
7363+ IMPORT events are triggered on the destination side of a slot migration
7364+ operation. These notifications let modules prepare for the upcoming
7365+ ownership change, observe successful completion once the cluster config
7366+ reflects the new owner, or detect a failure in which case slot ownership
7367+ remains with the source.
7368+
7369+ Similarly, MIGRATE events triggered on the source side of a slot
7370+ migration operation to let modules prepare for the ownership change and
7371+ observe the completion of the slot migration. MIGRATE_MODULE_PROPAGATE
7372+ event is triggered in the fork just before snapshot delivery; modules may
7373+ use it to enqueue commands that will be delivered first. See
7374+ RedisModule_ClusterPropagateForSlotMigration() for details.
7375+
7376+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_IMPORT_STARTED `
7377+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_IMPORT_FAILED `
7378+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_IMPORT_COMPLETED `
7379+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_MIGRATE_STARTED `
7380+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_MIGRATE_FAILED `
7381+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_MIGRATE_COMPLETED `
7382+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_MIGRATE_MODULE_PROPAGATE `
7383+
7384+ The data pointer can be casted to a RedisModuleClusterSlotMigrationInfo
7385+ structure with the following fields:
7386+
7387+ char source_node_id[REDISMODULE_NODE_ID_LEN + 1];
7388+ char destination_node_id[REDISMODULE_NODE_ID_LEN + 1];
7389+ const char *task_id; // Task ID
7390+ RedisModuleSlotRangeArray *slots; // Slot ranges
7391+
7392+ * ` RedisModuleEvent_ClusterSlotMigrationTrim `
7393+
7394+ Called when trimming keys after a slot migration. Fires on the source
7395+ after a successful migration to clean up migrated keys, or on the
7396+ destination after a failed import to discard partial imports. Two methods
7397+ are supported. In the first method, keys are deleted in a background
7398+ thread; this is reported via the TRIM_BACKGROUND event. In the second
7399+ method, Redis performs incremental deletions on the main thread via the
7400+ cron loop to avoid stalls; this is reported via the TRIM_STARTED and
7401+ TRIM_COMPLETED events. Each deletion emits REDISMODULE_NOTIFY_KEY_TRIMMED
7402+ so modules can react to individual key deletions. Redis selects the
7403+ method automatically: background by default; switches to main thread
7404+ trimming when a module subscribes to REDISMODULE_NOTIFY_KEY_TRIMMED.
7405+
7406+ The following sub events are available:
7407+
7408+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_TRIM_STARTED `
7409+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_TRIM_COMPLETED `
7410+ * ` REDISMODULE_SUBEVENT_CLUSTER_SLOT_MIGRATION_TRIM_BACKGROUND `
7411+
7412+ The data pointer can be casted to a RedisModuleClusterSlotMigrationTrimInfo
7413+ structure with the following fields:
7414+
7415+ RedisModuleSlotRangeArray *slots; // Slot ranges
7416+
72647417The function returns ` REDISMODULE_OK ` if the module was successfully subscribed
72657418for the specified event. If the API is called from a wrong context or unsupported event
72667419is given then ` REDISMODULE_ERR ` is returned.
@@ -7591,7 +7744,7 @@ cluster, and by that gain the permissions to execute internal commands.
75917744 RedisModuleConfigIterator *RedisModule_ConfigIteratorCreate(RedisModuleCtx *ctx,
75927745 const char *pattern);
75937746
7594- ** Available since:** unreleased
7747+ ** Available since:** 8.2.0
75957748
75967749Get an iterator to all configs.
75977750Optional ` ctx ` can be provided if use of auto-memory is desired.
@@ -7654,7 +7807,7 @@ the caller is responsible for freeing the iterator using
76547807 void RedisModule_ConfigIteratorRelease(RedisModuleCtx *ctx,
76557808 RedisModuleConfigIterator *iter);
76567809
7657- ** Available since:** unreleased
7810+ ** Available since:** 8.2.0
76587811
76597812Release the iterator returned by [ ` RedisModule_ConfigIteratorCreate() ` ] ( #RedisModule_ConfigIteratorCreate ) . If auto-memory
76607813is enabled and manual release is needed one must pass the same ` RedisModuleCtx `
@@ -7666,7 +7819,7 @@ that was used to create the iterator.
76667819
76677820 int RedisModule_ConfigGetType(const char *name, RedisModuleConfigType *res);
76687821
7669- ** Available since:** unreleased
7822+ ** Available since:** 8.2.0
76707823
76717824Get the type of a config as ` RedisModuleConfigType ` . One may use this in order
76727825to get or set the values of the config with the appropriate function if the
@@ -7694,7 +7847,7 @@ If a config with the given name exists `res` is populated with its type, else
76947847
76957848 const char *RedisModule_ConfigIteratorNext(RedisModuleConfigIterator *iter);
76967849
7697- ** Available since:** unreleased
7850+ ** Available since:** 8.2.0
76987851
76997852Go to the next element of the config iterator.
77007853
@@ -7713,7 +7866,7 @@ See [`RedisModule_ConfigIteratorCreate()`](#RedisModule_ConfigIteratorCreate) fo
77137866 const char *name,
77147867 RedisModuleString **res);
77157868
7716- ** Available since:** unreleased
7869+ ** Available since:** 8.2.0
77177870
77187871Get the value of a config as a string. This function can be used to get the
77197872value of any config, regardless of its type.
@@ -7730,7 +7883,7 @@ is returned and `res` is populated with the value.
77307883
77317884 int RedisModule_ConfigGetBool(RedisModuleCtx *ctx, const char *name, int *res);
77327885
7733- ** Available since:** unreleased
7886+ ** Available since:** 8.2.0
77347887
77357888Get the value of a bool config.
77367889
@@ -7746,7 +7899,7 @@ value.
77467899 const char *name,
77477900 RedisModuleString **res);
77487901
7749- ** Available since:** unreleased
7902+ ** Available since:** 8.2.0
77507903
77517904Get the value of an enum config.
77527905
@@ -7763,7 +7916,7 @@ string.
77637916 const char *name,
77647917 long long *res);
77657918
7766- ** Available since:** unreleased
7919+ ** Available since:** 8.2.0
77677920
77687921Get the value of a numeric config.
77697922
@@ -7780,7 +7933,7 @@ value.
77807933 RedisModuleString *value,
77817934 RedisModuleString **err);
77827935
7783- ** Available since:** unreleased
7936+ ** Available since:** 8.2.0
77847937
77857938Set the value of a config.
77867939
@@ -7800,7 +7953,7 @@ is not NULL, it will be populated with an error message.
78007953 int value,
78017954 RedisModuleString **err);
78027955
7803- ** Available since:** unreleased
7956+ ** Available since:** 8.2.0
78047957
78057958Set the value of a bool config.
78067959
@@ -7815,7 +7968,7 @@ See [`RedisModule_ConfigSet`](#RedisModule_ConfigSet) for return value.
78157968 RedisModuleString *value,
78167969 RedisModuleString **err);
78177970
7818- ** Available since:** unreleased
7971+ ** Available since:** 8.2.0
78197972
78207973Set the value of an enum config.
78217974
@@ -7833,7 +7986,7 @@ See [`RedisModule_ConfigSet`](#RedisModule_ConfigSet) for return value.
78337986 long long value,
78347987 RedisModuleString **err);
78357988
7836- ** Available since:** unreleased
7989+ ** Available since:** 8.2.0
78377990
78387991Set the value of a numeric config.
78397992If the value passed is meant to be a percentage, it should be passed as a
@@ -8346,8 +8499,13 @@ There is no guarantee that this info is always available, so this may return -1.
83468499* [ ` RedisModule_Calloc ` ] ( #RedisModule_Calloc )
83478500* [ ` RedisModule_ChannelAtPosWithFlags ` ] ( #RedisModule_ChannelAtPosWithFlags )
83488501* [ ` RedisModule_CloseKey ` ] ( #RedisModule_CloseKey )
8502+ * [ ` RedisModule_ClusterCanAccessKeysInSlot ` ] ( #RedisModule_ClusterCanAccessKeysInSlot )
83498503* [ ` RedisModule_ClusterCanonicalKeyNameInSlot ` ] ( #RedisModule_ClusterCanonicalKeyNameInSlot )
8504+ * [ ` RedisModule_ClusterFreeSlotRanges ` ] ( #RedisModule_ClusterFreeSlotRanges )
8505+ * [ ` RedisModule_ClusterGetLocalSlotRanges ` ] ( #RedisModule_ClusterGetLocalSlotRanges )
83508506* [ ` RedisModule_ClusterKeySlot ` ] ( #RedisModule_ClusterKeySlot )
8507+ * [ ` RedisModule_ClusterKeySlotC ` ] ( #RedisModule_ClusterKeySlotC )
8508+ * [ ` RedisModule_ClusterPropagateForSlotMigration ` ] ( #RedisModule_ClusterPropagateForSlotMigration )
83518509* [ ` RedisModule_CommandFilterArgDelete ` ] ( #RedisModule_CommandFilterArgDelete )
83528510* [ ` RedisModule_CommandFilterArgGet ` ] ( #RedisModule_CommandFilterArgGet )
83538511* [ ` RedisModule_CommandFilterArgInsert ` ] ( #RedisModule_CommandFilterArgInsert )
0 commit comments