Skip to content

Add get_bulk support to KV store bindings#949

Open
rorychatterton wants to merge 1 commit intocloudflare:mainfrom
rorychatterton:kv-bulkget
Open

Add get_bulk support to KV store bindings#949
rorychatterton wants to merge 1 commit intocloudflare:mainfrom
rorychatterton:kv-bulkget

Conversation

@rorychatterton
Copy link

Summary

  • Implements [Feature] KV BulkGet API Endpoint #948
  • Add get_bulk(&[impl AsRef]) to KvStore, returning a GetBulkOptionsBuilder with text(), json(), text_with_metadata(), and json_with_metadata() terminal methods
  • Extract shared deserialization helpers (deserialize_nullable, extract_metadata, build_get_options) used by both GetOptionsBuilder and GetBulkOptionsBuilder
  • Add integration test endpoints for the sandbox worker

Details

The Workers KV JS runtime already accepts an array of keys in get() and getWithMetadata(), returning a JS Map. This adds Rust bindings for that, passing a js_sys::Array instead of a single string and iterating the returned Map into a HashMap<String, Option>.

No new JS bindings are needed — reuses the existing get_function and get_with_meta_function references on KvStore.

To test it, I ran it locally with miniflare on my app and seemed to be fine.

Add KvStore::get_bulk() for fetching multiple keys in a single call,
using the existing JS runtime bulk get API. Returns HashMap<String, Option<T>>
via a GetBulkOptionsBuilder with text(), json(), text_with_metadata(),
and json_with_metadata() terminal methods.
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.

1 participant