Class LocalStorageCache

Local storage cache strategy with enhanced error handling

This cache strategy uses browser localStorage when available, with graceful fallback when running in Node.js or when localStorage is unavailable or restricted.

Hierarchy

  • LocalStorageCache

Implements

  • CacheStrategy

Constructors

Methods

Constructors

  • Create a new local storage cache

    Parameters

    • prefix: string = "bfapi_cache_"

      Prefix for cache keys

    Returns LocalStorageCache

Methods

  • Clear all cache entries with this prefix, with error handling

    Returns Promise<void>

  • Get a value from the cache with enhanced error handling

    Type Parameters

    • T

    Parameters

    • key: string

      Cache key

    Returns Promise<null | T>

    Cached value or null if not found, expired, or on error

  • Invalidate a cache entry with error handling

    Parameters

    • key: string

      Cache key

    Returns Promise<void>

  • Set a value in the cache with resilience features

    Type Parameters

    • T

    Parameters

    • key: string

      Cache key

    • value: T

      Value to cache

    • Optional ttl: number

      Time to live in milliseconds (optional)

    Returns Promise<void>

Generated using TypeDoc