Skip to content

feat: make 5m cache-creation ratio configurable - #2870

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/cache-creation-configurable
Feb 7, 2026
Merged

feat: make 5m cache-creation ratio configurable#2870
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/cache-creation-configurable

Conversation

@seefs001

@seefs001 seefs001 commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added configurable cache creation ratio settings with JSON-based management
    • Added UI controls to configure cache creation ratios for 5m and 1h cache tiers
    • Extended multi-language support including English, French, Japanese, Russian, Vietnamese, and Chinese for the new cache creation ratio feature

@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR introduces a new "CreateCacheRatio" configuration option enabling users to control cache creation multipliers. It adds backend request handling via the controller-model layer, implements thread-safe ratio storage with JSON serialization in the ratio_setting package, and provides a frontend UI component with internationalization support across six languages.

Changes

Cohort / File(s) Summary
Backend Controller Integration
controller/option.go, model/option.go
Add "CreateCacheRatio" case to UpdateOption handler and register it in the OptionMap with routing to the ratio_setting update function.
Backend Ratio Setting Core
setting/ratio_setting/cache_ratio.go
Introduce createCacheRatioMap with mutex for thread-safe storage. Add four public functions: CreateCacheRatio2JSONString (serialization), UpdateCreateCacheRatioByJSONString (deserialization with cache invalidation), GetCreateCacheRatio (single-value fetch with default 1.25), and GetCreateCacheRatioCopy (thread-safe map copy).
Backend Ratio Setting Initialization & Exposure
setting/ratio_setting/model_ratio.go, setting/ratio_setting/exposed_cache.go
Initialize createCacheRatioMap in InitRatioSettings mirroring existing cacheRatioMap setup. Expose create_cache_ratio in GetExposedData() map.
Frontend State & UI Components
web/src/components/settings/RatioSetting.jsx, web/src/pages/Setting/Ratio/ModelRatioSettings.jsx
Add CreateCacheRatio to initial inputs state. Introduce Form.TextArea field with JSON validation, label, guidance text, and onChange handler for user configuration.
Internationalization
web/src/i18n/locales/en.json, fr.json, ja.json, ru.json, vi.json, zh.json
Add two new translation keys across all six locale files: label for "缓存创建倍率" (Cache creation ratio) and descriptive note on default behavior and 1h auto-calculation. Vietnamese locale updates existing mapping for the label.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 With whiskers a\-twitch, the rabbit now sings,
A cache creation ratio—oh what it brings!
Mutex protection keeps threads in line,
JSON to JSON, a config so fine.
From five-minute gardens to one-hour glows,
The new ratio feature magically flows! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: make 5m cache-creation ratio configurable' directly and accurately describes the main change: introducing configurability for the 5-minute cache-creation ratio, which is implemented across backend settings, model options, and frontend UI components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit 7a146a1 into QuantumNous:main Feb 7, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…ion-configurable

feat: make 5m cache-creation ratio configurable
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.

2 participants