Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
1use crate::CachedRecord; 2use foyer::{DirectFsDeviceOptions, Engine, HybridCache, HybridCacheBuilder}; 3use std::path::Path; 4 5pub async fn firehose_cache( 6 cache_dir: impl AsRef<Path>, 7) -> Result<HybridCache<String, CachedRecord>, String> { 8 let cache = HybridCacheBuilder::new() 9 .with_name("firehose") 10 .memory(64 * 2_usize.pow(20)) 11 .with_weighter(|k: &String, v| k.len() + std::mem::size_of_val(v)) 12 .storage(Engine::large()) 13 .with_device_options(DirectFsDeviceOptions::new(cache_dir)) 14 .build() 15 .await 16 .map_err(|e| format!("foyer setup error: {e:?}"))?; 17 Ok(cache) 18}