lisaogren / axios-cache-adapter

Caching adapter for axios. Store request results in a configurable store to prevent unneeded network requests.
MIT License
725 stars 108 forks source link

fix: RedisStore with no expiration #259

Open speedytwenty opened 2 years ago

speedytwenty commented 2 years ago

I was unable to get the RedisStore to work no-expiration. Setting the maxAge to 0 seemed to lead to immediate expiration and setting the maxAge to Number.POSITIVE_INFINITY resulted in expires value being null.

So to solve this, I'm passing Number.POSITIVE_INFINITY as the maxAge and the RedisStore adjusts the expires value to 0.

This fix does feel a bit hackish. I can make adjustments if someone can point out a cleaner way to solve this.

codecov[bot] commented 2 years ago

Codecov Report

Merging #259 (9afc56c) into master (2d51cee) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #259   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          235       235           
=========================================
  Hits           235       235           
Impacted Files Coverage Δ
src/redis.js 100.00% <100.00%> (ø)
src/serialize.js 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2d51cee...9afc56c. Read the comment docs.