-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 Middleware - Update expiration for expired entry #1228
Conversation
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Thanks for the pull request, after seeing the point now, I wonder why we don't put the expiration time set at the bottom, after the check of the storages, when the other properties of the e record are set. |
I mean shortly before we set e.body |
@ReneWerner87 this is a good point. Updated the PR |
Thx |
Can you check the tests again, by the way, I also meant line 66, that could be omitted if you formulate a suitable condition for the else and the elseif. |
4250dbf
to
22bd92b
Compare
@ReneWerner87 right, updated the PR |
I think the first condition needs also the |
Perfect thx |
@ReneWerner87 oh, right. And this is a reminder that need to prepare PRs with a fresh mind :D |
Maybe we should use
What do you think |
Go to sleep now, look at it tomorrow and merge it, if the tests are okay |
Sounds like a plan ;) |
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@ReneWerner87 thanks. Noticed that the test has failed for one environment. I bet it's because memory storage managed to delete old entry before the next check https://github.com/gofiber/fiber/blob/master/internal/memory/memory.go#L72 |
I can add an optional parameter for |
yeah, sound good the failure was because one had made exactly in the time of the intervals actions of the test ? |
yeah, exactly. And this looks like a race condition. But now I'm thinking if changing of memory storage gc interval is a really good solution |
@ReneWerner87 ok, logs showed that it's not related to the memory storage. Will look into it this evening |
Please provide enough information so that others can review your pull request:
I noticed that expiration timestamp is still the same after cache entry has been expired. It leads to situation when right after the entry has been expired, all the next requests that were made right after the eviction are not cached since the expiration time is always behind the expiration deadline.
This PR contains one-liner fix and updated test.