01
Getting Started
Connect & Basic Commands
Memcached uses a simple text protocol on port 11211. The set command takes flags (a 32-bit integer opaque to the server), exptime (expiration in seconds, 0 = no expiry), and byte size. Values are stored as raw bytes — the server never inspects or modifies them. memcached-tool ships with the server and is handy for quick stats.
memcached
# connect to a memcached server
telnet localhost 11211
# or use the memcached-tool (ships with the server)
memcached-tool localhost:11211 stats
# set a key (flags, exptime, bytes)
set mykey 0 3600 5
hello
# get a key
get mykey
# delete a key
delete mykeyProtocol Overview
Memcached supports both an ASCII text protocol (easy to use with telnet/netcat) and a binary protocol (more efficient, supports SASL authentication and atomic operations). The binary protocol uses a fixed 24-byte header and is preferred by most production clients. Both protocols operate on the same underlying key-value store.
memcached