MemoryDataStore
Class: MemoryDataStore
Defined in: storage/data-store.ts:202
In-memory DataStore implementation — useful for tests and ephemeral sandboxes.
Remarks
Same surface as FileDataStore (including the synchronous helpers the Web Storage shims need) but with no persistence. Contents are lost when the process exits.
Example
import { SnapcapClient, MemoryDataStore } from "@snapcap/native";
const client = new SnapcapClient({
dataStore: new MemoryDataStore(),
username, password,
});Implements
Constructors
Constructor
new MemoryDataStore(): MemoryDataStore;Returns
MemoryDataStore
Methods
delete()
delete(key: string): Promise<void>;Defined in: storage/data-store.ts:226
Delete the entry at key. No-op if the key is absent.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The storage key to remove. |
Returns
Promise<void>
Implementation of
get()
get(key: string): Promise<
| Uint8Array<ArrayBufferLike>
| undefined>;Defined in: storage/data-store.ts:216
Read the value at key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The storage key. |
Returns
Promise<
| Uint8Array<ArrayBufferLike>
| undefined>
The stored bytes, or undefined if the key is absent.
Implementation of
getSync()
getSync(key: string):
| Uint8Array<ArrayBufferLike>
| undefined;Defined in: storage/data-store.ts:206
Synchronous read — for Web Storage shims that can't await.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
| Uint8Array<ArrayBufferLike>
| undefined
keys()
keys(prefix?: string): string[];Defined in: storage/data-store.ts:237
Iterate stored keys, optionally filtered by prefix.
Parameters
| Parameter | Type | Description |
|---|---|---|
prefix? | string | Optional prefix filter. When omitted, every key is returned. |
Returns
string[]
A snapshot array of matching keys.
set()
set(key: string, value: Uint8Array): Promise<void>;Defined in: storage/data-store.ts:221
Write value to key, overwriting any prior entry. Implementations
SHOULD make this durable before resolving.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The storage key. |
value | Uint8Array | The bytes to store. Treat as immutable; the SDK never mutates the supplied buffer after passing it. |
Returns
Promise<void>
Implementation of
setSync()
setSync(key: string, value: Uint8Array): void;Defined in: storage/data-store.ts:211
Synchronous variant of MemoryDataStore.set.
Parameters
| Parameter | Type |
|---|---|
key | string |
value | Uint8Array |
Returns
void