Skip to content

feat(cache): add onCacheNotAvailable option#4876

Merged
yusukebe merged 1 commit intomainfrom
feat/cache-on-cache-not-available
Apr 15, 2026
Merged

feat(cache): add onCacheNotAvailable option#4876
yusukebe merged 1 commit intomainfrom
feat/cache-on-cache-not-available

Conversation

@yusukebe
Copy link
Copy Markdown
Member

@yusukebe yusukebe commented Apr 13, 2026

This PR introduces onCacheNotAvailable to Cache Middleware.

By default, it logs a message with console.log if the caches are not found in the global scope. But some users want to prevent logging or customize the behavior. In that case, onCacheNotAvailable is useful:

app.use(
  cache({
    cacheName: 'my-app-v1',
    onCacheNotAvailable: () => {
      console.log('Custom log: Cache API is not available.')
    },
  })
)

Or to prevent logging:

app.use(
  cache({
    cacheName: 'my-app-v1',
    onCacheNotAvailable: false,
  })
)

Relevant to #4871

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@github-actions
Copy link
Copy Markdown

Bundle size check

main (1aa32fb) #4876 (cc0f96f) +/-
Bundle Size (B) 18,489B 18,489B 0B
Bundle Size (KB) 18.06K 18.06K 0K

Compiler Diagnostics (tsc)

main (1aa32fb) #4876 (cc0f96f) +/-
Files 229 229 0
Lines 146,731 146,731 0
Identifiers 124,420 124,420 0
Symbols 150,435 150,435 0
Types 157,114 157,114 0
Instantiations 401,812 401,812 0
Memory used 252,473K 251,941K -532K
I/O read 0.03s 0.02s -0.01s
I/O write 0s 0s 0s
Parse time 0.69s 0.76s 0.07s
Bind time 0.28s 0.28s 0s
Check time 1.44s 1.49s 0.05s
Emit time 0.01s 0.01s 0s
Total time 2.41s 2.54s 0.13s

Compiler Diagnostics (typescript-go)

main (1aa32fb) #4876 (cc0f96f) +/-
Files 229 229 0
Lines 150,912 150,912 0
Identifiers 125,098 125,098 0
Symbols 190,741 190,741 0
Types 255,501 255,501 0
Instantiations 609,367 609,367 0
Memory used 162,042K 162,090K 48K
Memory allocs 1,767,761 1,768,498 737
Config time 0.001s 0.001s 0s
BuildInfo read time 0.001s 0.001s 0s
Parse time 0.111s 0.093s -0.018s
Bind time 0s 0s 0s
Check time 0.417s 0.461s 0.044s
Emit time 0.005s 0.005s 0s
Changes compute time 0.025s 0.025s 0s
Total time 0.592s 0.623s 0.031s

Reported by octocov

@github-actions
Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 51,747.35 68,363.81 47,596.84 39,281.40
hono (current) bun 51,464.15 67,766.35 47,624.25 39,001.85
Change -0.55% -0.87% +0.06% -0.71%

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.89%. Comparing base (c37ba26) to head (c36019c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4876   +/-   ##
=======================================
  Coverage   92.89%   92.89%           
=======================================
  Files         177      177           
  Lines       11797    11802    +5     
  Branches     3515     3517    +2     
=======================================
+ Hits        10959    10964    +5     
  Misses        837      837           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe yusukebe merged commit faa6c46 into main Apr 15, 2026
35 of 36 checks passed
@yusukebe yusukebe deleted the feat/cache-on-cache-not-available branch April 15, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant