Protocol Compatibility Reference

This is the definitive reference for RedCouch's protocol support. For tutorial-style examples, see the User Guide.

RedCouch implements three memcached protocol surfaces over a single TCP listener (port 11210). Protocol detection is automatic: the first byte of each connection determines the protocol.

First ByteProtocol
0x80Binary (Couchbase memcached)
Printable ASCIIText (ASCII or meta commands)
\r or \nSkipped; next byte determines protocol

Binary Protocol

Based on the Couchbase memcached binary protocol. All 34 opcodes (0x00–0x22, excluding 0x1F) are parsed and dispatched.

Supported Operations

Opcode FamilyOpcodesStatusNotes
GETGET (0x00), GETQ (0x09), GETK (0x0C), GETKQ (0x0D)✅ SupportedReturns value, flags, CAS. Quiet variants suppress success responses. Key-inclusive variants echo key.
SET/ADD/REPLACESET (0x01), SETQ (0x11), ADD (0x02), ADDQ (0x12), REPLACE (0x03), REPLACEQ (0x13)✅ SupportedCAS-checked mutations. Flags, expiry, and binary-safe values preserved.
DELETEDELETE (0x04), DELETEQ (0x14)✅ SupportedCAS-checked. Returns item CAS on success.
INCREMENT/DECREMENTINCR (0x05), INCRQ (0x15), DECR (0x06), DECRQ (0x16)✅ SupportedUnsigned 64-bit semantics with initial-value and miss rules. See Limitations.
APPEND/PREPENDAPPEND (0x0E), APPENDQ (0x19), PREPEND (0x0F), PREPENDQ (0x1A)✅ SupportedRequires existing item.
TOUCHTOUCH (0x1C)✅ SupportedUpdates TTL on existing items.
GAT/GATQGAT (0x1D), GATQ (0x1E)✅ SupportedGet-and-touch with TTL update. Key included in response.
FLUSHFLUSH (0x08), FLUSHQ (0x18)✅ SupportedNamespace-isolated: flushes only RedCouch keys (rc:*), never FLUSHDB.
NOOPNOOP (0x0A)✅ SupportedPipeline terminator.
QUITQUIT (0x07), QUITQ (0x17)✅ SupportedGraceful connection close.
VERSIONVERSION (0x0B)✅ SupportedReturns RedCouch 0.1.0.
STATSTAT (0x10)✅ SupportedGeneral stats (pid, uptime, version, cmd_get, cmd_set, curr_items).
VERBOSITYVERBOSITY (0x1B)✅ SupportedAccepted and acknowledged; no runtime effect.
SASL AUTHSASL_LIST_MECHS (0x20), SASL_AUTH (0x21), SASL_STEP (0x22)⚠️ StubLists "PLAIN". Auth always succeeds — no credential enforcement.
UnknownAny unrecognized opcode✅ HandledReturns Unknown command (status 0x0081).

Unsupported Binary Behaviors

FeatureStatusReason
STAT groups (settings, items, slabs, conns)❌ Not supportedReturns empty terminator for sub-groups
Dynamic SASL credential enforcement❌ Not implementedStub-only: auth always succeeds
UDP transport❌ Not supportedTCP only
Couchbase bucket/vbucket management❌ Not supportedOutside bridge scope

ASCII Text Protocol

Based on the memcached ASCII text protocol. All 19 standard commands are implemented.

Supported Commands

CommandSyntaxStatus
setset <key> <flags> <exptime> <bytes> [noreply]\r\n<data>\r\n
addadd <key> <flags> <exptime> <bytes> [noreply]\r\n<data>\r\n
replacereplace <key> <flags> <exptime> <bytes> [noreply]\r\n<data>\r\n
cascas <key> <flags> <exptime> <bytes> <cas_unique> [noreply]\r\n<data>\r\n
appendappend <key> <bytes> [noreply]\r\n<data>\r\n
prependprepend <key> <bytes> [noreply]\r\n<data>\r\n
getget <key> [<key> ...]
getsgets <key> [<key> ...]
gatgat <exptime> <key> [<key> ...]
gatsgats <exptime> <key> [<key> ...]
deletedelete <key> [noreply]
incrincr <key> <value> [noreply]
decrdecr <key> <value> [noreply]
touchtouch <key> <exptime> [noreply]
flush_allflush_all [delay] [noreply]
versionversion
statsstats [group]
verbosityverbosity <level> [noreply]
quitquit

Unsupported ASCII Behaviors

FeatureStatusReason
Authentication❌ Not supportedNo SASL/auth in ASCII text mode (per memcached spec)
flush_all delay⚠️ Accepted, not honoredDelay parameter parsed but flush is immediate
noreply on malformed input⚠️ PartialCLIENT_ERROR may still be emitted if noreply cannot be parsed before the error

Meta Protocol

Meta commands use two-letter prefixes and a flag-based system, routed through the ASCII text-protocol path.

Supported Meta Commands

CommandSyntaxStatusSupported Flags
mg (meta get)mg <key> [flags]v, c, f, k, s, O, q, t, T
ms (meta set)ms <key> <datalen> [flags]\r\n<data>\r\nF, T, C, q, O, k, M (mode: S/E/A/P/R)
md (meta delete)md <key> [flags]C, q, O, k
ma (meta arithmetic)ma <key> [flags]D, J, N, q, O, k, v, c, M (mode: I/D)
mn (meta noop)mn [flags]O
me (meta debug)me <key> [flags]⚠️ StubReturns EN. Flags O, k, q accepted.

Unsupported Meta Behaviors

FeatureStatusReason
Stale items (vivify/invalidate)Requires stale item concept not in item model
Recache (R flag on mg)Requires stale item concept
Win/lose/stale flags (W, X, Z)Requires stale item concept
Base64 keys (b flag)Not implemented
me debug data❌ StubAlways returns EN (not found)

Item Model

All three protocols share the same underlying item model stored in Redis:

PropertyImplementation
Storage shapeHash-per-item: HSET <redis_key> v <value> f <flags> c <cas>
Key namespaceClient key foo → Redis key rc:foo
Reserved keysSystem keys under redcouch:sys:* (e.g., redcouch:sys:cas_counter)
CASMonotonic counter via INCR redcouch:sys:cas_counter
Binary-safe valuesFull binary round-trip via Lua hex encode/decode
Flags32-bit unsigned, stored as decimal string
Expiry0 = no expiry, ≤2592000 = relative seconds, >2592000 = absolute Unix timestamp
Atomic mutationsAll CAS-sensitive operations use server-side Lua scripts
Flush scopeFLUSH operates only on rc:* keys, never FLUSHDB