@metreeca/http - v0.1.1
    Preparing search index...

    Interface Store

    Backing store for cached responses.

    Holds the responses a cache middleware is to answer from, so that entries live wherever the consumer needs them, whether in memory, on the file system or in a shared key-value service. A store keeps a private cache, so the entries it holds are to serve one user alone, however widely the service backing it is reached. Keys are opaque strings, computed by the middleware from the target URI of the request and from the header fields the response states as varying. The fragment plays no part, as it never reaches the origin server, so requests differing by fragment alone share one entry and invalidate it together.

    Note

    Retention is the store's own concern. Beyond the default memory store, which gives up the least recently used entries once its limit is reached, no implementation is provided: how many entries a store holds, and which it gives up first, are the consumer's to decide.

    interface Store {
        lookup(key: string): Promise<Entry | undefined>;
        insert(key: string, entry: Entry): Promise<void>;
        remove(key: string): Promise<void>;
    }
    Index
    • Retrieves an entry.

      Parameters

      • key: string

        The key of the entry to be retrieved

      Returns Promise<Entry | undefined>

      A promise resolving to the entry stored under key, or to undefined if the store holds none

    • Inserts an entry.

      Parameters

      • key: string

        The key the entry is to be stored under

      • entry: Entry

        The entry to be stored

      Returns Promise<void>

      A promise resolving when entry is stored

    • Removes an entry.

      States an outcome rather than a change: removing a key the store doesn't hold succeeds without doing anything, so a caller is free to remove a key without first checking for it.

      Parameters

      • key: string

        The key of the entry to be removed

      Returns Promise<void>

      A promise resolving when no entry is stored under key