It's pretty easy to configure caching with redis in shopware6!
On our TurboStack you have redis and redis persistent available. Here is a sample configuration, test thourougly on your shopware version before putting into production.
Put a file, e.g. config/packages/redisconfig.yaml
framework:
session:
handler_id: "redis:///var/run/redis-persistent/redis.sock/1"
cache:
prefix_seed: shopware
app: cache.adapter.redis
default_redis_provider: "redis:///var/run/redis/redis.sock/1"
pools:
cache.object:
default_lifetime: 86400
adapter: cache.app
tags: cache.tags
cache.http:
default_lifetime: 86400
adapter: cache.app
tags: cache.tags
cache.tags:
adapter: cache.app
Another extended configuration which
- Uses redis also for messenger process (to minimize the MySQL database load)
- Will invalidate cache asynchronously
- Uses redis to cache the shopping cart, the cart is expired after 21 days in this example to not endlessly fill up redis
- Reference: https://github.com/shopware/platform/blob/trunk/adr/performance/2022-03-25-redis-cart-persister.md
- If you use this, you might want to migrate the carts from MySQL with this command: bin/console cart:migrate --from=sql
framework:
session:
handler_id: "redis:///var/run/redis-persistent/redis.sock/1"
messenger:
transports:
default:
dsn: "redis://localhost:6378/messages/symfony/consumer?delete_after_ack=true&delete_after_reject=true&dbindex=2"
cache:
prefix_seed: shopware
app: cache.adapter.redis
default_redis_provider: "redis:///var/run/redis/redis.sock/1"
pools:
cache.object:
default_lifetime: 86400
adapter: cache.app
tags: cache.tags
cache.http:
default_lifetime: 86400
adapter: cache.app
tags: cache.tags
cache.tags:
adapter: cache.app
shopware:
cache:
invalidation:
delay: 0
count: 150
cart:
expire_days: 21
redis_url: "redis:///var/run/redis-persistent/redis.sock/3"