Belin.io Core
    Preparing search index...

    Interface Cache

    Represents a cache.

    interface Cache {
        clear: () => Promise<void>;
        delete: (key: string) => Promise<void>;
        get: <T>(key: string) => Promise<null | T>;
        has: (key: string) => Promise<boolean>;
        set: (key: string, value: unknown, duration?: number) => Promise<Cache>;
    }

    Implemented by

    Index

    Properties

    Properties

    clear: () => Promise<void>

    Removes all entries from this cache.

    Type declaration

      • (): Promise<void>
      • Returns Promise<void>

        Resolves when this cache has been cleared.

    delete: (key: string) => Promise<void>

    Removes the value associated with the specified key.

    Type declaration

      • (key: string): Promise<void>
      • Parameters

        • key: string

          The cache key.

        Returns Promise<void>

        Resolves when the value has been removed.

    get: <T>(key: string) => Promise<null | T>

    Gets the value associated with the specified key.

    Type declaration

      • <T>(key: string): Promise<null | T>
      • Type Parameters

        • T

        Parameters

        • key: string

          The cache key.

        Returns Promise<null | T>

        The cached value, or null if the key does not exist.

    has: (key: string) => Promise<boolean>

    Gets a value indicating whether this cache contains the specified key.

    Type declaration

      • (key: string): Promise<boolean>
      • Parameters

        • key: string

          The cache key.

        Returns Promise<boolean>

        true if this cache contains the specified key, otherwise false.

    set: (key: string, value: unknown, duration?: number) => Promise<Cache>

    Associates a given value with the specified key.

    Type declaration

      • (key: string, value: unknown, duration?: number): Promise<Cache>
      • Parameters

        • key: string

          The cache key.

        • value: unknown

          The value to be cached.

        • Optionalduration: number

          The number of seconds in which the cached value will expire.

        Returns Promise<Cache>

        This instance.