Storage.from
Wraps a base storage with a key prefix and request deduplication. All keys are automatically prefixed with {key}:.
Usage
import { } from 'viem/tempo'
const = .()
const = .(, { : 'tempo' })
await .('foo', 'bar')
// Stored under "tempo:foo" in the base storage.
const = await .('tempo:foo')
'bar'Parameters
storage
- Type:
Storage
The base storage to wrap.
Options for the wrapped storage.
options.key
- Type:
string | undefined
Key prefix prepended to all storage keys. If omitted, keys are passed through without a prefix.
Return Value
type ReturnType = StorageA Storage instance that prefixes all keys and deduplicates concurrent getItem calls.