How youngyangyang04/kamacache-cpp works
KCache is a distributed cache service with an SDK-driven workflow: applications call the SDK, which discovers nodes through etcd, routes keys using consistent hashing, and sends gRPC operations to a node. The node dispatches requests to a cache group backed by local LRU storage; misses use a getter callback, with SingleFlight coalescing concurrent loads. The README also documents coordinated invalidation and deletion plus an optional HTTP gateway. Some subsystem links rely on README documentation because their implementation files were not excerpted.
Main entry points: client_sdk.cpp Client SDK · group.cpp Cache group · server.cpp gRPC server · main.cpp Node entry
Components 12
Client SDK
- Client SDK
src/client/client_sdk.cpp - Consistent hash
src/consistent_hash/consistent_hash.cpp - Service discovery
src/client/client_sdk.cpp
Cache node
- Node entry
src/main.cpp - gRPC server
src/server/server.cpp - Cache group
src/group/group.cpp - LRU cache
src/cache/lru.cpp - SingleFlight
src/include/kcache/singleflight.h - Getter data source
src/main.cpp
Cluster coordination
- etcd registry
src/registry/registry.cpp
Integrations
- HTTP gateway
example/http_gateway/http_gateway.cpp
Other components
- Application
Connections 15
- Application → Client SDK: calls
README.md - HTTP gateway → Client SDK: uses
README.md - Client SDK → Service discovery: starts
src/client/client_sdk.cpp - Service discovery → etcd registry: watches services
src/client/client_sdk.cpp - Client SDK → Consistent hash: routes keys
src/client/client_sdk.cpp - Client SDK → gRPC server: sends RPCs
src/client/client_sdk.cpp - Client SDK → gRPC server: invalidates peers
src/client/client_sdk.cpp - Client SDK → gRPC server: broadcasts deletes
src/client/client_sdk.cpp - Node entry → gRPC server: starts
src/main.cpp - Node entry → etcd registry: registers node
- gRPC server → Cache group: dispatches requests
src/server/server.cpp - Node entry → Cache group: creates group
src/main.cpp - Cache group → LRU cache: reads and writes
src/group/group.cpp - Cache group → SingleFlight: coalesces loads
src/group/group.cpp - Cache group → Getter data source: loads on miss
src/group/group.cpp