Redis Cache By Xon

Redis Cache By Xon 2.17.2

No permission to download
Why do many people prefer Redis over Memcache?
It's usually personal preference though more web apps are supporting Redis so easier to use Redis for other web apps too. Though Memcached has a limitation in that it has a max 250 character limit for keys so some web apps which end up handling larger character length keys will have problems i.e. one of my Centmin Mod users reported such with Wordpress https://community.centminmod.com/threads/problem-memcached-and-long-urls.1661/
 
@Xon
Could you please look at this.
I have redis with several instances.
Ports:
6379 will be for classic xf cache
6480 will be for xf guest page cache
6481 will be for xf css cache (not enabled at beginning)

Is this configuration will be OK?

PHP:
// START Redis configuration //

// Global Cache
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['namespace'] = 'xfredis_';
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = array(
    'server' => '127.0.0.1',
    'port' => 6379,
    'connect_retries' => 2,
    'use_lua' => true,
    'compress_data' => 2,
    'serializer' => 'igbinary',
//  'password' => 'password',
    'read_timeout' => 1,
    'timeout' => 1,
    'persistent' => true,
    'persistent_id' => 'global'
);


// Guest Page Cache
$config['pageCache']['enabled'] = true;
$config['pageCache']['lifetime'] = 900;
$config['pageCache']['recordSessionActivity'] = true;
$config['cache']['context']['page']['namespace'] = 'xfredispages_';
$config['cache']['context']['page']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['context']['page']['config'] = array(
    'server' => '127.0.0.1',
    'port' => 6480,
    'connect_retries' => 2,
    'use_lua' => true,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'timeout' => 1,
    'persistent' => true,
    'persistent_id' => 'pages'
);

// css cache
// $config['css']['enabled'] = true;
//$config['cache']['context']['css']['provider'] = 'Redis';
//$config['cache']['context']['css']['config'] = array(
//    'server' => '127.0.0.1',
//    'port' => 6481,
//   'connect_retries' => 2,
//    'use_lua' => true,
//    'compress_data' => 6,
//    'serializer' => 'igbinary',
//    'timeout' => 1,
//    'persistent' => true,
//    'persistent_id' => 'css'
//);

// END Redis configuration //
 
@Sunka I am using similar config at very end of the post at https://community.centminmod.com/th...mod-123-09beta01-lemp-stack.16060/#post-70603

Native Xenforo 2.1.0 css cache context using Redis provider on 127.0.0.1 port 6479 database 7 while having global cache on port 6479 database 2 and page cache on port 6480 using Xon's Redis Cache Addon provider

PHP:
// global cache
$config['cache']['enabled'] = true;
$config['cache']['namespace'] = 'xfaredis';
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6479,
    'database' => 2,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'use_lua' => true,
//  'read_timeout' => 1,
//  'timeout' => 1,
//  'lifetimelimit' => 2592000,
//  'compress_threshold' => 20480,
    'persistent' => true
];

// session cache
$config['cache']['sessions'] = true;

$config['pageCache']['enabled'] = true;
$config['pageCache']['lifetime'] = 900;
$config['pageCache']['recordSessionActivity'] = true;
$config['cache']['context']['page']['namespace'] = 'xfaredispagecache';
$config['cache']['context']['page']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['context']['page']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6480,
    'database' => 4,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'use_lua' => true,
//  'read_timeout' => 1,
//  'timeout' => 1,
//  'lifetimelimit' => 2592000,
//  'compress_threshold' => 20480,
    'persistent' => true
];

// css cache
$config['css']['enabled'] = true;
$config['cache']['context']['css']['provider'] = 'Redis';
$config['cache']['context']['css']['namespace'] = 'xfarediscsscache_';
$config['cache']['context']['css']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6479,
    'serializer' => 'igbinary',
    'database' => 7,
//  'timeout' => 1,
    'persistent' => true
];

inspecting the redis caches for global, page and css cache respectively

194912194913194911
 
Last edited:
@Sunka I am using similar config at very end of the post at https://community.centminmod.com/th...mod-123-09beta01-lemp-stack.16060/#post-70603

