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

Existing multicaching support not exposed in types #174

Open
2 of 4 tasks
adworacz opened this issue Sep 28, 2023 · 4 comments
Open
2 of 4 tasks

Existing multicaching support not exposed in types #174

adworacz opened this issue Sep 28, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@adworacz
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Technically, the code supports multicaching, as written here: https://github.com/nestjs/cache-manager/blob/master/lib/cache.providers.ts#L53-L59

However, the types set on the register function do not indicate any sort of array input support.

There's also no mention of multicaching support in the documentation

Minimum reproduction code

https://github.com/nestjs/cache-manager/blob/master/lib/cache.providers.ts#L53-L59

Steps to reproduce

No response

Expected behavior

Multicaching should be supported by the register and registerAsync methods.

Package version

2.0.1

NestJS version

10.0.5

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@adworacz adworacz added the bug Something isn't working label Sep 28, 2023
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@adworacz
Copy link
Author

adworacz commented Oct 2, 2023

I'm open to doing so. I'm not sure when I can invest the time just yet, got a few critical projects that need to see completion in the coming month.

@Djunnni
Copy link

Djunnni commented Oct 25, 2023

hello there 👋🏻
let you know more situation about this problem. if i can understand that. i want to try :)

@honguyenhaituan
Copy link

Hi @Djunnni,

There exists a way to set up multi-caching. I saw it in the test case:

CacheModule.register([
{
store: 'memory',
max: 100,
ttl: 50,
},
{
store: redisStore,
host: 'localhost',
port: 6379,
db: 0,
ttl: 50,
},
]),

But I think it is very hard to read CacheModuleOptions to know there is an existing way config like that.

export type CacheModuleOptions<
StoreConfig extends Record<any, any> = Record<string, any>,
> =
// Store-specific configuration takes precedence over cache module options due
// to how `createCacheManager` is implemented.
CacheManagerOptions &
StoreConfig & {
/**
* If "true', register `CacheModule` as a global module.
*/
isGlobal?: boolean;
};

So I suggest changing the type of CacheModuleOptions so everyone can easily set up when using the lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants