The official Redis image saves to disk by default, and a cache that survives a restart is occasionally what you want and usually a way to carry a corrupt entry across a deploy.
services:
cache:
image: redis:5-alpine
command: ["redis-server", "--save", "", "--appendonly", "no",
"--maxmemory", "256mb", "--maxmemory-policy", "allkeys-lru"]
# a second instance for anything that must not be evicted
queue:
image: redis:5-alpine
command: ["redis-server", "--appendonly", "yes"]
volumes: [queue:/data]
The split is the part worth copying. One instance configured as a cache with an eviction policy and one configured as a store with persistence means the cache can be full without the queue losing jobs — which is exactly what happens when both share an instance and allkeys-lru starts evicting queue keys. It costs about twenty megabytes of RAM to separate them, and it removes an entire category of incident.