tower-http-cache-plus 0.0.2

HTTP response caching middleware with integrated compression
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use super::super::super::{key::*, response::*, weight::*};

/// Moka cache entry weigher.
pub fn weigher<CacheKeyT>(cache_key: &CacheKeyT, cached_response: &CachedResponseRef) -> u32
where
    CacheKeyT: CacheKey,
{
    let weight = cache_key.cache_weight() + cached_response.cache_weight();
    let weight = weight.try_into().unwrap_or(u32::MAX);
    tracing::debug!("{} for {}", weight, cache_key);
    weight
}