Skip to content

x/data/cache Primer

Experimental — API compatibility is not frozen. Evaluate before adopting in production. Check Release Posture for current maturity status.

Open this page after x/data Primer when the change is narrowly about distributed or Redis-backed cache topology: consistent-hashing rings, replication, failover, Redis client adapters, or leaderboard caching built on store/cache primitives.

x/data/cache is a subordinate package within the x/data family. Start distributed cache work in x/data before opening this package directly. For simple in-process caching, import github.com/spcent/plumego/store/cache and use cache.MemoryCache without opening x/data/cache at all.

  • you are implementing or modifying a consistent-hashing distributed cache (distributed/)
  • you are adding Redis client adapter logic implementing the store/cache.Cache interface (redis/)
  • you are building or tuning a leaderboard cache with ranking semantics (leaderboard/)
  • you are adding replication or failover coordination to a distributed cache topology
  • simple in-process caching is sufficient — use cache.MemoryCache from store/cache directly
  • the work is tenant-aware cache adapters that scope by tenant key — that belongs in x/tenant/store/cache
  • the change is about stable store/cache interface definitions — those are a kernel contract, not an adapter
  • the work is core bootstrap or application-level cache configuration

First files to read in the current repository

Section titled “First files to read in the current repository”
  1. x/data/cache/module.yaml
  2. x/data/cache/distributed/
  3. x/data/cache/redis/
  4. x/data/cache/leaderboard/
Keep it in x/data/cache when the work is aboutMove out when the work becomes
distributed: consistent-hashing ring, node membership, replication factor, failovertenant-aware cache scoping — use x/tenant/store/cache
redis: Redis client implementing store/cache.Cache, pipeline helpers, TTL managementRedis cluster administration or connection pooling configuration
leaderboard: ranked set semantics built on store/cache primitivesbusiness-specific leaderboard rules or score computation domain logic
replication coordinator, hash ring membership updatesstable store/cache interface changes — those are kernel contracts

x/data/cache is often opened directly when the right starting point is cache.MemoryCache from store/cache for simple cases or x/data for topology placement. The subordinate relationship exists because distributed cache topology — sharding keys, ring membership, failover — is a topology concern that belongs in the x/data family rather than a separate top-level concern. Keeping them together preserves the invariant that topology decisions are explicit and reviewable.