Closed KerryRitter closed 6 years ago
https://www.npmjs.com/package/node-cache would probably be an ideal package to support "under the hood" of the Nest provider.
I'd be happy to write this provider if you think it's a good idea, @kamilmysliwiec.
Yeah, go for it! Maybe, let's create an interceptor that we could even put in the @nestjs/common
as a built-in interceptor. CacheInterceptor
sounds quite good :)
Hi @KerryRitter, any updates here? 🔥
I haven't been able to do much lately but this is on my to-do! Anyone is free to take over, happy to help where I can
+1
+1
CacheModule
just landed in 5.3.0. Read more here https://docs.nestjs.com/techniques/caching
it wold be nice to have Method level @Cache annotation as well for service methods
@Injectable()
export class ProductService {
@Cache(myStore, { ttl: 60 })
public async getProducts(): Promise<string[]> {
// return seed data from database
return [...];
}
}
Is there a way to expose some generic cache (CacheStore) to have get and set methods to cache any arbitrary data?!
@danil-z I was able to do this by injecting the cache manager into my cache service, you can checkout an example at https://github.com/kyle-mccarthy/nest-next-starter/blob/master/src/cache/cache.service.ts
@danil-z this issue has been closed, it would be great to make another issue for this request.
@kamilmysliwiec how to invalidate cache ?
common use case
only manually ?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm submitting a...
What is the motivation / use case for changing the behavior?
Supporting a simple in-memory cache provider out of the box would be a great, useful feature. Probably as an external installable package, i.e. @nest/cache. See https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-2.0 for an example.