Skip to main content

Redis

Updated: October 29, 2026
By Willya Randika

Redis is an in-memory key-value store often used for caching, sessions, rate limiting, and job queues. Because data lives in RAM, Redis is much faster than a database query for small, repeated reads. That speed comes with memory limits and a need for expiration strategy.

What Redis is used for

Page or fragment cache uses keys such as page:/home with a TTL. WordPress object cache uses Redis as a backend for query results. Sessions are stored with a TTL that matches the login lifetime. Rate limits use a counter per IP in a time window. Job queues use Lists, Streams, or a queue library.

Redis does not fit every kind of data. If you need relational queries, reports, or complex transactions, keep the primary database.

Limit memory and eviction

In redis.conf, set maxmemory and maxmemory-policy. For a pure cache, allkeys-lru makes sense because rarely used keys are evicted when memory is full. For sessions or queues, do not use a policy that discards data carelessly. Consider noeviction and monitor capacity.

Check usage with redis-cli INFO memory, redis-cli DBSIZE, and redis-cli --bigkeys. To inspect latency, run redis-cli --latency. A sudden increase can mean a slow network or a large key blocking the server.

Persistence and security

Redis offers RDB and AOF. RDB is fast for backups but can lose the last few minutes of data. AOF is more durable at the cost of extra I/O. If Redis is only a cache, persistence can be disabled. If it stores sessions or queues, enable it and test a restore.

Bind Redis to 127.0.0.1 or a private network, not 0.0.0.0. Enable a password or ACL, and never expose port 6379 to the internet. Separate instances for different applications when possible.

What people miss

A missing TTL lets the cache grow until memory is full. Incomplete invalidation serves old content after an update. Too many round trips to Redis per request can also be slower than one indexed database query.

Network latency is easy to forget. Redis in another region can add tens of milliseconds. Keep it close to the app, and do not treat Redis as a database replacement.

Redis complements an object cache and web cache. If the app opens database connections too often, also see Connection Pooling.

FAQ

Is Redis required for WordPress?

No. A small site with page caching often does not need it. Redis helps with many repeated queries, sessions, or high-traffic WooCommerce.

What happens when Redis restarts?

It depends on persistence. A cache can be rebuilt, but sessions or queues without persistence can be lost. Test the restart scenario in staging.

Is Redis safe on shared hosting?

Usually it is unavailable or limited. If the provider offers it, make sure the instance is isolated and not reachable from the internet.

Disclaimer: Hosting Wiki articles are prepared for educational and reference purposes. Hosting technology keeps evolving, so some technical details may change over time.