Skip to content

feat: support async serialize/deserialize in CacheValueSerializer#216

Merged
AyronK merged 1 commit intofortedigital:masterfrom
gergokee:feat/async-value-serializer
Apr 3, 2026
Merged

feat: support async serialize/deserialize in CacheValueSerializer#216
AyronK merged 1 commit intofortedigital:masterfrom
gergokee:feat/async-value-serializer

Conversation

@gergokee
Copy link
Copy Markdown
Contributor

@gergokee gergokee commented Apr 1, 2026

Widen CacheValueSerializer.serialize and .deserialize return types from sync-only to string | Promise and CacheHandlerValue | null | Promise<CacheHandlerValue | null> respectively, and add await at both call sites in redis-strings.ts.

This allows users to replace blocking sync codecs (e.g. brotliCompressSync) with non-blocking async variants (e.g. brotliCompress) without blocking the Node.js event loop under load. Existing sync implementations continue to work unchanged — await on a non-Promise is a no-op in JavaScript.

Widen CacheValueSerializer.serialize and .deserialize return types from
sync-only to string | Promise<string> and CacheHandlerValue | null |
Promise<CacheHandlerValue | null> respectively, and add await at both
call sites in redis-strings.ts.

This allows users to replace blocking sync codecs (e.g. brotliCompressSync)
with non-blocking async variants (e.g. brotliCompress) without blocking
the Node.js event loop under load. Existing sync implementations continue
to work unchanged — await on a non-Promise is a no-op in JavaScript.
@AyronK AyronK self-requested a review April 2, 2026 20:13
Copy link
Copy Markdown
Collaborator

@AyronK AyronK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

@AyronK AyronK merged commit 60f0c64 into fortedigital:master Apr 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants