Redis Configuration in XF2

developr

Active member
Dear Community,

I configured Redis Cache in config.php but it seems that Redis doesn't work out of the box with XF2.

Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
    'directory' => '/var/htdocs/internal_data/cache',
     'server' => '127.0.0.1',
     'host' => '127.0.0.1',
        'port' => 6379,
        'compress_data' => 6,
        'connect_retries' => 2,
        'use_lua' => true,
        'read_timeout' => 1,
        'timeout' => 1,
        'database' => 2,
        'serializer' => 'igbinary'
];
$config['cache']['cacheSessions'] = true;

In XF1 forums I'm using the Addon from Xon (also exists for XF2) and this work very well.

I checked the RDB with redis-cli and there is a big difference in amount of keys from XF1/XF2 after flushing RDB.

# Keyspace
db4:keys=37,expires=37,avg_ttl=1803293 (XF2)
db5:keys=6357,expires=6357,avg_ttl=1692423 (XF1)

Is my config correct?
 
Is my config correct?
Did you try with a minimal configuration?
I'm using something like this:
Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
        'host' => '127.0.0.1',
        'password' => '...',
        'database' => 1
        ];
$config['cache']['sessions'] = true;

In your example, you are using $config['cache']['cacheSessions'] instead of $config['cache']['sessions'] which might explain the difference in the rdb.
 
Thanks for the tip with session instead of cacheSessions.

Maybe I will try Xon's Addon in XF2 as well :).
 
How much speed increase should we expect in page generation times with Redis enabled?

Page load time with redis enabled/disabled is the same, I haven't seen a difference.
forum.webp

Settings are

// setup redis caching
$config['cache']['enabled'] = true;
$config['pagecache']['enabled'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
// all keys and their defaults
$config['cache']['config'] = array(
'server' => '127.0.0.1',
'port' => 6379,
'timeout' => 2.5,
'persistent' => null,
'force_standalone' => false,
'connect_retries' => 1,
'read_timeout' => null,
'password' => null,
'database' => 0,
'compress_data' => 1,
'lifetimelimit' => 2592000,
'compress_threshold' => 20480,
'compression_lib' => null, // dynamically select first of; snappy,lzf,l4z,gzip IF EMPTY/null
'use_lua' => true,
'serializer' => 'igbinary', // to disable set ot 'php'
'retry_reads_on_master' => false,
// HA support
'load_from_slave' => null, // config entry similar to $config['cache']['config'], except without HA options
'load_from_slaves' => null, // config entry similar to $config['cache']['config'], except without HA options
'sentinel_master_set' => null,
'sentinel_persistent' => null,
);

redis.webp
So it looks like it is working, but little difference in results with it on or off. Does the config look correct? The settings were copied from one of the examples in the Redis Cache 2.6.2 addon.
 
Top Bottom