@hateoas-ts/resource - v1.4.3
    Preparing search index...

    Interface Cache

    Interface for caching resource State objects.

    Implementations provide storage strategies (e.g., memory, persistent) for caching fetched resource states to improve performance.

    interface Cache {
        clear: () => void;
        delete: (uri: string) => void;
        get: <T extends Entity<any, Record<string, any>>>(
            uri: string,
        ) => State<T> | null;
        has: (uri: string) => boolean;
        store: (state: State) => void;
    }

    Implemented by

    Index

    Properties

    Properties

    clear: () => void

    Clears all entries from the cache.

    delete: (uri: string) => void

    Removes a State from the cache.

    Type Declaration

      • (uri: string): void
      • Parameters

        • uri: string

          The absolute URI to remove

        Returns void

    get: <T extends Entity<any, Record<string, any>>>(
        uri: string,
    ) => State<T> | null

    Retrieves a cached State by its URI.

    Type Declaration

      • <T extends Entity<any, Record<string, any>>>(uri: string): State<T> | null
      • Type Parameters

        • T extends Entity<any, Record<string, any>>

          The entity type of the cached state

        Parameters

        • uri: string

          The absolute URI of the resource

        Returns State<T> | null

        The cached State or null if not found

    has: (uri: string) => boolean

    Checks if a State exists in the cache.

    Type Declaration

      • (uri: string): boolean
      • Parameters

        • uri: string

          The absolute URI to check

        Returns boolean

        true if the URI is cached

    store: (state: State) => void

    Stores a State object in the cache.

    The state will be cloned before storing to prevent mutation.

    Type Declaration

      • (state: State): void
      • Parameters

        • state: State

          The State object to cache

        Returns void