API Reference
classes
Idbcache

@coasys/ad4m / Exports / IDBCache

Class: IDBCache<T>

PersistentCache — two-tier persistent key-value cache abstraction.

Provides an IndexedDB-backed implementation for browsers and a no-op NullCache fallback for Node.js / environments without IndexedDB.

Design goals:

  • Lazy open: IDB connection is deferred until first access
  • Fire-and-forget writes: put() resolves immediately (best-effort persistence)
  • Graceful degradation: all IDB errors resolve (never reject), so callers never need try/catch around cache operations
  • Tree-shakeable: import only what you need

Type parameters

NameType
Tunknown

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

• new IDBCache<T>(dbName, storeName)

Type parameters

NameType
Tunknown

Parameters

NameType
dbNamestring
storeNamestring

Defined in

core/src/cache/PersistentCache.ts:32 (opens in a new tab)

Properties

#dbName

• Private #dbName: string

Defined in

core/src/cache/PersistentCache.ts:27 (opens in a new tab)


#dbPromise

• Private #dbPromise: Promise<IDBDatabase> = null

Defined in

core/src/cache/PersistentCache.ts:29 (opens in a new tab)


#storeName

• Private #storeName: string

Defined in

core/src/cache/PersistentCache.ts:28 (opens in a new tab)


#version

• Private #version: number = 1

Defined in

core/src/cache/PersistentCache.ts:30 (opens in a new tab)

Methods

#open

▸ Private #open(): Promise<IDBDatabase>

Returns

Promise<IDBDatabase>

Defined in

core/src/cache/PersistentCache.ts:37 (opens in a new tab)


clear

▸ clear(): Promise<void>

Returns

Promise<void>

Implementation of

PersistentCache.clear

Defined in

core/src/cache/PersistentCache.ts:100 (opens in a new tab)


delete

▸ delete(key): Promise<void>

Parameters

NameType
keystring

Returns

Promise<void>

Implementation of

PersistentCache.delete

Defined in

core/src/cache/PersistentCache.ts:85 (opens in a new tab)


get

▸ get(key): Promise<T>

Parameters

NameType
keystring

Returns

Promise<T>

Implementation of

PersistentCache.get

Defined in

core/src/cache/PersistentCache.ts:55 (opens in a new tab)


put

▸ put(key, value): Promise<void>

Parameters

NameType
keystring
valueT

Returns

Promise<void>

Implementation of

PersistentCache.put

Defined in

core/src/cache/PersistentCache.ts:70 (opens in a new tab)