Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache not expiring #15

Open
matishadow opened this issue Nov 20, 2018 · 1 comment
Open

Cache not expiring #15

matishadow opened this issue Nov 20, 2018 · 1 comment

Comments

@matishadow
Copy link

Most of the times the cache fails to expire in my code.
Maybe you have an idea what I'm doing wrong. Any help would be greatly appreciated.

Here is the code directly using FluentCache:
https://github.com/matishadow/GimmeDatAPI/blob/develop/GimmeDatAPI.Web/Controllers/ZascianekDataController.cs

And here is the GetZascianekExpireAfter method which result is passed to ExpireAfter. It aims to get TimeSpan which is remaining to 7 PM (19:00)
https://github.com/matishadow/GimmeDatAPI/blob/develop/GimmeDatAPI.Cache/CacheInvalidation.cs

@evan-rash
Copy link
Owner

Based on a quick look at your code it does seem like it should be working the way you intend.

What about writing a test case demonstrating the issue, without all the rest of the app code? It seems like a good test case would:

  1. setup a cached method with expiration set to 30 seconds in the future
  2. get the item & confirm it was retrieved from the cache by asserting that the cached item version = 0
  3. wait 5 seconds
  4. get the item again & confirm it was retrieved from the cache by asserting that the cached item version = 0
  5. wait the remaining time + some short buffer
  6. get the item again and confirm that the previous value expired by asserting that the cached item version = 1

A test case like the above demonstrating the issue would go a long way to figuring out what's not working properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants