perf: update ProxyRequestCache to use boxed CacheEntry for improved memory management

This commit is contained in:
Tunglies
2025-09-02 19:09:44 +08:00
parent 0c65f8ebad
commit 926c095409
2 changed files with 7 additions and 3 deletions

View File

@@ -4,6 +4,10 @@
- 增加托盘节点选择
### 🚀 性能优化
- 优化节点信息缓存占用
### 🐞 修复问题
- 修复首页节点切换失效的问题

View File

@@ -11,7 +11,7 @@ pub struct CacheEntry {
}
pub struct ProxyRequestCache {
pub map: DashMap<String, Arc<OnceCell<CacheEntry>>>,
pub map: DashMap<String, Arc<OnceCell<Box<CacheEntry>>>>,
}
impl ProxyRequestCache {
@@ -54,10 +54,10 @@ impl ProxyRequestCache {
// Try to set a new value
let value = fetch_fn().await;
let entry = CacheEntry {
let entry = Box::new(CacheEntry {
value: Arc::new(value),
expires_at: Instant::now() + ttl,
};
});
match cell.set(entry) {
Ok(_) => {