Adding Redis cache via config.php, how to add mappings?

Adding Redis cache via config.php, how to add mappings?

by Jay Dee -
Number of replies: 6
Hi,
I'm trying to add redis to moodle via the config.php file, so that an admin doesn't need to add redis to moodle via the web interface.
Is this even possible? Because I can't find settings in the config.php file that define "stores" or "store mappings".

As you can see here, the redis plugin is installed, but how do I configure a store or mapping?

cache1

My current config.
cache2
Average of ratings: -
In reply to Jay Dee

Re: Adding Redis cache via config.php, how to add mappings?

by Jay Dee -
Does someone have an idea if it's possible to configure a Redis cache store via config file? Thanks.
In reply to Jay Dee

Re: Adding Redis cache via config.php, how to add mappings?

by Alain Raap -
Picture of Particularly helpful Moodlers
Hi Jay Dee, if you choose "Add instance", you can add a store for Redis and map it on the same page to
application/session. If you can start /usr/bin/redis-cli on the server, you can check with command MONITOR
if your caching server is working.
In reply to Alain Raap

Re: Adding Redis cache via config.php, how to add mappings?

by Jay Dee -
Thanks for the answer.
Adding the store manually via the frontend works, but I'm trying to configure the store and store-mapping with the config file. So that I can just start the moodle instance and everything is already configured, without the need to manually login as an admin and assign redis instances in the frontend.

Is that even possible, to configure the stores outside of the frontend via the config file or CLI?
In reply to Jay Dee

Re: Adding Redis cache via config.php, how to add mappings?

by Alain Raap -
Picture of Particularly helpful Moodlers
It's possible to only configure your Redis in config.php, I tested it on a server and the caching was assigned to my Redis instance I configured in my config.php. I saw with 'redis-cli MONITOR' that the caching server was assigned and was showing the keys.
I don't know if it's also necessary to configure a cache store on the frontend, it seems not, as it works when configured in the config file.
In reply to Alain Raap

Re: Adding Redis cache via config.php, how to add mappings?

by Jay Dee -
I had some time for testing this. When I monitor the Redis cache I can see that there is some activity when browsing moodle. But when I configure Redis as a store in the moodle admin panel and assign the store mappings manually, then there is a ~10x increase in activity on Redis.

So moodle is doing something with the cache, but could do more if configured in the admin panel.

My question is then, can I do the store mappings (as in the screenshot below) in the config file? Or somehow assign the default store to the Redis instance? Because there is a lot of caching potential not utilized when the store is not assign.

redis config
In reply to Jay Dee

Re: Adding Redis cache via config.php, how to add mappings?

by Alain Raap -
Picture of Particularly helpful Moodlers
I think (assume) that configuring Redis in the config.php is only for the session handler. The names of the CFG variables begin with session_redis, but correct me if I'm wrong.