↑ ↓ select, Enter open, Esc close

Redis and Memcached

Object caches make WordPress and other PHP applications noticeably faster. Commands to check, flush, monitor and debug Redis and Memcached.

15 one-liners: 12 harmless, 1 caution, 2 destructive

All Redis and Memcached one-liners

Check the Redis Object Cache status in WordPress

$wp redis status --path=/var/www/vhosts/example.com/httpdocs
harmless

Check whether Redis is reachable

$redis-cli -h 127.0.0.1 -p 6379 ping
harmless

Connect to Redis over a Unix socket

$redis-cli -s /run/redis/redis-server.sock ping
harmless

Count Redis keys by pattern without blocking the server

$redis-cli -n 0 --scan --pattern '*transient*' | wc -l
harmless

Count the keys in a Redis database

$redis-cli -n 0 DBSIZE
harmless

Find the biggest keys in Redis

$redis-cli -n 0 --bigkeys
harmless

More power on the server

Does the optimization reach your visitors?

Faster database, more RAM, better caching: GENLOC.SEO measures whether it shows up in PageSpeed and Core Web Vitals. Free, for mobile and desktop.

by GENLOC.NETWORK, the team behind myline.de

Flush a single Redis database (FLUSHDB)

$redis-cli -n 0 FLUSHDB
destructive

Flush all Redis databases (FLUSHALL)

$redis-cli FLUSHALL
destructive

Flush Memcached completely (flush_all)

$printf 'flush_all\nquit\n' | nc 127.0.0.1 11211
caution

Query Memcached statistics with netcat

$printf 'stats\nquit\n' | nc 127.0.0.1 11211 | grep -E 'STAT (curr_items|bytes|limit_maxbytes|get_hits|get_misses|evictions|curr_connections) '
harmless

Show Redis memory usage and limit

$redis-cli INFO memory | grep -E '^(used_memory_human|used_memory_peak_human|maxmemory_human|maxmemory_policy|mem_fragmentation_ratio):'
harmless

Show slow Redis commands (SLOWLOG)

$redis-cli SLOWLOG GET 10
harmless

Show the Redis cache hit rate

$redis-cli INFO stats | grep -E '^(keyspace_hits|keyspace_misses|evicted_keys|expired_keys):'
harmless

Show used Redis databases and key counts

$redis-cli INFO keyspace
harmless

Watch Redis commands live for a short time (MONITOR)

$timeout 10 redis-cli MONITOR
harmless

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.