Constructs a KVBinding instance.
Optionalsettings: KVSettings
Resolved settings. Defaults to resolve('kv'), so callers
normally construct this with no arguments at all.
Private Optional ReadonlyexpirationDefault expiration applied to writes, in seconds.
Private ReadonlysettingsThis accessor’s settings, resolved on first read.
The binding name this instance resolves.
The binding name as declared in wrangler.json.
Deletes a key.
Deleting a key that does not exist is not an error.
The Worker environment.
The key to delete.
Reads a value as text.
The Worker environment.
The key to read.
OptionalcacheTtl: number
How long, in seconds, the edge may serve this read from cache.
The stored value, or null when the key is absent or expired.
MissingBindingError When the KV binding is absent.
Reads a value and parses it as JSON.
The Worker environment.
The key to read.
OptionalcacheTtl: number
How long, in seconds, the edge may serve this read from cache.
The parsed value, or null when the key is absent or expired.
Checks whether the binding is available on the given environment.
Use this to degrade gracefully when a binding is optional.
The Worker environment.
true when the binding is present.
Writes a value, applying the configured default TTL when none is supplied.
The Worker environment.
The key to write.
The value to store.
Put options — expiration, TTL, and metadata.
Serialises a value to JSON and writes it.
The Worker environment.
The key to write.
The value to serialise and store.
Put options — expiration, TTL, and metadata.
Resolves the binding, failing fast when it is not configured.
The Worker environment.
The resolved binding.
MissingBindingError When the binding is absent from the environment.
Resolves the binding without throwing.
The Worker environment.
The resolved binding, or null when it is not configured.
PrivatewithApplies the configured default TTL to put options that do not set one.
The caller-supplied put options.
Put options with an expiration applied where appropriate.
Accessor for the Workers KV namespace binding (
kv_namespacesinwrangler.json).Example
Author
Bayu Dwiyan Satria
Version
1.0.0
Since
1.0.0