MCPcopy Index your code
hub / github.com/Firstyear/opensuse-proxy-cache / new

Method new

opensuse-proxy-cache/src/cache.rs:243–268  ·  view source on GitHub ↗
(
        capacity: usize,
        content_dir: &Path,
        durable_fs: bool,
        default_backend: Backend,
        backends: Vec<Backend>,
    )

Source from the content-addressed store, hash-verified

241
242impl Cache {
243 pub fn new(
244 capacity: usize,
245 content_dir: &Path,
246 durable_fs: bool,
247 default_backend: Backend,
248 backends: Vec<Backend>,
249 ) -> std::io::Result<Self> {
250 let pri_cache = ArcDiskCache::new(capacity, content_dir, durable_fs)?;
251 let (submit_tx, submit_rx) = channel(PENDING_ADDS);
252 let pri_cache_cln = pri_cache.clone();
253
254 let bloom = Mutex::new(Bloom::new_for_fp_rate(65536, 0.001));
255
256 tokio::task::spawn_blocking(move || cache_mgr(submit_rx, pri_cache_cln));
257
258 let pri_cache_cln = pri_cache.clone();
259 tokio::task::spawn(async move { cache_stats(pri_cache_cln).await });
260
261 Ok(Cache {
262 pri_cache,
263 bloom,
264 default_backend,
265 backends,
266 submit_tx,
267 })
268 }
269
270 pub fn monitor_backends(&self) -> impl Iterator<Item = &Backend> {
271 std::iter::once(&self.default_backend)

Callers

nothing calls this directly

Calls 2

cache_statsFunction · 0.85
cache_mgrFunction · 0.70

Tested by

no test coverage detected