feat(universal-cache): add universal cache middleware package#1764
feat(universal-cache): add universal cache middleware package#1764lord007tn wants to merge 12 commits into
Conversation
🦋 Changeset detectedLatest commit: a4ebbfb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1764 +/- ##
=======================================
Coverage 92.13% 92.13%
=======================================
Files 115 115
Lines 4106 4106
Branches 1072 1072
=======================================
Hits 3783 3783
Misses 287 287
Partials 36 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Addressed the Codecov coverage gaps with additional targeted tests. What I added
Validation run
All passed locally. The new commit is: |
d79c864 to
89ea559
Compare
89ea559 to
29d3e05
Compare
1 similar comment
|
Sorry to be late. Can you merge the |
|
@yusukebe Done, |
|
@yusukebe done, fixed the remaining edge cases and pushed. all checks pass locally. |
Summary
This PR introduces
@hono/universal-cacheas a new third-party middleware package for Hono.It follows the direction discussed in
honojs/hono#3857:honojs/hono#3857
This middleware has been running internally in our production systems for a while. After validating it under real traffic and edge cases, we felt it was in a good place to open-source and get broader feedback on it.
Dependency Model
@hono/universal-cachedepends onunstorageas the storage abstraction.That gives us:
Major Features
cacheMiddleware()cacheFunction()cacheDefaults()getKey) and integrity (integrity/hash)serialize/deserializehooks for response and function entriesshouldBypassCache,shouldInvalidateCache,shouldRevalidate,validatevariessupport for cache key variationrevalidateHeaderkeepPreviousOn5xxbehavior for safer refresh failuresRuntime Notes
maxAgeis60workerd, stale middleware entries refresh synchronously instead of relying on background self-fetchTest Coverage
Added coverage for:
shouldRevalidategatingworkerdValidation
corepack yarn eslint packages/universal-cache/src packages/universal-cache/vitest.config.ts packages/universal-cache/vitest.workerd.config.ts --cache --cache-location .cache/.eslintcachecorepack yarn workspace @hono/universal-cache typecheckcorepack yarn workspace @hono/universal-cache test --runcorepack yarn workspace @hono/universal-cache test:workerd --runcd packages/universal-cache && bunx vitest run src/index.test.ts src/utils.test.tsRelated
Merge Note
Please merge this together with the docs PR above.
The author should do the following, if applicable
yarn changesetat the top of this repo and push the changeset