@anchan828/nest-cache-manager-async-local-storage
v2.0.75
Published
![npm](https://img.shields.io/npm/v/@anchan828/nest-cache-manager-async-local-storage.svg) ![NPM](https://img.shields.io/npm/l/@anchan828/nest-cache-manager-async-local-storage.svg)
Downloads
293
Readme
@anchan828/nest-cache-manager-async-local-storage
Description
AsyncLocalStorage store for node-cache-manager.
Installation
$ npm i --save @anchan828/nest-cache-manager-async-local-storage
Quick Start
import { asyncLocalStorageStore } from "@anchan828/nest-cache-manager-async-local-storage";
import { caching } from "cache-manager";
const asyncLocalStorage = new AsyncLocalStorage<Map<string, any>>();
const cache = caching({
store: asyncLocalStorageStore,
asyncLocalStorage,
});
asyncLocalStorage.run(new Map<string, any>(), () => {
cache.get("key");
});
Notes
- This package is a cache function that is enabled only during a request using AsyncLocalStorage.
- It is useful when the same data is retrieved from the database many times during a request, although it does not need to be cached permanently, such as in memory or Redis.