Skip to content

feat: add InvalidatePricingCache function and call it in updateOption#2685

Closed
0-don wants to merge 1 commit intoQuantumNous:mainfrom
0-don:main
Closed

feat: add InvalidatePricingCache function and call it in updateOption#2685
0-don wants to merge 1 commit intoQuantumNous:mainfrom
0-don:main

Conversation

@0-don
Copy link
Contributor

@0-don 0-don commented Jan 18, 2026

When updating model ratios or prices via the /api/option/ endpoint, the /api/pricing endpoint continues returning stale cached data for up to 1 minute.

This PR adds cache invalidation when ratio-related options are updated, ensuring the pricing endpoint immediately reflects the new values.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Pricing information now automatically refreshes when pricing or ratio options are updated, ensuring accurate and current pricing data is always displayed.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2026

Walkthrough

A new public function InvalidatePricingCache() is introduced to force pricing cache refresh. Calls to this function are added after updates to pricing-related options (ModelRatio, GroupRatio, CompletionRatio, ModelPrice) to ensure the cache reflects the latest configuration values.

Changes

Cohort / File(s) Summary
Pricing cache invalidation mechanism
model/pricing.go
Added InvalidatePricingCache() public function that acquires lock and resets lastGetPricingTime to zero, forcing cache refresh on next access
Option updates with cache invalidation
model/option.go
Integrated calls to InvalidatePricingCache() after ModelRatio, GroupRatio, CompletionRatio, and ModelPrice option updates to invalidate stale pricing data

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A cache grows stale, but fear not dear friend,
When prices update, we now make amend!
Invalidate, refresh, let the fresh data flow,
No more serving yesterday's pricing show! 💰

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 title accurately describes the main change: adding InvalidatePricingCache function and calling it in updateOption.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Add missing translation keys for all non-English languages:
- zh-TW: 27 keys (plurals, cache, recharge)
- fr: 98 keys (disk cache, OAuth, preferences, performance monitor)
- ru: 98 keys (disk cache, OAuth, preferences, performance monitor)
- ja: 103 keys (disk cache, OAuth, preferences, performance monitor)
- vi: 99 keys (disk cache, OAuth, preferences, performance monitor)

Fix SemiLocaleWrapper to map all supported languages (zh-TW, fr, ru,
ja, vi) to their Semi Design locale counterparts instead of only
zh/en, which caused UI components like pagination to show Chinese
labels for non-Chinese/English users.
@0-don
Copy link
Contributor Author

0-don commented Feb 24, 2026

Closing — the InvalidatePricingCache change was already merged, and the remaining i18n commit is covered by #2958.

@0-don 0-don closed this Feb 24, 2026
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