Skip to main content
benchmarkedInspired by Mycelial networks (fungal transport meshes)

Mycelial Cache

Counterpart to LRU / LFU / ARC Cache Eviction

Research in progress

The data and performance claims on this page reflect ongoing research, implementation, and experimentation. They may change as benchmarks are rerun and formal papers are finalized.

Key Properties

  • Mycelial Mesh: entries connected by weighted edges that strengthen through co-access and decay over time
  • Cluster-Aware Eviction: eviction considers mesh topology, not just individual recency or frequency
  • Bridge entry protection: structurally important entries (connecting clusters) resist eviction
  • Fever response: detects workload shifts via mesh coherence and temporarily shifts eviction toward recency
  • Composite eviction scoring (individual strength + cluster embedding + bridge bonus)
  • Tick-driven maintenance with periodic edge pruning, bridge refresh, and fever decay

Operation Complexity

Side-by-side comparison with the classical counterpart.

Operation complexity comparison
OperationMycelial CacheLRU / LFU / ARC Cache Eviction
getO(1) + O(W)O(1)
setO(1) + O(W) + O(S*K) evictionO(1)
deleteO(1) + O(K)O(1)
containsO(1)O(1)
evict (select)O(S*K)O(1)
tick (maintenance)O(n*K^2)N/A
mesh_neighborsO(K)N/A
eviction_scoreO(K)N/A
bridge_entriesO(n)N/A

Interface Preview

mycelial_cache.rs
rust
1pub struct MycelialCache<K: Hash + Eq + Clone, V> { /* internal */ }
2
3impl<K: Hash + Eq + Clone, V> MycelialCache<K, V> {
4    // Construction (+ preset configs)
5    pub fn new(config: MycelialConfig) -> Self;
6    pub fn with_capacity(capacity: u64) -> Self;
7    pub fn general_purpose(capacity: u64) -> Self;
8    pub fn high_co_access(capacity: u64) -> Self;
9    pub fn low_overhead(capacity: u64) -> Self;
10
11    // Core operations
12    pub fn get(&mut self, key: &K) -> Option<&V>;
13    pub fn get_mut(&mut self, key: &K) -> Option<&mut V>;
14    pub fn set(&mut self, key: K, value: V) -> Option<V>;
15    pub fn set_with_ttl(&mut self, key: K, value: V, ttl: Duration) -> Option<V>;
16    pub fn delete(&mut self, key: &K) -> Option<V>;
17    pub fn contains(&self, key: &K) -> bool;
18
19    // Size & capacity
20    pub fn len(&self) -> u64;
21    pub fn capacity(&self) -> u64;
22    pub fn is_empty(&self) -> bool;
23    pub fn is_full(&self) -> bool;
24    pub fn clear(&mut self);
25
26    // Iteration (does not update mesh)
27    pub fn keys(&self) -> impl Iterator<Item = &K>;
28    pub fn values(&self) -> impl Iterator<Item = &V>;
29    pub fn iter(&self) -> impl Iterator<Item = (&K, &V)>;
30
31    // Pinning
32    pub fn pin(&mut self, key: &K) -> bool;
33    pub fn unpin(&mut self, key: &K) -> bool;
34    pub fn is_pinned(&self, key: &K) -> bool;
35
36    // Mesh introspection
37    pub fn mesh_neighbors(&self, key: &K) -> Option<Vec<(K, f32)>>;
38    pub fn eviction_score(&self, key: &K) -> Option<EvictionScore>;
39    pub fn bridge_entries(&self) -> Vec<K>;
40    pub fn mesh_stats(&self) -> MeshStats;
41    pub fn fever_intensity(&self) -> f32;
42    pub fn coherence_ema(&self) -> f32;
43    pub fn coherence_baseline(&self) -> f32;
44    pub fn config(&self) -> &MycelialConfig;
45
46    // Maintenance (Maintainable trait)
47    pub fn tick(&mut self) -> MaintenanceReport;
48}
49
mycelial_cache.ts
typescript
1class MycelialCache {
2  constructor(options?: MycelialCacheOptions);
3  async init(): Promise<this>;
4  static async withCapacity(capacity: number): Promise<MycelialCache>;
5
6  // Core operations (string keys, any values via WASM)
7  get(key: string): unknown;
8  set(key: string, value: unknown): void;
9  setWithTtl(key: string, value: unknown, ttlMs: number): void;
10  remove(key: string): unknown;
11  contains(key: string): boolean;
12
13  // Size & capacity
14  readonly length: number;
15  readonly capacity: number;
16  readonly isEmpty: boolean;
17  readonly isFull: boolean;
18  clear(): void;
19
20  // Pinning
21  pin(key: string): boolean;
22  unpin(key: string): boolean;
23  isPinned(key: string): boolean;
24
25  // Mesh introspection
26  meshStats(): MeshStats;
27  meshNeighbors(key: string): MeshNeighbor[] | undefined;
28  evictionScore(key: string): EvictionScore | undefined;
29  bridgeEntries(): string[];
30  readonly feverIntensity: number;
31  readonly coherenceEma: number;
32  readonly coherenceBaseline: number;
33  keys(): string[];
34
35  // Maintenance
36  tick(): MaintenanceReport;
37}
38

Interactive Simulation

Discussion

Questions, ideas, or experiences with Mycelial Cache? Join the discussion.