Redis support for Concrete5?

Permalink 1 user found helpful
Hi there, I'm trying to enable Redis on my website, my webhosting is supporting it but I can't figure out how to enable it for my Concrete5 installation. Anyone has it working and is willing to share how to do it?

 
dimger84 replied on at Permalink Reply
dimger84
You can take a look here:
https://github.com/concrete5/concrete5/pull/7206#issuecomment-546684...

You just need to configure your concrete.php config file with your redis credentials and change the preffered driver to 'redis'.
Bernier replied on at Permalink Reply
This is the sample override of Redis cache config for concrete5. This version only works and tested with PHP version 7.2 and 7.3.
JaPPa replied on at Permalink Reply
Thank you very much for the reply! I'm not that confident with the config file tho, could you show me an example how to enable Redis inside the config file?
JaPPa replied on at Permalink Reply 1 Attachment
Where do I set the preferred driver to Redis? My concrete.php looks like this now:

<?php
/**
 * -----------------------------------------------------------------------------
 * Generated 2020-12-14T18:30:43+01:00
 *
 * DO NOT EDIT THIS FILE DIRECTLY
 *
 * @item      cache.clear.thumbnails
 * @group     concrete
 * @namespace null
 * -----------------------------------------------------------------------------
 */
return [
    'locale' => 'nl_NL',
    'version_installed' => '8.5.4',


It's showing a error message (see attachment).
Streettt replied on at Permalink Reply
Do you mind if I suggest to add these classes to the concrete5 core ... Stash already supports redis, but we are missing session and page cachehttp://www.alaskasworld.me/
JohntheFish replied on at Permalink Reply
JohntheFish
The place to make such a request is on GitHub - feel free to open an issue.
JaPPa replied on at Permalink Reply
Can anyone help me to setup the configuration? I can't get it to work on my own :(.
zZjessahZz replied on at Permalink Reply 1 Attachment
zZjessahZz
I figured it out!
Because we use a UNIX socket instead of TCP/IP, we need to do the following:
* Specify the server using the path to the socket. In my case, this was "/tmp/redis.sock"
* Specify the port as "0" (choose any other, or leave it out and your website stops functioning.)

Because it was quite the mission to find the correct configuration lines for the different caching that's possible in Concrete5 I will share the contents of my concrete.php below.
Please note that this file should be placed in the ./application/config folder, Leave concrete.php located in ./concrete/config or any other folder alone. (if ./application/config does not have a concrete.php file, just create it)

<?php
return [
   'cache' => [
      'levels' => [
         'overrides' => [
            'preferred_driver' => 'redis',
               'drivers'=> [
                  'redis'=>[
                     'options' => [
                        'servers' => [
                           [
                              'server' => '/tmp/redis.sock',
                              'port' => 0, //0 when connecting to a UNIX socket
                           ],
                        ],


Note that I have used a different Redis database number for each cache as this was recommended. change the number as required if you are already using the ones in my config for another website.

The config takes care of using Redis for Overrides cache, Expensive cache, Full page caching, and Session handling. Object caching is also possible but when I tried it, it had a negative impact on the performance of my website.

I hope this helps everyone!

Best regards,
Jesse

ps: I have also included the contents of the above code box as an attachment.