Skip to main content

Crate xds_cache

Crate xds_cache 

Source
Expand description

§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);

Structs§

CacheStats
Statistics for cache operations.
ShardedCache
A high-performance sharded cache using DashMap.
Snapshot
An immutable snapshot of xDS resources for a node.
SnapshotBuilder
Builder for creating snapshots.
SnapshotResources
Resources for a specific type within a snapshot.
Watch
A watch subscription for receiving snapshot updates.
WatchId
Unique identifier for a watch subscription.
WatchManager
Manager for watch subscriptions.

Traits§

Cache
Trait for xDS snapshot caches.