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

Using multiple CacheModules resolve to same cache manager in v10.3.0 #13058

Closed
2 tasks done
drdreo opened this issue Jan 16, 2024 · 1 comment
Closed
2 tasks done

Using multiple CacheModules resolve to same cache manager in v10.3.0 #13058

drdreo opened this issue Jan 16, 2024 · 1 comment
Labels
needs triage This issue has not been looked into type: bug 😭

Comments

@drdreo
Copy link

drdreo commented Jan 16, 2024

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

No response

NestJS version

10.2.10 --> 10.3.0

Describe the regression

The cache manager is shared between multiple cache modules since the upgrade on @nestjs/common@10.3.0 and @nestjs/core@10.3.0.
I have singled out these 2 dependencies, as latest @nestjs/cache-manager changes seem to be not causing this.

To verify caching aint working as expected run npx nx test

The cache modules can be found at src/app/caches. I created a cat-cache and a user-cache. They should be configured differently (ttl, max,..) and not share the same manager since cat and user IDs can overlap.

In the provided repo, there is also a working branch.

Minimum reproduction code

https://github.com/drdreo/nest-cache-bug

Input code

Registering a feature cache module will share same cache manager, like:

@Module({
    imports: [CacheModule.register({ ttl: 60 * 10 * 1000, max: 1000 })],
    providers: [CatCacheService],
    exports: [CatCacheService]
})
export class CatCacheModule {}

Expected behavior

Different cache modules can be configured differently. I would expect that the cache manager is not shared between the two modules and one cache does not include keys and values from others.

Other

No response

@drdreo drdreo added needs triage This issue has not been looked into type: bug 😭 labels Jan 16, 2024
@drdreo drdreo changed the title Using multiple CacheModules resolve to same cache manager Using multiple CacheModules resolve to same cache manager in v10.3.0 Jan 16, 2024
@kamilmysliwiec
Copy link
Member

nestjs/cache-manager#203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: bug 😭
Projects
None yet
Development

No branches or pull requests

2 participants