feat(universal-cache): add universal cache middleware package - #1764
feat(universal-cache): add universal cache middleware package#1764lord007tn wants to merge 16 commits into
Conversation
🦋 Changeset detectedLatest commit: 336c344 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1764 +/- ##
==========================================
+ Coverage 92.14% 92.28% +0.14%
==========================================
Files 115 117 +2
Lines 4113 4875 +762
Branches 1072 1314 +242
==========================================
+ Hits 3790 4499 +709
- Misses 287 334 +47
- Partials 36 42 +6
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. |
|
@yusukebe can you please check |
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