redis/tests/modules
Moti Cohen 11e73c66a8
Some checks are pending
CI / test-ubuntu-latest (push) Waiting to run
CI / test-sanitizer-address (push) Waiting to run
CI / build-debian-old (push) Waiting to run
CI / build-macos-latest (push) Waiting to run
CI / build-32bit (push) Waiting to run
CI / build-libc-malloc (push) Waiting to run
CI / build-centos-jemalloc (push) Waiting to run
CI / build-old-chain-jemalloc (push) Waiting to run
Codecov / code-coverage (push) Waiting to run
External Server Tests / test-external-standalone (push) Waiting to run
External Server Tests / test-external-cluster (push) Waiting to run
External Server Tests / test-external-nodebug (push) Waiting to run
Spellcheck / Spellcheck (push) Waiting to run
Modules KeyMeta (Keys Metadata) (#14445)
Modules KeyMeta (Keys Metadata)

Redis modules often need to associate additional metadata with keys in
the keyspace. The objective is to create a unified and extensible
interface, usable by modules, Redis core, and maybe later by the users,
that facilitate the association and management of metadata with keys.
While extending RedisModuleTypes might be an easier path, this proposal
goes one step further: a general-purpose mechanism that lets attach
metadata to any key, independent of underlying data type.

A major part of this feature involves defining how metadata is managed
throughout a key’s lifecycle. Modules will be able to optionally
register distinct metadata classes, each with its own lifecycle
callbacks and capable of storing arbitrary 8-byte value per key. These
metadata values will be embedded directly within Redis’s core key-value
objects to ensure fast access and automatic callback execution as keys
are created, updated, or deleted. Each 8 bytes of metadata can represent
either a simple primitive value or a pointer/handle to more complex,
externally managed data by the module and RDB serialized along with the
key.

Key Features:
- Modules can register up to 7 metadata classes (8 total, 1 reserved)
- Each class: 4-char name + 5-bit version (e.g., "SRC1" v1)
- Each class attaches 8 bytes per key (value or pointer/handle)
- Separate namespace from module data types

Module API:
- RedisModule_CreateKeyMetaClass() - Register metadata class
- RedisModule_ReleaseKeyMetaClass() - Release metadata class
- RedisModule_SetKeyMeta() - Attach/update metadata
- RedisModule_GetKeyMeta() - Retrieve metadata

Lifecycle Callbacks:
- copy, rename, move - Handle key operations
- unlink, free - Handle key deletion/expiration
- rdb_save, rdb_load - RDB persistence
- aof_rewrite - AOF rewrite support

Implementation:
- Metadata slots allocated before kvobj in reverse class ID order
- 8-bit metabits bitmap tracks active classes per key
- Minimal memory overhead - only allocated slots consume memory

RDB Serialization (v13):
- New opcode RDB_OPCODE_KEY_METADATA
- Compact 32-bit class spec: 24-bit name + 5-bit ver + 3-bit flags
- Self-contained format: [META,] TYPE, KEY, VALUE
- Portable across cluster nodes

Integration:
- Core ops: dbAdd, dbSet, COPY, MOVE, RENAME, DELETE
- DUMP/RESTORE support
- AOF rewrite via module callbacks
- Defragmentation support
- Module type I/O refactored to ModuleEntityId
2026-01-15 23:11:17 +02:00
..
aclcheck.c Add size_t cast for RM_call() in module tests (#14061) 2025-05-23 10:10:11 +08:00
atomicslotmigration.c Support delay trimming slots after finishing migrating slots (#14567) 2025-12-16 16:30:56 +08:00
auth.c Fix ASan Daily (#14527) 2025-11-19 10:56:18 +02:00
basics.c Adding AGPLv3 as a license option to Redis! (#13997) 2025-05-01 14:04:22 +01:00
blockedclient.c Add size_t cast for RM_call() in module tests (#14061) 2025-05-23 10:10:11 +08:00
blockonbackground.c Fix daylight race condition and some thread leaks (#13191) 2024-04-04 13:49:51 +03:00
blockonkeys.c Modules: Unblock from within a timer coverage (#12337) 2023-06-22 23:15:16 +03:00
cmdintrospection.c Add idempotency support to XADD via IDMPAUTO and IDMP parameters (#14615) 2026-01-15 21:58:44 +08:00
commandfilter.c Add size_t cast for RM_call() in module tests (#14061) 2025-05-23 10:10:11 +08:00
configaccess.c Fix numeric config boundry check (#14286) 2025-10-28 13:40:44 +02:00
crash.c Print command tokens on a crash when hide-user-data-from-log is enabled (#13639) 2024-11-11 09:34:18 +03:00
datatype.c Fix module loadex command crash due to invalid config (#13653) 2024-11-21 14:14:14 +08:00
datatype2.c Use const char pointer in redismodule.h as far as possible (#10064) 2022-01-18 15:55:20 +02:00
defragtest.c Create global data before test instead of module load for module defrag test (#13951) 2025-07-22 20:44:12 +08:00
eventloop.c delete obsolete REDISMODULE_EXPERIMENTAL_API define in module demos (#10527) 2022-04-05 08:21:41 +03:00
fork.c Fix race in module fork kill test (#10717) 2022-05-12 20:10:38 +03:00
getchannels.c Implemented module getchannels api and renamed channel keyspec (#10299) 2022-02-22 11:00:03 +02:00
getkeys.c Handle key-spec flags with modules (#10237) 2022-02-08 10:01:35 +02:00
hash.c Modules API: new HashFieldMinExpire(). Add flag REDISMODULE_HASH_EXPIRE_TIME to HashGet(). (#13676) 2024-12-05 11:14:52 +02:00
hooks.c Adding AGPLv3 as a license option to Redis! (#13997) 2025-05-01 14:04:22 +01:00
infotest.c Update supported version list. (#12488) 2023-08-16 08:36:40 +03:00
internalsecret.c Add size_t cast for RM_call() in module tests (#14061) 2025-05-23 10:10:11 +08:00
keyspace_events.c Add API to allow Redis modules to unsubscribe from keyspace notifications 2025-07-28 10:17:48 +03:00
keyspecs.c RM_CreateCommand should not set CMD_KEY_VARIABLE_FLAGS automatically (#11320) 2022-09-28 14:15:07 +03:00
list.c Fix crash due to to reuse iterator entry after list deletion in module (#11383) 2022-10-22 20:36:50 +03:00
Makefile Modules KeyMeta (Keys Metadata) (#14445) 2026-01-15 23:11:17 +02:00
mallocsize.c Add RM_MallocSizeString, RM_MallocSizeDict (#10542) 2022-04-17 08:31:57 +03:00
misc.c New eviction policies - least recently modified (#14624) 2026-01-06 20:57:31 +08:00
moduleauthtwo.c Custom authentication for Modules (#11659) 2023-03-15 15:18:42 -07:00
moduleconfigs.c Update tests/modules/moduleconfigs.c 2025-02-06 13:16:33 +02:00
moduleconfigstwo.c Module Configurations (#10285) 2022-03-30 15:47:06 +03:00
postnotifications.c Adding AGPLv3 as a license option to Redis! (#13997) 2025-05-01 14:04:22 +01:00
propagate.c Adding AGPLv3 as a license option to Redis! (#13997) 2025-05-01 14:04:22 +01:00
publish.c Fix broken protocol when PUBLISH emits local push inside MULTI (#12326) 2023-06-20 20:41:41 +03:00
rdbloadsave.c Add RM_RdbLoad and RM_RdbSave module API functions (#11852) 2023-04-09 12:07:32 +03:00
reply.c Add RM_ReplyWithErrorFormat that can support format (#11923) 2023-04-12 10:11:29 +03:00
scan.c Replace deprecated REDISMODULE_POSTPONED_ARRAY_LEN in module tests and examples (#9677) 2021-10-25 12:00:43 +03:00
stream.c Sort out the mess around writable replicas and lookupKeyRead/Write (#9572) 2021-11-28 11:26:28 +02:00
subcommands.c Block some specific characters in module command names (#11434) 2022-11-03 13:19:49 +02:00
test_keymeta.c Modules KeyMeta (Keys Metadata) (#14445) 2026-01-15 23:11:17 +02:00
test_lazyfree.c Sort out the mess around writable replicas and lookupKeyRead/Write (#9572) 2021-11-28 11:26:28 +02:00
testrdb.c Avoid saving module aux on RDB if no aux data was saved by the module. (#11374) 2022-10-18 19:45:46 +03:00
timer.c Modules: Mark all APIs non-experimental (#9983) 2021-12-30 12:17:22 +02:00
usercall.c Add size_t cast for RM_call() in module tests (#14061) 2025-05-23 10:10:11 +08:00
zset.c Expose "touches-arbitrary-keys" flag to Redis modules (#14290) 2025-08-20 07:32:24 +08:00