Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of [email protected] ? #516

Closed
1 task done
xavierraffin opened this issue Oct 8, 2024 · 9 comments
Closed
1 task done

Support of [email protected] ? #516

xavierraffin opened this issue Oct 8, 2024 · 9 comments

Comments

@xavierraffin
Copy link

xavierraffin commented Oct 8, 2024

Is there an existing issue that is already proposing this?

  • 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

@xavierraffin
Copy link
Author

It seems that there is a PR: #501 (from this Apr 2023 ticket??? #3)

But that will be nicer to get a Cache Store as well

@xavierraffin xavierraffin mentioned this issue Oct 8, 2024
2 tasks
@xavierraffin
Copy link
Author

PR on this: #508

@ArcherGu
Copy link

yes, same issue

@mghizzo
Copy link

mghizzo commented Oct 10, 2024

+1

@nodegin
Copy link

nodegin commented Oct 11, 2024

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

@jaredwray
Copy link

Adding this here as there is working being done to move to cache-manager v6: #508

@kamilmysliwiec
Copy link
Member

Let's track this here #508

We're going to support v6 in the next major release

@bluin4308
Copy link

Pls, add a remark to docs, that NestJS doesn't currently support cache-manager@6.

@The-True-Hooha
Copy link

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

@MickL MickL mentioned this issue Nov 15, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants