How couchbase/memcached works
Couchbase memcached is the frontend for the Couchbase key-value engine: clients send binary-protocol requests, which the daemon handles and dispatches to bucket engines. The repository also contains a default in-memory engine and supporting authentication, authorization, audit, replication, document-attribute, and operational capabilities. The graph emphasizes documented capabilities and source-indexed relationships; unsampled implementation details are represented only where the tree or README supports them.
Main entry points: mcbp_executors.cc Command executors · default_engine.cc Default engine · enginemap.cc Engine registry · connection.cc Client connections
Components 21
Daemon and protocol
- Client connections
daemon/connection.cc - Binary protocol
daemon/mcbp.cc - Command executors
daemon/mcbp_executors.cc - Bucket management
daemon/buckets.cc
Storage engines
- Engine registry
daemon/enginemap.cc - Engine loader
utilities/engine_loader.cc - Engine interface
include/memcached/engine.h - Default engine
engines/default_engine/default_engine.cc - Items and allocation
engines/default_engine/items.h - Engine lifecycle scrubber
engines/default_engine/engine_manager.cc
Security and audit
- SASL authentication
cbsasl/server.cc - Role-based access
rbac/privilege_database.cc - Audit events
auditd/src/audit.cc
Document and replication
- DCP replication
include/memcached/dcp.h - Subdocument commands
daemon/subdocument.cc - Document attributes
xattr/blob.cc
Operations and extensions
- TLS transport
daemon/memcached_openssl.cc - Server extensions
include/memcached/extension.h - Tracing
daemon/tracing.cc - Statistics and timings
daemon/timings.cc
Other components
- KV clients
Connections 16
- KV clients → Client connections: connects
- Client connections → Binary protocol: handles packets
- Binary protocol → Command executors: dispatches commands
- Command executors → Bucket management: uses bucket
- Engine registry → Engine loader: loads engines
daemon/enginemap.cc - Engine registry → Default engine: registers backend
daemon/enginemap.cc - Engine loader → Engine interface: creates instances
- Default engine → Engine interface: implements interface
include/memcached/engine.h - Default engine → Engine lifecycle scrubber: manages instances
engines/default_engine/default_engine.cc - Engine lifecycle scrubber → Items and allocation: scrubs engine data
- KV clients → SASL authentication: authenticates
- Command executors → Role-based access: checks privileges
- KV clients → DCP replication: replicates changes
- Command executors → Subdocument commands: handles subdocument ops
- Subdocument commands → Document attributes: uses attributes
- KV clients → TLS transport: uses secure transport