fix: skip serializing empty cache entries
This commit is contained in:
parent
913bb12755
commit
be18d89ea6
1 changed files with 9 additions and 1 deletions
|
|
@ -395,6 +395,7 @@ struct CacheHolder {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
struct CacheData {
|
struct CacheData {
|
||||||
clients: HashMap<ClientType, CacheEntry<ClientData>>,
|
clients: HashMap<ClientType, CacheEntry<ClientData>>,
|
||||||
|
#[serde(skip_serializing_if = "CacheEntry::is_none")]
|
||||||
deobf: CacheEntry<DeobfData>,
|
deobf: CacheEntry<DeobfData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -445,6 +446,10 @@ impl<T> CacheEntry<T> {
|
||||||
CacheEntry::None => None,
|
CacheEntry::None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_none(&self) -> bool {
|
||||||
|
matches!(self, Self::None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<T> for CacheEntry<T> {
|
impl<T> From<T> for CacheEntry<T> {
|
||||||
|
|
@ -958,7 +963,10 @@ impl RustyPipe {
|
||||||
async fn store_cache(&self) {
|
async fn store_cache(&self) {
|
||||||
let mut cache_clients = HashMap::new();
|
let mut cache_clients = HashMap::new();
|
||||||
for (c, lk) in &self.inner.cache.clients {
|
for (c, lk) in &self.inner.cache.clients {
|
||||||
cache_clients.insert(*c, lk.read().await.clone());
|
let v = lk.read().await.clone();
|
||||||
|
if !v.is_none() {
|
||||||
|
cache_clients.insert(*c, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(storage) = &self.inner.storage {
|
if let Some(storage) = &self.inner.storage {
|
||||||
|
|
|
||||||
Reference in a new issue