Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ecdcce0
Introduce HASH items expiration
ranshid Jan 6, 2025
89f56b0
fix new introduced commands
ranshid May 15, 2025
61bd39a
fix some spelling checks
ranshid May 15, 2025
cc7c2a3
handle some format check issues
ranshid May 15, 2025
fcce92b
fix expire propagation
ranshid May 15, 2025
90b7536
fix typo
ranshid May 15, 2025
6ee497c
fix some more format issues
ranshid May 15, 2025
1f0c933
avoid extra ref count incrementing in hashTypePropagateDeletion
ranshid May 18, 2025
fce9a43
fix cmake compilation
ranshid May 18, 2025
ea039c4
Merge remote-tracking branch 'origin/unstable' into ttl-poc-new
ranshid May 18, 2025
dd62037
remove hashtable redundant log
ranshid May 18, 2025
4a09f3d
free entry when calling hashTypeDelete
ranshid May 18, 2025
a59f31a
Add support for HGETEX and HSETEX
ranshid May 19, 2025
f62c163
format fixes
ranshid May 19, 2025
6465314
handle negative ttl correctly
ranshid May 19, 2025
4301399
fix wrong assert condition on update entry
ranshid May 19, 2025
d97e23f
fix FNX/FXX logic
ranshid May 19, 2025
0723625
Fix HEXPIRE parse limits
ranshid May 19, 2025
b782d44
fix case of hll command issues on non-existing listpack encoded hash
ranshid May 19, 2025
31923c5
make httl functions verify the type
ranshid May 19, 2025
5e19c90
fix HGETEX replication handling
ranshid May 19, 2025
20c0d29
fix hexpire propagation to use hpexpireat
ranshid May 19, 2025
a6844ac
add commands json files
ranshid May 19, 2025
36b7356
allow setting the key object in context
ranshid May 19, 2025
e72d7a6
fix build issues
ranshid May 19, 2025
c5b8d76
fix formatting issue
ranshid May 19, 2025
753ba3c
fix object pass to keyspace notification in HSETEX
ranshid May 20, 2025
0b8dc03
centralize keyspace and key signal notifications to the reset context
ranshid May 21, 2025
e604b37
make hashtable call entry destructor on delete access
ranshid May 21, 2025
d719dcd
Hash TTL - add tests (#1)
xbasel May 21, 2025
6d9551e
fix bad memory access issue on entry tracking update
ranshid May 21, 2025
eab6fc4
fix trackUpdate condition
ranshid May 21, 2025
8654080
make sure to remove the volatile set on hash object detructor
ranshid May 21, 2025
cb45000
trigger build
xbasel May 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmake/Modules/SourceFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ set(VALKEY_SERVER_SRCS
${CMAKE_SOURCE_DIR}/src/connection.c
${CMAKE_SOURCE_DIR}/src/unix.c
${CMAKE_SOURCE_DIR}/src/server.c
${CMAKE_SOURCE_DIR}/src/logreqres.c)
${CMAKE_SOURCE_DIR}/src/logreqres.c
${CMAKE_SOURCE_DIR}/src/volatile_set.c)


# valkey-cli
set(VALKEY_CLI_SRCS
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ 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 hashtable.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 memory_prefetch.o io_threads.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 cluster_slot_stats.o crc16.o endianconv.o commandlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crccombine.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 allocator_defrag.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.o functions.o commands.o strl.o connection.o unix.o logreqres.o rdma.o scripting_engine.o lua/script_lua.o lua/function_lua.o lua/engine_lua.o lua/debug_lua.o
ENGINE_SERVER_OBJ=threads_mngr.o adlist.o quicklist.o ae.o anet.o dict.o hashtable.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 memory_prefetch.o io_threads.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 cluster_slot_stats.o crc16.o endianconv.o commandlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crccombine.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 allocator_defrag.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.o functions.o commands.o strl.o connection.o unix.o logreqres.o rdma.o scripting_engine.o volatile_set.o lua/script_lua.o lua/function_lua.o lua/engine_lua.o lua/debug_lua.o
ENGINE_CLI_NAME=$(ENGINE_NAME)-cli$(PROG_SUFFIX)
ENGINE_CLI_OBJ=anet.o adlist.o dict.o valkey-cli.o zmalloc.o release.o ae.o serverassert.o crcspeed.o crccombine.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o sds.o util.o sha256.o
ENGINE_BENCHMARK_NAME=$(ENGINE_NAME)-benchmark$(PROG_SUFFIX)
Expand Down
24 changes: 23 additions & 1 deletion src/aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {
* The function returns 0 on error, 1 on success. */
int rewriteHashObject(rio *r, robj *key, robj *o) {
hashTypeIterator hi;
long long count = 0, items = hashTypeLength(o);
long long count = 0, volatile_items = hashTypeNumVolatileElements(o), items = hashTypeLength(o) - volatile_items;

hashTypeInitIterator(o, &hi);
while (hashTypeNext(&hi) != C_ERR) {
Expand All @@ -1963,6 +1963,9 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {
}
}

if (volatile_items > 0 && hashTypeEntryHasExpire(hi.next))
continue;

if (!rioWriteHashIteratorCursor(r, &hi, OBJ_HASH_FIELD) || !rioWriteHashIteratorCursor(r, &hi, OBJ_HASH_VALUE)) {
hashTypeResetIterator(&hi);
return 0;
Expand All @@ -1973,6 +1976,25 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {

hashTypeResetIterator(&hi);

/* Now serialize volatile items if exist */
if (hashTypeHasVolatileElements(o)) {
hashTypeInitVolatileIterator(o, &hi);
while (hashTypeNext(&hi) != C_ERR) {
long long expiry = hashTypeEntryGetExpiry(hi.next);
sds field = hashTypeEntryGetField(hi.next);
sds value = hashTypeEntryGetValue(hi.next);
if (rioWriteBulkCount(r, '*', 8) == 0) return 0;
if (rioWriteBulkString(r, "HSETEX", 6) == 0) return 0;
if (rioWriteBulkObject(r, key) == 0) return 0;
if (rioWriteBulkString(r, "PXAT", 4) == 0) return 0;
if (rioWriteBulkLongLong(r, expiry) == 0) return 0;
if (rioWriteBulkString(r, "FIELDS", 6) == 0) return 0;
if (rioWriteBulkLongLong(r, 1) == 0) return 0;
if (rioWriteBulkString(r, field, sdslen(field)) == 0) return 0;
if (rioWriteBulkString(r, value, sdslen(value)) == 0) return 0;
}
hashTypeResetIterator(&hi);
}
return 1;
}

Expand Down
Loading
Loading