Interface IPersistMeasureInstance

Per-bucket measure cache persistence instance interface. Used by Cache.file for caching external API responses.

Supports soft delete: removed entries stay on disk with removed: true flag and are filtered out by read/list operations.

Custom adapters should implement this interface to override the default file-based measure cache behavior.

interface IPersistMeasureInstance {
    listMeasureData(): AsyncGenerator<string>;
    readMeasureData(key: string): Promise<MeasureData>;
    removeMeasureData(key: string): Promise<void>;
    waitForInit(initial: boolean): Promise<void>;
    writeMeasureData(data: MeasureData, key: string, when: Date): Promise<void>;
}

Implemented by

Methods

  • Iterate all non-removed entry keys for this bucket.

    Returns AsyncGenerator<string>

    AsyncGenerator yielding entry keys

  • Read cached entry by key.

    Parameters

    • key: string

      Cache key within the bucket

    Returns Promise<MeasureData>

    Promise resolving to cached value, or null if not found or soft-deleted

  • Soft-delete an entry by setting its removed flag. File stays on disk, but subsequent reads return null.

    Parameters

    • key: string

      Cache key within the bucket

    Returns Promise<void>

    Promise that resolves when removal is complete

  • Initialize storage for this bucket.

    Parameters

    • initial: boolean

      Whether this is the first initialization

    Returns Promise<void>

    Promise that resolves when initialization is complete

  • Write entry to cache.

    Parameters

    • data: MeasureData

      Data to cache

    • key: string

      Cache key within the bucket

    • when: Date

    Returns Promise<void>

    Promise that resolves when write is complete