nestjs / cache-manager

Cache manager module for Nest framework (node.js) 🗃
MIT License
125 stars 26 forks source link

Unable to call cacheManager properly when there is a cyclic dependency #341

Closed liaorg closed 6 months ago

liaorg commented 6 months ago

Is there an existing issue for this?

Current behavior

role.services.ts like this: ... @Inject(forwardRef(() => MenuService)) private readonly menuService: WrapperType, .....

base.service.ts : ..... async setCache(param: { value: any; key?: string; ttl?: Milliseconds }) { const { key = this.cacheKey, value, ttl } = param; return await this.cacheManager.set(key, value, ttl); } ......

============= unhandledRejection: TypeError: Cannot read properties of undefined (reading 'set') at RoleService.setCache (C:\work\dasplus\src\common\services\base.service.ts:45:40) at C:\work\dasplus\src\common\services\base.service.ts:38:24 at processTicksAndRejections (node:internal/process/task_queues:95:5)

Minimum reproduction code

Steps to reproduce

No response

Expected behavior

can use

Package version

^5.4.0

NestJS version

^10.3.3

Node.js version

v18.14.1

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 6 months ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.