Skip to main content

tower_http_cache_plus/cache/implementation/moka/
weigher.rs

1use super::super::super::{key::*, response::*, weight::*};
2
3/// Moka cache entry weigher.
4pub fn weigher<CacheKeyT>(cache_key: &CacheKeyT, cached_response: &CachedResponseRef) -> u32
5where
6    CacheKeyT: CacheKey,
7{
8    let weight = cache_key.cache_weight() + cached_response.cache_weight();
9    let weight = weight.try_into().unwrap_or(u32::MAX);
10    tracing::debug!("{} for {}", weight, cache_key);
11    weight
12}