Nebulex.Distributed (Nebulex.Distributed v3.2.2)

Copy Markdown View Source

Distributed caching adapters for Nebulex.

This package provides adapters for building distributed cache topologies on top of Nebulex. Each adapter wraps a local cache adapter (e.g., Nebulex.Adapters.Local) and adds a distributed layer on top of it.

Adapters

  • Nebulex.Adapters.Partitioned - Partitioned cache topology where data is sharded across cluster nodes using consistent hashing. Each node owns a subset of the keyspace, providing linear scalability and single-hop point-to-point operations.

  • Nebulex.Adapters.Multilevel - Multi-level (near) cache topology with a hierarchy of cache layers (e.g., L1 local + L2 distributed). Reads check levels in order for fast local hits with fallback to slower shared layers. Writes use a write-through policy.

  • Nebulex.Adapters.Coherent - Local cache with distributed invalidation via Nebulex.Streams. Each node maintains its own independent local cache for maximum read performance; entries are only present on nodes that have fetched them. Writes broadcast invalidation events across the cluster so other nodes delete stale entries and fetch fresh data on the next read.

  • Nebulex.Adapters.Replicated - Push-based replicated cache topology where writes are eagerly replicated to all nodes via buffered RPC.

Choosing an Adapter

AspectPartitionedMultilevelCoherentReplicated
Data locationSharded across nodesL1 local + L2 sharedIndependent per nodeFull copy on every node
Read performanceNetwork hop requiredL1 fast, L2 slowerFastest (pure local)Fastest (pure local)
Write behaviorRemote write to ownerWrite through levelsLocal + invalidationLocal + push to all peers
ConsistencyStrong (single owner)Varies by configEventualEventual
Network overheadMediumMedium to highLow (invalidations)Medium (batched RPCs)
Best forLarge datasetsTiered access patternsRead-heavy workloadsRead-heavy, small datasets

Installation

Add :nebulex_distributed to your dependencies in mix.exs:

def deps do
  [
    {:nebulex_distributed, "~> 3.0"},
    {:telemetry, "~> 0.4 or ~> 1.0"}, # For observability and monitoring
    {:decorator, "~> 1.4"},           # For declarative caching
  ]
end

The :telemetry (observability and monitoring cache operations) and :decorator (declarative caching) dependencies are optional but highly recommended.

See each adapter's documentation for configuration and usage details.