npm.io
0.3.1 • Published 7 months ago

@extra-memoize/memory-cache

Licence
MIT
Version
0.3.1
Deps
2
Size
41 kB
Vulns
0
Weekly
0

@extra-memoize/memory-cache

Install

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

API

Cache
class Cache<T> implements ICache<T> {
  clear(): void
}
LRUCache
class LRUCache<T> implements ICache<T> {
  constructor(limit: number)

  delete(key: string): void
  clear(): void
}

The classic LRU cache.

ExpirableCache
class ExpirableCache<T> implements ICache<T> {
  constructor(timeToLive: number /*ms*/)

  clear(): void
}

The classisc expirable cache.

ExpirableCacheWithStaleWhileRevalidate
class ExpirableCacheWithStaleWhileRevalidate<T> implements IStaleWhileRevalidateCache<T> {
  constructor(timeToLive: number /*ms*/, staleWhileRevalidate: number /*ms*/)
}
ExpirableCacheWithStaleIfError
class ExpirableCacheWithStaleIfError<T> implements IStaleIfErrorCache<T> {
  constructor(timeToLive: number /*ms*/, staleIfError: number /*ms*/)
}
ExpirableCacheWithStaleWhileRevalidateAndStaleIfError
class ExpirableCacheWithStaleWhileRevalidateAndStaleIfError<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
  constructor(
    timeToLive: number /*ms*/
  , staleWhileRevalidate: number /*ms*/
  , staleIfError: number /*ms*/
  )
}
TLRUCache
class TLRUCache<T> implements ICache<T> {
  constructor(limit: number, timeToLive: number /*ms*/)

  clear(): void
}

The classic TLRU cache.

TLRUCacheWithStaleWhileRevalidate
class TLRUCacheWithStaleWhileRevalidate<T> implements IStaleWhileRevalidateCache<T> {
  constructor(limit: number, timeToLive: number /*ms*/, staleWhileRevalidate: number /*ms*/)
}
TLRUCacheWithStaleIfError
class TLRUCacheWithStaleIfError<T> implements IStaleIfErrorCache<T> {
  constructor(limit: number, timeToLive: number /*ms*/, staleIfError: number /*ms*/)
}
TLRUCacheWithStaleWhileRevalidateAndStaleIfError
class TLRUCacheWithStaleWhileRevalidateAndStaleIfError<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
  constructor(
    limit: number
  , timeToLive: number /*ms*/
  , staleWhileRevalidate: number /*ms*/
  , staleIfError: number /*ms*/
  )
}