Native Xenforo 2.1.0 css cache context using Redis provider on 127.0.0.1 port 6479 database 7 while having global cache on port 6479 database 2 and page cache on port 6480 using Xon's Redis Cache Addon provider

PHP:
// global cache
$config['cache']['enabled'] = true;
$config['cache']['namespace'] = 'xfaredis';
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6479,
    'database' => 2,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'use_lua' => true,
    'read_timeout' => 1,
    'timeout' => 1,
    'lifetimelimit' => 2592000,
    'compress_threshold' => 20480,
    'persistent' => true
];

// session cache
$config['cache']['sessions'] = true;

$config['pageCache']['enabled'] = true;
$config['pageCache']['lifetime'] = 900;
$config['pageCache']['recordSessionActivity'] = true;
$config['cache']['context']['page']['namespace'] = 'xfaredispagecache';
$config['cache']['context']['page']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['context']['page']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6480,
    'database' => 4,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'use_lua' => true,
    'read_timeout' => 1,
    'timeout' => 1,
    'lifetimelimit' => 2592000,
    'compress_threshold' => 20480,
    'persistent' => true
];

// css cache
$config['css']['enabled'] = true;
$config['cache']['context']['css']['provider'] = 'Redis';
$config['cache']['context']['css']['namespace'] = 'xfarediscsscache_';
$config['cache']['context']['css']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6479,
    'serializer' => 'igbinary',
    'database' => 7,
    'timeout' => 1,
    'persistent' => true
];

inspecting the redis caches for global, page and css cache respectively

View attachment 194912View attachment 194913View attachment 194911

Yep, but isn't it better two have seperate instances than same port with several databases?
 
@Sunka I am using similar config at very end of the post at https://community.centminmod.com/th...mod-123-09beta01-lemp-stack.16060/#post-70603

Native Xenforo 2.1.0 css cache context using Redis provider on 127.0.0.1 port 6479 database 7 while having global cache on port 6479 database 2 and page cache on port 6480 using Xon's Redis Cache Addon provider
Update: seems extending separate CSS cache isn't working 100% with webpagetest.org 3x run tests, 2nd and 3rd runs always come back with 404 content. Removing separated CSS cache config and only using global and page cache works fine for webpagetest.org 3x run tests.

So just leave off css cache config :)

Update 2: Although it might be due to timeout settings so have commented those out while testing.
 
Last edited:
What do I put in config.php to select Redis database? I already use 0 and 1.
In XF1, I use $config['cache']['backendOptions']['database'] = 2;
 
What do I put in config.php to select Redis database? I already use 0 and 1.
In XF1, I use $config['cache']['backendOptions']['database'] = 2;

Think I got it, is this okay?

Code:
$config['cache']['sessions'] = true;

$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config']  = array(
        'server' => 'x.x.x.x',
        'port' => 6379,
        'compress_data' => 6,
        'password' => 'removed',
        'use_lua' => true,
        'read_timeout' => 1,
        'timeout' => 2,
        'database' => 2,
    );
 
@Xon if i use "Discouraged IP addresses", server to return 500 error.

my settings

PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = array(
        'server' => 'x.x.x.x',
        'port' => 6379,
        'timeout' => 2.5,
        'persistent' => null,
        'force_standalone' => false,
        'connect_retries' => 2,
        'read_timeout' => null,
        'password' => 'xxxxx',
        'database' => 0,
        'compress_data' => 6,
        'compression_lib' => null,
        'use_lua' => true,
        'serializer' => 'igbinary',
        );
after deletion of "Discouraged IP addresses" server return 200 (OK) server success worked.
 
This add-on doesn't interact with the discouragment system. It likely having a value for the "page delay" is messing with things.
 
This add-on doesn't interact with the discouragment system. It likely having a value for the "page delay" is messing with things.
Yeah, i'm sorry The problem at the very core of the forum is related to "Discouraged IP addresses".
 
Hi

I would like to avoid data list when restarting redis, mainly user sessions.
What do you suggest? RDB or AOF?

I think for this use case RDB should be enough:

save 900 1

What do you think?
 
Top Bottom