0

I want to cache a query result on per request basis. Because I need that query in multiple places. And I want to cache that query on request and use it whenever and wherever I want. And at the end of the request-response cycle it should expire . Here I found a solution but there is a discussion stating it would be dangerous

Can someone please tell me how to achieve this.

Community
  • 1
  • 1
Vaibhav Jain
  • 5,287
  • 10
  • 54
  • 114

1 Answers1

1

You could modify the solution proposed here to use per-request locmemcache instances, instead of a global cache per thread.

You could then use the middleware's process_response function to then cleanup the local cache.

Community
  • 1
  • 1
bvanvugt
  • 1,212
  • 1
  • 8
  • 15