unstorage icon indicating copy to clipboard operation
unstorage copied to clipboard

feat(lru-cache): allow passing options to leverage stale-while-revalidate strategy

Open patzick opened this issue 1 year ago โ€ข 3 comments

๐Ÿ”— Linked issue

  • no related issue

โ“ Type of change

  • [x] ๐Ÿ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [x] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

  • replaced cache.get withcache.fetch. it is not a breaking change. The usage is the same

If fetch method is not provided, then cache.fetch(key) is equivalent to Promise.resolve(cache.get(key)).

source in docs

  • that allows to provide fetchMethod for the driver and use stale-while-revalidate strategy to improve cache performence
  • added docs entry to inform about that possibility

Sidenote

This PR will conflict with #320 as I wanted to create two separate PRs because the overall scope differs. I'll update this or the other PR whenever the second one is merged.

๐Ÿ“ Checklist

  • [ ] I have linked an issue or discussion.
  • [x] I have updated the documentation accordingly.

patzick avatar Oct 13 '23 18:10 patzick

Live Preview ready!

Name Edit Preview Latest Commit
unstorage Edit on Studio โ†—๏ธŽ View Live Preview 85347dda2360167fdb7401df3aa1f9e039fbbd96

nuxt-studio[bot] avatar Oct 13 '23 18:10 nuxt-studio[bot]

Codecov Report

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

Project coverage is 64.83%. Comparing base (f6841df) to head (9c61054). Report is 39 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #321      +/-   ##
==========================================
+ Coverage   64.79%   64.83%   +0.03%     
==========================================
  Files          41       40       -1     
  Lines        4071     4072       +1     
  Branches      489      488       -1     
==========================================
+ Hits         2638     2640       +2     
  Misses       1422     1422              
+ Partials       11       10       -1     

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

codecov[bot] avatar Nov 14 '23 18:11 codecov[bot]

@pi0 thanks for merging #320, The conflict with this PR is resolved and it's ready to be merged too :)

patzick avatar Nov 14 '23 18:11 patzick