Skip to main content

Module cache_management

Module cache_management 

Source
Expand description

Example: Cache management.

use oximedia_proxy::{CacheManager, CacheStrategy};

let cache_dir = std::path::PathBuf::from("/var/cache/proxies");
let max_size = 10 * 1024 * 1024 * 1024; // 10 GB

let mut cache = CacheManager::new(cache_dir, max_size);
cache.set_strategy(CacheStrategy::Lru);

// Add proxies to cache
cache.add(std::path::PathBuf::from("proxy1.mp4"), 100_000_000);
cache.add(std::path::PathBuf::from("proxy2.mp4"), 150_000_000);

println!("Cache utilization: {:.1}%", cache.utilization());

Functionsยง

cleanup_cache
Clean up cache based on policy.
setup_cache
Set up and manage proxy cache.