Class CacheService<CacheValue>

class CacheService

  • common service to provide cache

Type Parameters

  • CacheValue = any

Hierarchy

Implements

Constructors

  • Protected

    Protected constructor -> use CacheService.create() WARN! - do not create directly.˜

    Type Parameters

    • CacheValue = any

    Parameters

    • backend: CacheBackend

      cache backend object

    • Optional params: { maker?: CacheKeyMakable; ns?: string; options?: CacheOptions }

      params to create service.

      • Optional maker?: CacheKeyMakable

        custom key-maker

      • Optional ns?: string

        (optional) namespace of cache key (default: '')

      • Optional options?: CacheOptions

        (optional) the final options to create()

    Returns CacheService<CacheValue>

Properties

backend: CacheBackend

Cache backend instance

maker of cache-key

ns: string

Namespace of cache key

options: CacheOptions

the final options to create this service.

DEF_CACHE_DEFAULT_TIMEOUT: number = ...

Default cache timeout

Static

ENV_CACHE_DEFAULT_TIMEOUT: "CACHE_DEFAULT_TIMEOUT" = 'CACHE_DEFAULT_TIMEOUT'

Environment variable name for default cache timeout

Static

ENV_CACHE_ENDPOINT: "CACHE_ENDPOINT" = 'CACHE_ENDPOINT'

Environment variable name for cache server endpoint

Static

NAMESPACE_DELIMITER: "::" = '::'

Namespace delimiter

Static

Methods

  • for convient, make another typed service.

    • it add type into key automatically.

    Returns

    the typed CacheService

    Parameters

    • type: string

      model-type like 'test'

    • delimiter: string = ':'

      (optional) delim bewteen type and key (default ':')

    Returns CacheService<any>

  • Get remaining time to live in milliseconds

    Returns

    • number of milliseconds to expire
    • undefined if the key does not exist
    • 0 if the key has no timeout

    Parameters

    Returns Promise<number>

Generated using TypeDoc