better-buddy-share-backend
    Preparing search index...

    Class BaseCacheAbstract

    Base abstraction for DAOs that use a caching layer.

    Provides helper methods to interact with CacheService and maps underlying cache errors into DaoError subclasses.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cacheService: CacheService

    Instance of the CacheService used to perform cache operations.

    Methods

    • Get a value from cache by key.

      Returns null when the key does not exist.

      Type Parameters

      • T

        Expected type of the cached value.

      Parameters

      • key: string

        Cache key to read.

      Returns Promise<T | null>

      The value stored under the key or null if not present.

      DaoError when a cache-related error occurs.

    • Get multiple values from cache by an array of keys.

      If the underlying CacheService does not provide a batch get, this method falls back to parallel single gets.

      Type Parameters

      • T

        Expected type of each cached value.

      Parameters

      • keys: string[]

        Array of cache keys to read.

      Returns Promise<(T | null)[]>

      An array containing the values or nulls for missing keys.

      DaoError when a cache-related error occurs.

    • Set a value in cache with optional TTL.

      Type Parameters

      • T

        Type of the value to store.

      Parameters

      • key: string

        Cache key to set.

      • value: T

        Value to store.

      • OptionalttlSeconds: number

        Optional time-to-live in seconds.

      Returns Promise<void>

      DaoError when a cache-related error occurs.

    • Map low-level cache errors to DaoError subclasses.

      Parameters

      • error: any

        The original error thrown by the cache client.

      Returns DaoError

      A DaoError or a more specific subclass representing the failure.