xds-cache 0.1.0

High-performance snapshot cache for xDS resources
Documentation

xds-cache

High-performance snapshot cache for xDS resources.

This crate provides the caching layer for xDS control plane implementations:

  • [ShardedCache] - DashMap-based concurrent cache for snapshots
  • [Snapshot] - Immutable collection of resources for a node
  • [Watch] - Subscription system for cache updates

Key Design Decisions

  • Uses DashMap for lock-free concurrent access
  • All DashMap references are dropped before any .await to prevent deadlocks
  • Snapshots are immutable and atomically replaced
  • Watch notifications are async and non-blocking

Example

use xds_cache::{Cache, ShardedCache, Snapshot};
use xds_core::NodeHash;

// Create a cache
let cache = ShardedCache::new();

// Build a snapshot
let snapshot = Snapshot::builder()
    .version("v1")
    .build();

// Set snapshot for a node (sync; watch notifications are async internally)
cache.set_snapshot(NodeHash::from_id("node-1"), snapshot);