0.0.1 • Published 4 months ago

@forts/resilience4ts-cache v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

@forts/resilience4ts-cache

Cache pattern implementation for resilience4ts.

Installation

npm install @forts/resilience4ts-cache

Usage

import { Cache } from '@forts/resilience4ts-cache';

const cache = Cache.of('my-cache', {
  extractKey: (...args: Parameters<MyDecoratedMethod>) => UniqueId, // Function that returns a unique id for the call from the decorated function args.
  ttl: 1000, // Time to live in milliseconds.
  maxCapacity: 100, // Maximum number of entries in the cache.
});

const result = await cache.on(async () => {
  // do something
});

Options

const cache = Cache.of('my-cache', {
  extractKey: (...args: Parameters<MyDecoratedMethod>) => UniqueId, // Function that returns a unique id for the call from the decorated function args.
  expiration: 1000, // Time to live in milliseconds.
  maxCapacity: 100, // Maximum number of entries in the cache.
});
0.0.1

4 months ago

0.0.0

4 months ago