ThemeParks.wiki Parks API - v2.0.0
    Preparing search index...

    Class CacheLib

    Index

    Constructors

    Methods

    • Remove all expired entries from cache

      Returns number

    • Delete every entry in the cache. Returns number deleted.

      Returns number

    • Delete all cache entries whose key contains the given class name. Matches both plain keys (ClassName:method:args) and prefixed keys (prefix:ClassName:method:args). Returns the number of deleted entries.

      Parameters

      • className: string

      Returns number

    • Parameters

      • key: string

      Returns void

    • Enable temporary mode - use in-memory cache that doesn't persist Must be called before any cache operations

      Returns void

    • Enforce cache size limit by removing least recently accessed entries. Called periodically from set() rather than on every write.

      Returns void

    • Parameters

      • key: string

      Returns any

    • Get all cache entries with metadata

      Returns {
          expiresAt: number;
          isExpired: boolean;
          key: string;
          lastAccess: number;
          size: number;
          value: any;
      }[]

    • Parameters

      • key: string

      Returns boolean

    • Check if cache is in temporary mode

      Returns boolean

    • Type Parameters

      • T

      Parameters

      • key: string
      • value: T
      • ttlSeconds: number = 60

      Returns void

    • Start automatic cleanup of expired entries

      Returns void

    • Get cache statistics

      Returns { active: number; expired: number; total: number }

    • Stop automatic cleanup

      Returns void

    • Cache-with-dedup wrapper. Concurrent callers on a cache miss for the same key share a single execution rather than each running fn independently.

      Type Parameters

      • T

      Parameters

      • key: string
      • fn: () => T | Promise<T>
      • ttl: number | ((result: T) => number | Promise<number>)

        Either a fixed TTL in seconds, or a callback that derives a TTL from the function's result (e.g. for OAuth tokens that expire on a server-supplied schedule).

      Returns Promise<T>