tirke / node-cache-manager-stores Goto Github PK
View Code? Open in Web Editor NEWIORedis and Mongo store for node-cache-manager.
License: MIT License
IORedis and Mongo store for node-cache-manager.
License: MIT License
It would be good to make the cache collection for mongodb to be configurable since you might want to have different collections for different caches in the same mongo instance.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)node
, @types/node
)docker-compose.yml
redis 7.2.5
.github/workflows/main.yml
actions/checkout v4
pnpm/action-setup v4.0.0
actions/setup-node v4
supercharge/redis-github-action 1.8.0
supercharge/mongodb-github-action 1.11.0
codecov/codecov-action v4
actions/checkout v4
pnpm/action-setup v4.0.0
actions/setup-node v4
changesets/action v1
.github/workflows/pr.yml
actions/checkout v4
pnpm/action-setup v4.0.0
actions/setup-node v4
supercharge/redis-github-action 1.8.0
supercharge/mongodb-github-action 1.11.0
codecov/codecov-action v4
.node-version
node 20.14.0
package.json
ioredis ^5.3.2
mongodb ^6.3.0
@changesets/cli 2.27.5
@svitejs/changesets-changelog-github-compact 1.1.0
@swc/cli 0.3.12
@swc/core 1.5.28
@swc/jest 0.2.36
@types/jest 29.5.12
@types/node 20.14.2
@typescript-eslint/eslint-plugin 7.13.0
@typescript-eslint/parser 7.13.0
cache-manager 5.6.1
eslint 9.4.0
eslint-config-prettier 9.1.0
eslint-plugin-import 2.29.1
jest 29.7.0
prettier 3.3.2
ts-node 10.9.2
tsup 8.1.0
typescript 5.4.5
zx 8.1.2
pnpm 9.3.0
packages/node-cache-manager-ioredis/package.json
ioredis ^5.2.2
node >=14.20
packages/node-cache-manager-mongodb/package.json
mongodb ^6.0.0
node >=14.20
Sorry to bother you, I'm new in Redis, I use this library to connect Redis in Nextjs, And in my project, I have to support single-point and Cluster two modes. the Cluster is ok, But the single-point mode isn't working, and then I delete instanceConfig
. It's working
Here's my change, I wonder what the instanceConfig
is and how it's different from the default
node-cache-manager
is made with typescript doesn't need external types
I get this error when I try to inject Redistore inside my CachingInterceptor.
Code :
import { CacheModule, Module } from '@nestjs/common'
import RedisStore from '@tirke/node-cache-manager-ioredis'
import type { ClientOpts } from 'redis3'
import { AppConfig } from '@hublo/configuration/configs'
import type { CachedAppConfig } from './configuration'
@Module({
imports: [
CacheModule.registerAsync<ClientOpts>({
isGlobal: true,
inject: [AppConfig],
useFactory: (config: CachedAppConfig) => {
return config.useRedisStore
? {
store: RedisStore,
host: config.cache.redisHost,
port: config.cache.redisPort,
ttl: config.cache.ttl,
}
: {}
},
}),
],
})
Bug description :
TypeError: Cannot read properties of undefined (reading 'bind')
at Object.caching (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/cache-manager@4.1.0/node_modules/cache-manager/lib/caching.js:306:31)
at InstanceWrapper.useFactory [as metatype] (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+common@9.0.8_mgy7w2bm3yhmntrbe3boyroj6m/node_modules/@nestjs/common/cache/cache.providers.js:20:32)
at Injector.instantiateClass (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+core@9.0.8_t6wygpagnzylhnpg25zual64b4/node_modules/@nestjs/core/injector/injector.js:343:55)
at callback (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+core@9.0.8_t6wygpagnzylhnpg25zual64b4/node_modules/@nestjs/core/injector/injector.js:53:45)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Injector.resolveConstructorParams (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+core@9.0.8_t6wygpagnzylhnpg25zual64b4/node_modules/@nestjs/core/injector/injector.js:132:24)
at Injector.loadInstance (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+core@9.0.8_t6wygpagnzylhnpg25zual64b4/node_modules/@nestjs/core/injector/injector.js:57:13)
at Injector.loadProvider (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+core@9.0.8_t6wygpagnzylhnpg25zual64b4/node_modules/@nestjs/core/injector/injector.js:84:9)
at async Promise.all (index 3)
at InstanceLoader.createInstancesOfProviders (/Users/remydeme/WebstormProjects/hublo/monorepo/node_modules/.pnpm/@nestjs+core@9.0.8_t6wygpagnzylhnpg25zual64b4/node_modules/@nestjs/core/injector/instance-loader.js:47:9)
This repo respectively its npm package is missing license information.
I am using your package in a project where we have to run a license check on installed npm packages, but without license info being added for your npm package, the check fails and I have to exclude the package from the checks which can become troublesome to continue using it without having a clear license definition.
As this package is based on https://github.com/dabroek/node-cache-manager-ioredis, I'd assume you will just continue using same license format as its predecessor, which is MIT.
So, I'd be glad if you could add a license definition in form of a LICENSE.md to the repo respectively npm package.
Hi
Thanks for rewriting this package. We updated the cache-manager to the latest version(5.0.1) and things started breaking ever since. Please see below the error we get.
private configRedisStore(): void {
const configObj: any = {
store: IoRedisStore,
clusterConfig: null,
host: null,
port: null,
ttl: null,
connectTimeout: 5000,
tls: null,
// eslint-disable-next-line camelcase
socket_keepalive: true
};
if (
this.dsConfig.node.app_env.toUpperCase() === DSServerConstants.PROD_ENV ||
this.dsConfig.node.app_env.toUpperCase() === DSServerConstants.UAT_ENV ||
this.dsConfig.node.app_env.toUpperCase() === DSServerConstants.DEV_ENV
) {
configObj.tls = {};
}
if (this.dsConfig.aws.elasticCache.clusterConfig) {
configObj.clusterConfig = this.dsConfig.aws.elasticCache.clusterConfig;
} else {
configObj.host = this.dsConfig.aws.elasticCache.host;
configObj.port = this.dsConfig.aws.elasticCache.port;
}
// Promisify all the functions
this.redisCache = caching(configObj);
const cacheStore: Store = this.redisCache.store as Store;
this.redisClient = cacheStore.getClient();
}
Error
2022-10-14 10:32:25.831 [error] - TypeError: Cannot read properties of undefined (reading 'getClient')
It looks like the cacheStore is undefined.
According to some documentation on cache-manager, it looks like they have moved to milliseconds from seconds from version 4 to 5:
I'm sending the values in to cache something with milliseconds and I'm getting very high ttl values in redis. Is there some specification on whether we should be using seconds vs milliseconds?
const CACHE_TTL_ROLES = 60 * 5 * 1000 // 5 Mins
await this.cacheManager.set(localCacheKey, response.data, CACHE_TTL_ROLES)
redis> ttl "MY-KEY"
(integer) 299987 (300000)
I'm trying to use node-cache-manager-ioredis
but struggling on importing from the package, as described in the readme:
import { ioRedisStore } from '@tirke/node-cache-manager-ioredis';
gives me the following error:
Error: Module not found: Error: Package path . is not exported from package [...]/node_modules/@tirke/node-cache-manager-ioredis (see exports field in [...]/node_modules/@tirke/node-cache-manager-ioredis/package.json)
The project is pretty much standard:
Any advice?
I can't find a way to close the connection using @tirke/node-cache-manager-ioredis, either in the cache manager or the store implementation. Does anyone have insights on how to call redis.disconnect() or redis.quit()?
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
โ TCPWRAP
33 | public static async getInstance(): Promise<ICacheService> {
34 | if (!RedisStoreProvider.instance) {
> 35 | const cache: Cache = await caching(ioRedisStore, redisConfig);
| ^
36 | cache.on('error', (error: unknown) => {
37 | logError('Redis store error', error);
38 | });
at node_modules/ioredis/built/connectors/StandaloneConnector.js:44:21
at StandaloneConnector.connect (node_modules/ioredis/built/connectors/StandaloneConnector.js:43:16)
at node_modules/ioredis/built/Redis.js:121:64
at EventEmitter.connect (node_modules/ioredis/built/Redis.js:103:25)
at new Redis (node_modules/ioredis/built/Redis.js:77:18)
at new RedisStore (node_modules/@tirke/node-cache-manager-ioredis/index.js:57:21)
at ioRedisStore (node_modules/@tirke/node-cache-manager-ioredis/index.js:124:10)
at caching (node_modules/cache-manager/dist/caching.js:19:29)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.