There are 3 steps you'll need to take in order to make Craft CMS to work properly with Redis that runs as a UNIX socket (as is the case with most single server implementations we host)
/*** The caching method that Craft should use. Valid values are 'apc', 'db', 'eaccelerator', 'file', 'memcache',
* 'redis', 'wincache', 'xcache', and 'zenddata',
* Defaults to 'file'.
'cacheMethod' => 'redis',
Here is an example of rediscache.php you can use:
* Hostname to use for connecting to the redis server. Defaults to 'localhost'.
'hostname' => 'unix:///home/USER/.kxcache/redis.sock',
* The port to use for connecting to the redis server. Default port is 6379.
'port' => '0',
* The password to use to authenticate with the redis server. If not set, no AUTH command will be sent. LEAVE EMPTY IF USING stream_socket_server BELOW
'password' => '',
* The password to use to authenticate with the redis server. If not set, no AUTH command will be sent.
'stream_socket_server' => 'STREAM_CLIENT_PERSISTENT',
* The redis database to use. This is an integer value starting from 0. Defaults to 0.
'database' => 0,
* Timeout to use for connection to redis. If not set the timeout set in php.ini will be used:
'timeout' => null,
IMPORTANT: Replace the hostname with "Your Redis socket address" as per your cPanel and also set unique database ID for this application if you host multiple applications in the same account that use Redis.
To do that, you'll need to change a line of code in: craft/app/framework/caching/CRedisCache.php
around the 85th line and change it to:
Save the change and test your Craft CMS.
The application should be properly working now, serving cache from Redis.
For even greater performance, we can strongly recommend integrating LiteSpeed into Craft CMS.