mirror of
https://github.com/redis/redis.git
synced 2026-02-03 20:39:54 -05:00
|
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) 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 |
||
|---|---|---|
| .. | ||
| aclcheck.c | ||
| atomicslotmigration.c | ||
| auth.c | ||
| basics.c | ||
| blockedclient.c | ||
| blockonbackground.c | ||
| blockonkeys.c | ||
| cmdintrospection.c | ||
| commandfilter.c | ||
| configaccess.c | ||
| crash.c | ||
| datatype.c | ||
| datatype2.c | ||
| defragtest.c | ||
| eventloop.c | ||
| fork.c | ||
| getchannels.c | ||
| getkeys.c | ||
| hash.c | ||
| hooks.c | ||
| infotest.c | ||
| internalsecret.c | ||
| keyspace_events.c | ||
| keyspecs.c | ||
| list.c | ||
| Makefile | ||
| mallocsize.c | ||
| misc.c | ||
| moduleauthtwo.c | ||
| moduleconfigs.c | ||
| moduleconfigstwo.c | ||
| postnotifications.c | ||
| propagate.c | ||
| publish.c | ||
| rdbloadsave.c | ||
| reply.c | ||
| scan.c | ||
| stream.c | ||
| subcommands.c | ||
| test_keymeta.c | ||
| test_lazyfree.c | ||
| testrdb.c | ||
| timer.c | ||
| usercall.c | ||
| zset.c | ||