store.get()
读取一个键的当前字节值和乐观并发版本。键不存在时返回 null。
Syntax
const entry = await host.store.get(key);
Parameters
key: string:规范化后 UTF-8 字节数不超过 store.maxKeyBytes 的应用键。
Return value
{ value: Bytes, version: u64 } | null
Examples
const entry = await host.store.get('settings/theme');
const theme = entry ? new TextDecoder().decode(entry.value) : 'system';
Errors
特有错误:denied、invalid-key、sink-too-small、limit-exceeded。不存在不是错误。
Requirements
- 能力:
host:store.get - 用户激活:不需要
- 信任档位:green