Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a smart cache. An instance of this class is required for any cached queries.

Hierarchy

  • Store

Index

Constructors

constructor

Methods

createQuery

  • createQuery<TRequestBody, TResult>(storageKey: string, resolver: (body: TRequestBody) => Promise<TResult>, initialBody: TRequestBody): Query<TRequestBody, TResult>
  • Creates a query, which is used to smartly cache the results of functions.

    Type parameters

    • TRequestBody

    • TResult

    Parameters

    • storageKey: string

      The key in the cache for this query. Must be unique within a store.

    • resolver: (body: TRequestBody) => Promise<TResult>

      The function to call in order to resolve the query. This function is not called until the first request.

        • (body: TRequestBody): Promise<TResult>
        • Parameters

          • body: TRequestBody

          Returns Promise<TResult>

    • initialBody: TRequestBody

      The initial parameter used.

    Returns Query<TRequestBody, TResult>

    Query<TRequestBody, TResult>

getCurrentValue

  • getCurrentValue<TResult>(storageKey: string): CacheResult<TResult>
  • Gets the most recent value from the store, given its storage key. This will never trigger a refetch even if the cache is dirty.

    Type parameters

    • TResult

    Parameters

    • storageKey: string

      The key of the entry to fetch.

    Returns CacheResult<TResult>

    CacheResult - The most recent value associated with this key, or an empty cache result if it does not exist.

getValue

  • getValue<TRequestBody, TResult>(storageKey: string, body: TRequestBody): CacheResult<TResult>
  • Gets a value from the store, given its storage key. This will never trigger a refetch even if the cache is dirty.

    Type parameters

    • TRequestBody

    • TResult

    Parameters

    • storageKey: string

      The key of the entry to fetch.

    • body: TRequestBody

      The body of the request you want to retrieve.

    Returns CacheResult<TResult>

    CacheResult - The most recent value associated with this key, or an empty cache result if it does not exist.

Legend

  • Constructor
  • Property

Generated using TypeDoc