Support of `[email protected]` ?
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Is your feature request related to a problem? Please describe it
cache-manager 6 has been released (6.1.0 as of today).
But the installation of it with @nestjs/[email protected] gives warning on potential compatibility issues:
npm warn ERESOLVE overriding peer dependency
npm warn Found: [email protected]
npm warn node_modules/cache-manager
npm warn peer cache-manager@"<=5" from @nestjs/[email protected]
npm warn node_modules/@nestjs/cache-manager
npm warn @nestjs/cache-manager@"^2.2.2" from the root project
npm warn 1 more (the root project)
npm warn
npm warn Could not resolve dependency:
npm warn peer cache-manager@"<=5" from @nestjs/[email protected]
npm warn node_modules/@nestjs/cache-manager
npm warn @nestjs/cache-manager@"^2.2.2" from the root project
Indeed, cache-manager 6 switched from cache-manager-ioredis-yet to keyv (because of being "more actively maintained and have a larger community" as the npm cache manager page says.). This may require some code update (it did inside my code), or at least on the examples.
Describe the solution you'd like
A new release of @nestjs/cache-manager which supports the cache-manager 6 package.
If that could help, here is the cache interface I needed to create to make it work on v6:
import { CacheStore } from "@nestjs/common/cache/interfaces/cache-manager.interface";
import Keyv from "keyv";
export class KeyvStore implements CacheStore {
private keyv: Keyv<any>;
constructor(keyv: Keyv<any>) {
this.keyv = keyv;
}
async get<T>(key: string): Promise<T | undefined> {
return this.keyv.get(key);
}
async set<T>(key: string, value: T, ttl?: number): Promise<void> {
await this.keyv.set(key, value, ttl);
}
async del(key: string): Promise<void> {
await this.keyv.delete(key);
}
async reset(): Promise<void> {
await this.keyv.clear();
}
}
Maybe something you like to add in @nestjs/cache-manager ?
Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
No behavior changes
It seems that there is a PR: https://github.com/nestjs/cache-manager/pull/501 (from this Apr 2023 ticket??? https://github.com/nestjs/cache-manager/issues/3)
But that will be nicer to get a Cache Store as well
PR on this: https://github.com/nestjs/cache-manager/pull/508
yes, same issue
+1
same here
apps/backend/src/app/api/app.module.ts:50:7 - error TS2322: Type '() => Promise<{ store: RedisStore; }>' is not assignable to type '(...args: any[]) => CacheOptions<{ store: RedisStore; }> | Promise<CacheOptions<{ store: RedisStore; }>>'
was using cache-manager-ioredis-yet
Adding this here as there is working being done to move to cache-manager v6: https://github.com/nestjs/cache-manager/pull/508
Let's track this here https://github.com/nestjs/cache-manager/pull/508
We're going to support v6 in the next major release
Pls, add a remark to docs, that NestJS doesn't currently support cache-manager@6.
Pls, add a remark to docs, that NestJS doesn't currently support cache-manager@6.
Just to support this, you get this error message when using cache-manager@6
cacheManager.caching is not a function