dataloader icon indicating copy to clipboard operation
dataloader copied to clipboard

About caching in tutorial

Open hdlinh1808 opened this issue 3 years ago • 1 comments

Hi, Int the README.md, I found: This implementation contains a very basic cache that is intended only to be used for short lived DataLoaders (i.e. DataLoaders that only exist for the life of **an http request**). You may use your own implementation if you want. But when I test, I found that it cache for many requests. So I have the questions:

  • What is default of the cache (TTL)?
  • If I want cache for only the life of a http request, How can I make with only one dataloader object easily?

Thanks, Linh

hdlinh1808 avatar Nov 01 '22 15:11 hdlinh1808

Not sure if it can help, but you could consider to init the dataloader for each request then include it into the context of the request, rather than init the dataloader for the whole application. And in the last middleware of the request, you can call ClearAll for each dataloader to ensure you clean its memory.

vuon9 avatar Nov 01 '22 17:11 vuon9