LinuxCommandLibrary

memcached

TLDR

Start memcached

$ memcached
copy
Start with specific memory
$ memcached -m [256]
copy
Listen on specific port
$ memcached -p [11211]
copy
Run as daemon
$ memcached -d -u [memcache]
copy
Verbose output
$ memcached -vv
copy
Limit connections
$ memcached -c [1024]
copy

SYNOPSIS

memcached [options]

DESCRIPTION

memcached is a high-performance, distributed memory caching system. It stores key-value pairs in RAM to reduce database load and speed up dynamic web applications.
memcached uses a simple protocol and is widely used for caching database queries, API responses, and session data.

PARAMETERS

-p port

TCP port (default 11211).
-m MB
Memory limit in megabytes.
-c connections
Max simultaneous connections.
-d
Run as daemon.
-u user
Run as user.
-l ip
Listen address.
-v, -vv
Verbose output.
-t threads
Number of threads.

PROTOCOL COMMANDS

$ set key 0 3600 5\r\nvalue\r\n  # Store
get key\r\n                     # Retrieve
delete key\r\n                  # Remove
incr key 1\r\n                  # Increment
stats\r\n                       # Statistics
copy

CAVEATS

No persistence (RAM only). No authentication by default. LRU eviction when full. Not for large values (1MB limit).

HISTORY

memcached was developed by Brad Fitzpatrick at LiveJournal in 2003 to reduce database load. It became foundational for web scaling.

SEE ALSO

redis(1), redis-cli(1), valkey(1)

Copied to clipboard