pub struct CacheService { /* private fields */ }Expand description
The orbok cache service. One per data directory.
Implementations§
Source§impl CacheService
impl CacheService
Sourcepub fn new(data_dir: &Path) -> Self
pub fn new(data_dir: &Path) -> Self
Create the service for a data directory; the payload database is
<data_dir>/orbok-cache.sqlite3 (Appendix A §3).
Sourcepub fn engine<T: Serialize + DeserializeOwned>(
&self,
catalog: &Catalog,
namespace: &OrbokCacheNamespace,
options: EngineOptions,
) -> OrbokResult<CacheEngine<T>>
pub fn engine<T: Serialize + DeserializeOwned>( &self, catalog: &Catalog, namespace: &OrbokCacheNamespace, options: EngineOptions, ) -> OrbokResult<CacheEngine<T>>
Open a typed engine for namespace, registering it in the
catalog cache_engines table. Change detection is
metadata-then-full-hash (Appendix A §8: metadata fast path with
hash confirmation, mirroring the scanner’s policy).
Sourcepub fn get_fresh<T: Serialize + DeserializeOwned>(
engine: &CacheEngine<T>,
path: &ValidatedPath,
) -> OrbokResult<Option<T>>
pub fn get_fresh<T: Serialize + DeserializeOwned>( engine: &CacheEngine<T>, path: &ValidatedPath, ) -> OrbokResult<Option<T>>
Freshness-checked read: returns the payload only when localcache confirms the source file is unchanged (Appendix A §8). The catalog/scanner remains the authority for file state.
Sourcepub fn put<T: Serialize + DeserializeOwned>(
engine: &CacheEngine<T>,
path: &ValidatedPath,
payload: &T,
) -> OrbokResult<()>
pub fn put<T: Serialize + DeserializeOwned>( engine: &CacheEngine<T>, path: &ValidatedPath, payload: &T, ) -> OrbokResult<()>
Store a derived payload for a boundary-validated source path.
Sourcepub fn remove<T: Serialize + DeserializeOwned>(
engine: &CacheEngine<T>,
path: &ValidatedPath,
) -> OrbokResult<bool>
pub fn remove<T: Serialize + DeserializeOwned>( engine: &CacheEngine<T>, path: &ValidatedPath, ) -> OrbokResult<bool>
Invalidate one entry (e.g. file deleted from catalog).
Sourcepub fn run_safe_cleanup(
&self,
catalog: &Catalog,
plan: &CleanupPlan,
) -> OrbokResult<CacheCleanupOutcome>
pub fn run_safe_cleanup( &self, catalog: &Catalog, plan: &CleanupPlan, ) -> OrbokResult<CacheCleanupOutcome>
Safe cleanup driven by a validated plan (RFC-001 §9, Appendix A §12). Maps each action to its payload namespaces and runs expiry + missing-file + stale-version maintenance there.
Sourcepub fn shrink(&self, catalog: &Catalog) -> OrbokResult<()>
pub fn shrink(&self, catalog: &Catalog) -> OrbokResult<()>
Reclaim file space after large deletions (storage dashboard’s explicit “shrink” action; Appendix A §12).
Sourcepub fn usage(
&self,
catalog: &Catalog,
namespaces: &[OrbokCacheNamespace],
) -> OrbokResult<Vec<NamespaceUsage>>
pub fn usage( &self, catalog: &Catalog, namespaces: &[OrbokCacheNamespace], ) -> OrbokResult<Vec<NamespaceUsage>>
Usage per namespace for storage accounting (Appendix A §11).