Files
Aether/apps/aether-gateway/src/cache/auth_context.rs
T

36 lines
800 B
Rust
Raw Normal View History

use std::time::Duration;
use aether_cache::ExpiringMap;
use crate::control::GatewayControlAuthContext;
#[derive(Debug, Default)]
pub(crate) struct AuthContextCache {
entries: ExpiringMap<String, GatewayControlAuthContext>,
}
impl AuthContextCache {
pub(crate) fn get_fresh(
&self,
cache_key: &str,
ttl: Duration,
) -> Option<GatewayControlAuthContext> {
self.entries.get_fresh(&cache_key.to_string(), ttl)
}
pub(crate) fn insert(
&self,
cache_key: String,
auth_context: GatewayControlAuthContext,
ttl: Duration,
max_entries: usize,
) {
self.entries
.insert(cache_key, auth_context, ttl, max_entries);
}
2026-05-12 13:15:41 +08:00
pub(crate) fn clear(&self) {
self.entries.clear();
}
}