DDNet - v0.10.1
    Preparing search index...

    Class CacheManager<T>

    A simple cache manager.

    Type Parameters

    • T

      The type of the cached objects.

    Index

    Constructors

    Methods

    Constructors

    • Construct a new CacheManager instance.

      Type Parameters

      • T

        The type of the cached objects.

      Parameters

      • namespace: string

        The namespace to use for this cache.

      • Optionalttl: number

        The TTL (Time-To-Live) for objects in cache.

        7200000 // 2 hours
        

      Returns CacheManager<T>

    Methods

    • Gets the value of the given key from the cache.

      Parameters

      • key: string

        The key to get.

      Returns Promise<T | undefined>

    • Checks if the cache has a value for the given key.

      Parameters

      • key: string

        The key to check.

      Returns Promise<boolean>

    • Sets a key to a value in the cache.

      Parameters

      • key: string

        The key to set.

      • value: T

        The value to set.

      Returns Promise<void>

    • Sets the CacheManager.ttl.

      Parameters

      • OptionalttlMS: number

        If provided, sets the CacheManager.ttl to this value, otherwise uses the default value.

      Returns void