mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
perf: update ProxyRequestCache to use boxed CacheEntry for improved memory management
This commit is contained in:
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
- 增加托盘节点选择
|
- 增加托盘节点选择
|
||||||
|
|
||||||
|
### 🚀 性能优化
|
||||||
|
|
||||||
|
- 优化节点信息缓存占用
|
||||||
|
|
||||||
### 🐞 修复问题
|
### 🐞 修复问题
|
||||||
|
|
||||||
- 修复首页节点切换失效的问题
|
- 修复首页节点切换失效的问题
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub struct CacheEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct ProxyRequestCache {
|
pub struct ProxyRequestCache {
|
||||||
pub map: DashMap<String, Arc<OnceCell<CacheEntry>>>,
|
pub map: DashMap<String, Arc<OnceCell<Box<CacheEntry>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProxyRequestCache {
|
impl ProxyRequestCache {
|
||||||
@@ -54,10 +54,10 @@ impl ProxyRequestCache {
|
|||||||
|
|
||||||
// Try to set a new value
|
// Try to set a new value
|
||||||
let value = fetch_fn().await;
|
let value = fetch_fn().await;
|
||||||
let entry = CacheEntry {
|
let entry = Box::new(CacheEntry {
|
||||||
value: Arc::new(value),
|
value: Arc::new(value),
|
||||||
expires_at: Instant::now() + ttl,
|
expires_at: Instant::now() + ttl,
|
||||||
};
|
});
|
||||||
|
|
||||||
match cell.set(entry) {
|
match cell.set(entry) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user