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:
@@ -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(_) => {
|
||||
|
||||
Reference in New Issue
Block a user