Skip to content

extra-memoize/blackglory-cache-service

Repository files navigation

@extra-memoize/blackglory-cache-service

Install

npm install --save @extra-memoize/blackglory-cache-service
# or
yarn add @extra-memoize/blackglory-cache-service

API

AsyncCacheService

class AsyncCacheService<T> implements IAsyncCache<T> {
  constructor(
    client: CacheClient
  , namespace: string
  , timeToLive: number | null = null
  , toString: (value: T) => string = defaultToString
  , fromString: (text: string) => T = defaultFromString
  )
}

StaleWhileRevalidateAsyncCacheService

class StaleWhileRevalidateAsyncCacheService<T> implements IStaleWhileRevalidateAsyncCache<T> {
  constructor(
    client: CacheClient
  , namespace: string
  , timeToLive: number
  , staleWhileRevalidate: number
  , toString: (value: T) => string = defaultToString
  , fromString: (text: string) => T = defaultFromString
  )
}

StaleIfErrorAsyncCacheService

class StaleIfErrorAsyncCacheService<T> implements IStaleIfErrorAsyncCache<T> {
  constructor(
    client: CacheClient
  , namespace: string
  , timeToLive: number
  , staleIfError: number
  , toString: (value: T) => string = defaultToString
  , fromString: (text: string) => T = defaultFromString
  )
}

StaleWhileRevalidateAndStaleIfErrorAsyncCacheService

class StaleWhileRevalidateAndStaleIfErrorAsyncCacheService<T> implements IStaleWhileRevalidateAndStaleIfErrorAsyncCache<T> {
  constructor(
    client: CacheClient
  , namespace: string
  , timeToLive: number
  , staleWhileRevalidate: number
  , staleIfError: number
  , toString: (value: T) => string = defaultToString
  , fromString: (text: string) => T = defaultFromString
  )
}