npm.io
3.1.28 • Published 1 year ago

@anchan828/nest-cache-manager-ioredis

Licence
MIT
Version
3.1.28
Deps
4
Size
24 kB
Vulns
0
Weekly
0
Stars
2

@anchan828/nest-cache-manager-ioredis

npm NPM

Description

Redis store for node-cache-manager using IORedis.

Installation

$ npm i --save @anchan828/nest-cache-manager-ioredis

Quick Start

import { redisStore } from "@anchan828/nest-cache-manager-ioredis";
import { caching } from "cache-manager";

caching({
  store: redisStore,
  host: "localhost",
});

Use AsyncLocalStorage

You can cache results of redis to AsyncLocalStorage<Map<string, any>>.

const asyncLocalStorage = new AsyncLocalStorage<Map<string, any>>();

caching({
  store: redisStore,
  host: "localhost",
  asyncLocalStorage: asyncLocalStorage,
});


...


asyncLocalStorage.run(new Map(), ()=>{
  ...
})

Notes

  • This package uses MessagePack for efficient serialization/deserialization.
    • The most obvious is to serialize/deserialize a Date object with JSON. JSON.parse does not support Date object, so you need to implement the receiver yourself. Checking and parsing properties one by one as strings is an inefficient and very time-consuming process.

License

MIT