Skip to content

perf(auth): 将 API Key 校验缓存 TTL 延长至五分钟 - #291

Merged
g1331 merged 2 commits into
masterfrom
fix/api-key-cache-ttl
Aug 27, 2026
Merged

perf(auth): 将 API Key 校验缓存 TTL 延长至五分钟#291
g1331 merged 2 commits into
masterfrom
fix/api-key-cache-ttl

Conversation

@g1331

@g1331 g1331 commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Summary

API_KEY_VERIFY_CACHE_TTL_MS 从 120000 毫秒调整为 5 分钟(300000 毫秒),提高重复 API Key 校验的缓存命中窗口。

Related Issue

无关联 Issue。

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (code improvement without changing functionality)
  • Tests (adding or updating tests)
  • Build/CI (changes to build system or CI configuration)

Changes

  • API_KEY_VERIFY_CACHE_TTL_MS 设置为 5 * 60 * 1000
  • 更新 TTL 边界测试:299999 毫秒内命中缓存,300000 毫秒后重新执行 bcrypt。
  • 同步 request-lifecycle.md 中的缓存 TTL 说明。
  • 缓存容量与数据库权威鉴权检查保持不变。

Test Plan

  • Local tests pass (pnpm test:run)
  • Type check passes (pnpm exec tsc --noEmit)
  • Lint passes (pnpm lint)
  • Manual testing completed(纯后端缓存参数变更,不适用)

已验证:聚焦鉴权测试 30 passed;全量测试 245 files、3646 passed、1 skipped;format:check、production build 与 pre-commit hooks 均通过。构建仅有已知的 Turbopack NFT tracing warning。

Checklist

  • Code follows the project's coding standards
  • Tests have been added where necessary
  • Documentation has been updated (if applicable)
  • Changes do not introduce security vulnerabilities
  • Commit messages follow conventions

Screenshots

不适用。

Additional Notes

本 PR 仅包含 TTL、对应边界测试和架构文档三项变更。工作区中原有的落地页未提交改动未包含在本 PR 中。

将 API_KEY_VERIFY_CACHE_TTL_MS 从 120000 调整为 300000。

同步五分钟过期边界测试与鉴权生命周期文档。

验证:聚焦测试、全量测试、lint、format:check、tsc、build 均通过。
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.54%. Comparing base (89878d7) to head (7616131).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #291   +/-   ##
=======================================
  Coverage   72.54%   72.54%           
=======================================
  Files         245      245           
  Lines       14519    14519           
  Branches     4837     4837           
=======================================
  Hits        10533    10533           
  Misses       2600     2600           
  Partials     1386     1386           
Flag Coverage Δ
verify 72.54% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@g1331
g1331 merged commit a45eedc into master Aug 27, 2026
14 checks passed
@g1331
g1331 deleted the fix/api-key-cache-ttl branch August 27, 2026 12:09
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