A Level-based cache implementation for storing and retrieving DID resolution results.

This cache uses LevelDB for storage, allowing data persistence across process restarts or browser refreshes. It's suitable for both Node.js and browser environments.

Remarks

The LevelDB cache keeps data in memory for fast access and also writes to the filesystem in Node.js or indexedDB in browsers. Time-to-live (TTL) for cache entries is configurable.

Example

const cache = new DidResolverCacheLevel({ ttl: '15m' });

Implements

Constructors

Properties

Methods

Constructors

Properties

cache: AbstractLevel<string | Uint8Array | Buffer, string, string>

The underlying LevelDB store used for caching.

ttl: number

The time-to-live for cache entries in milliseconds.

Methods

  • Clears all entries from the cache.

    Returns Promise<void>

    A promise that resolves when the operation is complete.

  • Closes the underlying LevelDB store.

    Returns Promise<void>

    A promise that resolves when the store is closed.

  • Deletes a DID resolution result from the cache.

    Parameters

    • did: string

      The DID string used as the key for deletion.

    Returns Promise<void>

    A promise that resolves when the operation is complete.

  • Retrieves a DID resolution result from the cache.

    If the cached item has exceeded its TTL, it's scheduled for deletion and undefined is returned.

    Parameters

    • did: string

      The DID string used as the key for retrieving the cached result.

    Returns Promise<void | DidResolutionResult>

    The cached DID resolution result or undefined if not found or expired.

  • Stores a DID resolution result in the cache with a TTL.

    Parameters

    • did: string

      The DID string used as the key for storing the result.

    • value: DidResolutionResult

      The DID resolution result to be cached.

    Returns Promise<void>

    A promise that resolves when the operation is complete.