What is Redis?

Redis is an advanced key-value store, better known as a data-structure server. It can be considered a type of database that works with key-value pairs and uses main memory for storing data. Its use of main memory means that it is both fast and scalable, but may be confined by the capacity of the RAM.

When speaking of use cases of using Redis, the most generic use case that comes to many is for caching data and for session store

How Redis Works

How Redis Works

In that Service it's required, just a dockerfile to install radios and their dependencies And adding some configuration.

# Base Image
FROM debian:buster
# Install redis-server and install php-redis
RUN apt update && apt install -y redis-server && apt install -y php-redis
# change the bind adress from listening 127.0.01 to 0.0.0.0 
# tha means Redis will only accept client connections made to 0.0.0.0 (accept connection to any address)
RUN sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/redis/redis.conf
# maxmemory dictates the amount of memory allocated for a data set.
# If maxmemory is reached, you lose data only if the eviction policy set in maxmemory-policy indicates Redis to evict
# some keys and how to select these keys (volatile or all, lfu/lru/ttl/random). Otherwise, Redis start rejecting write
# commands to preserve the data already in memory. Read commands continue to be served.
RUN echo "maxmemory 256mb">> /etc/redis/redis.conf && echo "maxmemory-policy allkeys-lfu" >> /etc/redis/redis.conf
# The Redis server is an in-memory data store , Redis will accept connection from any host (useful for development or testing environments)
CMD ["redis-server", "--protected-mode", "no"]

I exposed port 6379, the default port for Redis

Redis section in docker-compose.yml

Redis section in docker-compose.yml

Go to the website, log in to the dashboard, then navigate to the settings section where the Redis plugin is located. Here, you can check to see if the plugin is correctly installed and enabled; if it is, it will show up in this part.

Screen Shot 2023-01-11 at 9.41.02 AM.png

You can check if Redis is running by connecting to the Redis container using the command docker exec -it container_name bash and then running redis-cli monitor in the terminal. Then browse the WordPress website if it's correct and run some output of the cache appearing in the terminal.

Resources

Redis Explained

How To Configure Redis Caching to Speed Up WordPress on Ubuntu 14.04 | DigitalOcean

Redis as a Database