Jaxelr / Nancy.RapidCache

A library to asynchronously cache responses on NancyFx Modules.
MIT License
6 stars 2 forks source link

Controller method is always called - even if cached response exists and sent back. #66

Closed duginov closed 5 years ago

duginov commented 5 years ago

Describe the question

I discovered that regardless of existing cache entry controller's method is always called in a separate thread. Tracing shows that module is created twice on different threads (two constructor calls), one thread finds cached response in the store and return it to caller. However on a different thread "regular" call is executed - potentially accessing expensive resource which looks like waste. Is that by design or it's a bug? One would probably expect no attempt to execute controller's code if cached response is available.

Steps to reproduce (if applicable)

In Nancy.RapidCache.SampleApplication.Net452, put tracepoints on module's constructor and the actual code responding to the call. After first call (which creates cached response), on every request controller method executes. Screenshot: https://i.imgur.com/iSYY91h.png

Jaxelr commented 5 years ago

Hi, thanks for opening the issue, ill take a peek in the next few days since ive been sort of swamp. 👎

Edit: To be clear, no, it shouldnt be called if is on the CacheStore created and Non-Expired.

Jaxelr commented 5 years ago

Found the bug, I will be doing some regression testing from my part and hopefully will be posting soon a newer version of the lib via nuget.

Jaxelr commented 5 years ago

Just released 0.3.2 on nuget which should address this issue.