feat(kv): add atomic operations - #927
Open
onmax wants to merge 4 commits into
Open
Conversation
|
@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NuxtHub KV users on Redis and Upstash can now atomically read and delete a value or increment an expiring counter. Each operation takes one server request and prevents another request from changing the value between the read and write.
This also gives
@nuxtjs/better-auththe NuxtHub KV operations it needs for Better Auth 1.7 secondary storage when users configure Redis or Upstash. WithoutgetAndDelete()andincrement(), affected users need a separate storage adapter. The limitation was reported in nuxt-modules/better-auth#423.Driver behavior
GETDEL· UpstashEVALfs-liteRedis runs both methods in Lua scripts. This keeps
getAndDelete()compatible with Redis versions beforeGETDELand letsincrement()check whether the key existed before setting its expiry. Upstash uses its nativeGETDELcommand and a Lua script for the counter.Deno KV can make the update atomic, but it cannot preserve the counter's original fixed expiry when writing the next value through this interface. The unsupported drivers therefore do not advertise these methods or fake them with separate
get(),delete(), andset()calls.Atomic reads use the same
destrdecoder as ordinary KV reads, preserving long numeric strings and matching literal and prototype-key handling. The generated KV package imports the helper from@nuxthub/core/kv/atomic, sodestrresolves from its owning runtime package rather than the consuming app.Before · After. The repository reproduction covers both command response shapes; it does not exercise live Redis or Upstash servers.