Skip to main content
Version: Next

CacheManager

Index

Type Aliases

Cache

Cache<S>: { del: (key: string) => Promise<void>; get: <T>(key: string) => Promise<T | undefined>; reset: () => Promise<void>; set: (key: string, value: unknown, ttl?: Milliseconds) => Promise<void>; store: S; methodWrap: any; wrap: any }

Type parameters

CachingConfig

CachingConfig<T>: MemoryConfig | StoreConfig | FactoryConfig<T>

Type parameters

  • T

Config

Config: { isCacheable?: (val: unknown) => boolean; refreshThreshold?: Milliseconds; ttl?: Milliseconds }

FactoryConfig

FactoryConfig<T>: T & Config

Type parameters

  • T

FactoryStore

FactoryStore<S, T>: (config?: FactoryConfig<T>) => S | Promise<S>

Type parameters

  • S: Store
  • T: object = never

LRU

LRU: LRUCache<string, any>

MemoryCache

MemoryCache: Cache<MemoryStore>

MemoryConfig

MemoryConfig: { max?: number; shouldCloneBeforeSet?: boolean; sizeCalculation?: (value: unknown, key: string) => number } & Options & Config

MemoryStore

MemoryStore: Store & { calculatedSize: LRU[calculatedSize]; dump: LRU[dump]; load: LRU[load]; size: any }

Milliseconds

Milliseconds: number

MultiCache

MultiCache: Omit<Cache, store> & Pick<Cache[store], mset | mget | mdel>

Store

Store: { del: any; get: any; keys: any; mdel: any; mget: any; mset: any; reset: any; set: any; ttl: any }

StoreConfig

StoreConfig: Config

Stores

Stores<S, T>: memory | Store | FactoryStore<S, T>

Type parameters

WrapTTL

WrapTTL<T>: Milliseconds | (v: T) => Milliseconds

Type parameters

  • T

Functions

caching

  • Generic caching interface that wraps any caching library with a compatible interface.

createCache

  • Create cache instance by store (non-async).

memoryStore

  • Wrapper for lru-cache.

multiCaching

  • Module that lets you specify a hierarchy of caches.


    Type parameters