06chaynes / http-cache

A caching middleware that follows HTTP caching rules
https://http-cache.rs/
Apache License 2.0
69 stars 17 forks source link

fix `cache_mode_fn` consistency #65

Closed matt-phylum closed 10 months ago

matt-phylum commented 10 months ago

cache_mode_fn was added to HttpCacheOptions to allow different cache modes to be used for different requests. However, cache_mode_fn was only consulted when determining if a request could be satisfied from the cache, not when determining whether to use an existing cached value or whether to cache a fresh value. The test was incorrectly passing because cache_mode_fn was setting the mode equal to the same value that it would have been otherwise.

This PR makes all code paths use cache_mode_fn consistently and fixes the cache_mode_fn test to rely on cache_mode_fn working.

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c1e8b6b) 92.58% compared to head (937e587) 92.64%. Report is 4 commits behind head on develop.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #65 +/- ## =========================================== + Coverage 92.58% 92.64% +0.06% =========================================== Files 11 11 Lines 1092 1101 +9 =========================================== + Hits 1011 1020 +9 Misses 81 81 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

06chaynes commented 10 months ago

Ah good catch, and thank you for the PR! I'll try to get this in and published this weekend.

06chaynes commented 10 months ago

Ignore that coverage error, it's super annoying about it. Thanks for the clippy fixes!

Edit: Ha looks like clippy was a bit overzealous with that fix I'm guessing? I can add an ignore for this case if so

matt-phylum commented 10 months ago

I changed the wrong instance of try_into(). My IDE does not work on this project because it tries to use multiple async implementations.