# Using Redis as cache

**URL:** <https://forum.mautic.org/t/using-redis-as-cache/26235>\
**Category:** Mautic 4 Install/Upgrade Support\
**Created:** [November 29, 2022, 2:58pm UTC](https://forum.mautic.org/t/using-redis-as-cache/26235 "2022-11-29T14:58:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hasse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hasse/32/187_2.png) [@Hasse](https://forum.mautic.org/u/Hasse)\
**Post date:** [November 29, 2022, 2:58pm UTC](https://forum.mautic.org/t/using-redis-as-cache/26235/1 "2022-11-29T14:58:28Z")

</div>

Mautic v. 4.4 and 5.X  
_My PHP version is_ : 8.0  
\*My MySQL/MariaDB version is: MySQL 5.7

**Updating/Installing Errors**  
_I am_ (delete as applicable): Installing  
_Upgrading/installing via_ (delete as applicable) : Web + Command Line

_These errors are showing in the installer_ : None

_These errors are showing in the Mautic log_ : None

**Your problem**  
I’m trying to setup Mautic in a docker container with Redis as a Cache backend.  
But I just can’t get Mautic to keep /var/cache empty and store any cache values in Redis.  
I have tried both version 4.4 and the latest 5.x

_Steps I have tried to fix the problem_:  
Installing with someting like this:  
git clone [GitHub - mautic/mautic: Mautic: Open Source Marketing Automation Software.](https://github.com/mautic/mautic.git)  
cd mautic  
composer install  
[Doing the rest of the install from the web interface]

Adding this to app/config/local.php:

…

```auto
// Cache
    'cache_adapter' => getenv("CACHE_ADAPTER") ?? "mautic.cache.adapter.redis",
    'cache_prefix' => getenv("CACHE_PREFIX") ?? "app_cache",
    'cache_lifetime' => getenv("CACHE_LIFETIME") ?? "86400",

```

```
'cache_adapter_redis' => [
    'dsn' => getenv("REDIS_DSN") ?? "redis://local-dev-redis",
    'options' => [
        'dbindex' => getenv("REDIS_OPTIONS_DBINDEX") ?? 0,
        'lazy' => getenv("REDIS_OPTIONS_LAZY") ?? false,
        'persistent' => getenv("REDIS_OPTIONS_PERSISTENT") ?? 0,
        'persistent_id' => getenv("REDIS_OPTIONS_PERSISTENT_ID") ?? null,
        'timeout' => getenv("REDIS_OPTIONS_TIMEOUT") ?? 30,
        'read_timeout' => getenv("REDIS_OPTIONS_READ_TIMEOUT") ?? 0,
        'retry_interval' => getenv("REDIS_OPTIONS_RETRY_INTERVAL") ?? 0,
        ]
    ],

```

```auto
ENVIRONMENT vars:
# 'local-dev-redis' is the name of the docker container

REDIS_DSN="redis://local-dev-redis"
REDIS_OPTIONS_DBINDEX="5"
REDIS_OPTIONS_LAZY="false"
REDIS_OPTIONS_PERSISTENT="0"
REDIS_OPTIONS_PERSISTENT_ID="null"
REDIS_OPTIONS_READ_TIMEOUT="0"
REDIS_OPTIONS_RETRY_INTERVAL="0"
REDIS_OPTIONS_TIMEOUT="30"

CACHE_ADAPTER="mautic.cache.adapter.redis"
CACHE_LIFETIME="86400"
CACHE_PREFIX="mautic_"

```

And finally clearing the cache:  
./bin/console cache:clear env=prod

And nothing shows up in redis and cache files piles up in /var/cache …

What is the proper way of doing this - how do you configure Mautic with Redis?

Pages of inspiration:  
[https://developer.mautic.org/#configuration](https://developer.mautic.org/#configuration)

> **[Mautic Community | Anyone succesfully configured redis for mautic4 | Facebook](https://www.facebook.com/groups/mautic/posts/4707231632730724/)**
>
> Anyone succesfully configured redis for mautic4?
> 
> I checked the documentation here ( https://developer.mautic.org/?php#configuration ) but the redis cache is still empty.
> 
> Do I just add parameters (...

> [@Mautic Cache Redis config](https://forum.mautic.org/t/mautic-cache-redis-config/20176/2):
>
> Hello, I am also trying to setup mautic to use Redis so I figured I would use an old post since there is no solution reply. Your software My Mautic version is: 4.1.1 My PHP version is: 7.4 My Database type and version is: MariaDB 10.3 Your problem My problem is: I am trying to configure Mautic so that it uses Redis instead of filesystem cache. I installed redis-server package on my system as well as php-redis. These errors are showing in the log: [no errors detect in logs] Steps I hav…
