Type Alias ICacheResolver<TAdapters, TType>

ICacheResolver: { use(adapterName?: TAdapters): ICache<TType> }

Cache resolver contract for dynamically selecting and switching between cache adapters. Simplifies adapter management by providing a single interface to access registered cache implementations.

Typical usage:

  • Development: Use in-memory cache
  • Testing: Use no-op cache or mock
  • Production: Use Redis or distributed cache All without changing application code (just switch the configured adapter).

Type Parameters

  • TAdapters extends string = string

    Union type of registered adapter names (e.g., "memory" | "redis" | "memcached")

  • TType = unknown

    The type of values cached (optional, defaults to unknown)

    IMPORT_PATH: "@daiso-tech/core/cache/contracts"

Type declaration

  • use:function
    • Retrieves a cache adapter by name. If no adapter name is provided, uses the default registered adapter.

      Parameters

      • OptionaladapterName: TAdapters

        The name of the adapter to retrieve (optional). If not provided, uses the default adapter.

      Returns ICache<TType>

      The requested cache adapter instance

      If the specified adapter name is not registered

      If no adapter name is provided and no default adapter is defined