Install Memcached on Ubuntu 24.04
Step 1 – Install
apt install -y memcached libmemcached-tools
systemctl enable --now memcached
-l 127.0.0.1 # listen on localhost only
-m 256 # memory (MB)
-c 1024 # max connections
-t 4 # threads
Step 3 – Verify
echo "stats" | nc 127.0.0.1 11211
Step 4 – Basic operations
telnet 127.0.0.1 11211
set mykey 0 3600 5
hello
get mykey
quit
Step 5 – PHP client
$mc = new Memcached();
$mc->addServer('127.0.0.1', 11211);
$mc->set('key', 'value', 3600);
echo $mc->get('key');