Skip to content

feat: implement TTL support#66

Merged
AlexJuca merged 2 commits intomainfrom
implement-ttl-support
Feb 26, 2026
Merged

feat: implement TTL support#66
AlexJuca merged 2 commits intomainfrom
implement-ttl-support

Conversation

@AlexJuca
Copy link
Owner

@AlexJuca AlexJuca commented Feb 25, 2026

This PR implements #6

Adds TTL support with four new commands: DEL, EXPIRE, TTL, and PERSIST. Key expiration uses a hybrid approach lazy checks on every read/write operation plus an active sweep via a 100ms event loop timer (kqueue, epoll, and io_uring).

SET clears any existing TTL, matching Redis semantics most users would expect.

Includes 34 integration tests covering the full lifecycle: expiry, persistence, edge cases like EXPIRE 0, double DEL, and lazy expiry across all arithmetic commands.

Summary of supposed commands:

Command Usage Description
SET SET key value [EX seconds] Store a key-value pair, optionally setting a TTL atomically

Expiration (TTL)

Command Usage Description
EXPIRE EXPIRE key seconds Set a timeout on a key (in seconds)
TTL TTL key Get the remaining time-to-live of a key (-1 = no TTL, -2 = key missing)
PERSIST PERSIST key Remove the timeout from a key

@AlexJuca AlexJuca self-assigned this Feb 25, 2026
@AlexJuca AlexJuca added the enhancement New feature or request label Feb 25, 2026
@AlexJuca AlexJuca merged commit eb4bc65 into main Feb 26, 2026
3 of 4 checks passed
@AlexJuca AlexJuca deleted the implement-ttl-support branch February 26, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant