Skip to content
Cisco edited this page Oct 27, 2025 · 7 revisions

Brief

REmote DIctionary Server is an open-source, in-memory database storing data as key-value pairs. It is quick, simple and polyvalent

  • in-memory : RAM storage allows quick access (usecs)
  • persistence : can store data on hard drive to avoid losses
  • rich datasets : strings, lists, sets, sorted sets, hashes, streams, ...
  • replication
  • high avaibility through Redis Sentinel
  • atomicity

Usages

Redis can be used for :

  • caching
  • session storage
  • message broker through Redis Pub/Sub
  • leaderboards
  • task queue

Which objects will be cached for Wordpress ?

  • query results

Can be used alongside Nginx microcaching It can be completed with a page cache

Which objects should we not cache ?

  • sessions

Commands

  • SET key value
  • GET key
  • DEL key
  • INCR key
  • LPUSHlist elem : adds an element at the start of a list
  • INFO
  • MONITOR
  • MEMORY STATS

Configuration

Redis server

Note

protect rebuilds with spaced TTL and locks to avoid Thundering Herd : when a cache content expires and many simultaneous request rebuild it

Wordpress

in /var/www/wordpress/wp-config.php or using CLI

eviction policy

// wp-config.php
// 1 day
define('WP_REDIS_MAXTTL', '86400') ;

sockets conf

// wp-config.php
define('WP_REDIS_SCHEME', 'unix') ;
define('WP_REDIS_PATH', '/tmp/redis.sock') ;
// wp-config.php
define('WP_REDIS_PASSWORD', 'strong') ;

Testing

  • inspect
  • logs
  • in container redis-cli ping

Observability and performance

Metrics

  • hit ratio : keyspace hits/misses
  • latency
  • used_memory
  • evicted keys
  • expired keys : if too many, TTL is too short
  • TTFB : time to first build
  • First contentful paint
  • server response time
  • mem_fragmentation_ratio
  • connected_clients
  • blocked_clients

Source

https://redis.io/docs/latest/ https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/apt/ https://redis.io/docs/latest/commands/

https://www.youtube.com/watch?v=G1rOthIU-uo https://www.youtube.com/watch?v=XCsS_NVAa1g https://www.manning.com/books/redis-in-action https://medium.com/@deepakkumar21158/how-redis-works-and-what-makes-it-so-fast-5f749770fe68 https://webhosting.de/fr/configuration-de-la-mise-en-cache-wordpress-redis-accelerer-les-performances-9324/

Clone this wiki locally