Creates a new JavaScript KVStore object which interacts with the Fastly KV Store named name.
Name of the Fastly KV Store to interact with. A name cannot be empty, contain Control characters, or be longer than 255 characters.
Delete the value associated with the key key in the KV Store.
The key to retrieve from within the KV Store. A key cannot:
Gets the value associated with the key key in the KV Store.
When the key is present, a resolved Promise containing an KVStoreEntry will be returned which contains the associated value.
When the key is absent, a resolved Promise containing null is returned.
The key to retrieve from within the KV Store. A key cannot:
Returns an async iterator for the values of the KV Store optionally taking a prefix and limit
Optionaloptions: { cursor?: string; limit?: number; noSync?: boolean; prefix?: string }Optionalcursor?: stringCursor
The base64 cursor string representing the last listing operation
Optionallimit?: numberLimit the number of keys provided per listing.
OptionalnoSync?: booleanDo not wait to sync the key list, and instead immediately return the current cached key list.
Optionalprefix?: stringString prefix for keys to list.
Pass this base64 cursor into a subsequent list call to obtain the next listing.
The cursor is undefined when the end of the list is reached.
Write the value of value into the KV Store under the key key.
Note: KV Store is eventually consistent, this means that the updated contents associated with the key key may not be available to read from all
edge locations immediately and some edge locations may continue returning the previous contents associated with the key.
The key to associate with the value. A key cannot:
The value to store within the KV Store.
Optionaloptions: {Optionalgen?: numberIf generation match integer.
Optionalmetadata?: string | ArrayBuffer | ArrayBufferView<ArrayBufferLike>Optional metadata to be associated with the entry.
If passing a string, UTF-8 encoding is used
Optionalmode?: "overwrite" | "add" | "append" | "prepend"Insert mode, defaults to 'overwrite'.
Optionalttl?: numberTTL for the entry.
Class for accessing a Fastly KV-store.
A kv store is a persistent, globally consistent key-value store.
Note: Can only be used when processing requests, not during build-time initialization.
Example
In this example we connect to an KV Store named
'files'and save an entry to the store under the key'hello'and then read back the value and return it to the client.