Redis Cache By Xon

Redis Cache By Xon 2.17.2

No permission to download
You can try using a socket to talk to Redis, or the persistent connection option to reduce the number of connection attempts;
Code:
$config['cache']['backendOptions']['persistent'] = true;
 
You can try using a socket to talk to Redis, or the persistent connection option to reduce the number of connection attempts;
Code:
$config['cache']['backendOptions']['persistent'] = true;

Does this correct for adding persistent connection?

Code:
// START Redis configuration //
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['namespace'] = 'xfredis_';
$config['cache']['backendOptions']['persistent'] = true;

$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' => 6,
'read_timeout' => 1,
'timeout' => 1,
'serializer' => 'igbinary',
//        'serializer' => 'php',
);
// END Redis configuration //
 
Whoops, was looking at the XF1 version. This should work:
Code:
// START Redis configuration //
$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' => 6,
'read_timeout' => 1,
'timeout' => 1,
'serializer' => 'igbinary',
//        'serializer' => 'php',
'persistent' => true,
);
// END Redis configuration //
 
@Xon does this Server error log from Redis?

Code:
ErrorException: Template error: Cannot call method hasPermission on a non-object (NULL) src/XF/Template/Templater.php:926

Generated by: Unknown account May 7, 2018 at 3:19 PM

Stack trace

#0 [internal function]: XF\Template\Templater->handleTemplateError(512, 'Cannot call met...', '/home/nadda/pub...', 926, Array)
#1 src/XF/Template/Templater.php(926): trigger_error('Cannot call met...', 512)
#2 internal_data/code_cache/templates/l1/s6/public/tso_member_list_tso_stat.php(8): XF\Template\Templater->method(NULL, 'hasPermission', Array)
#3 src/XF/Template/Templater.php(1249): XF\Template\Templater->{closure}(Object(Yugensoft\TimeSpentOnline\XF\Template\Templater), Array)
#4 src/addons/AddonsLab/LinkChecker/XF/Template/Templater.php(89): XF\Template\Templater->renderTemplate('tso_member_list...', Array, true)
#5 src/XF/Template/Templater.php(1323): AddonsLab\LinkChecker\XF\Template\Templater->renderTemplate('public:tso_memb...', Array)
#6 internal_data/code_cache/templates/l1/s6/public/member_list_macros.php(90): XF\Template\Templater->includeTemplate('public:tso_memb...', Array)
#7 src/XF/Template/Templater.php(662): XF\Template\Templater->{closure}(Object(Yugensoft\TimeSpentOnline\XF\Template\Templater), Array, Array)
#8 internal_data/code_cache/templates/l1/s6/public/like_list.php(46): XF\Template\Templater->callMacro('member_list_mac...', 'item', Array, Array)
#9 src/XF/Template/Templater.php(1249): XF\Template\Templater->{closure}(Object(Yugensoft\TimeSpentOnline\XF\Template\Templater), Array)
#10 src/addons/AddonsLab/LinkChecker/XF/Template/Templater.php(89): XF\Template\Templater->renderTemplate('like_list', Array, true)
#11 src/XF/Template/Template.php(24): AddonsLab\LinkChecker\XF\Template\Templater->renderTemplate('public:like_lis...', Array)
#12 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#13 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Like\\Listing', 'public:like_lis...', Array)
#14 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#15 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#16 src/XF/App.php(1894): XF\Mvc\Dispatcher->run()
#17 src/XF.php(328): XF\App->run()
#18 index.php(13): XF::runApp('XF\\Pub\\App')
#19 {main}

Request state

array(4) {
  ["url"] => string(23) "/profile-posts/37/likes"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
The word 'redis' doesn't appear once in that error.
My guess is an interaction with 'LinkChecker' addon.
I'll put up a "guess fix" soon.

Hello!

Checking the message you can see, that "LinkChecker" is mentioned only in the full name of "Templater" class. This is the class that renders ANY template, no matter their content and the variables. We have extended the class to put some additional logic related to our add-on, but not altering the way templates render in general. Without our add-on the error would just mention "\XF\Template\Templater" as the class of templater. So, this is very unlikely to be related to our add-on. The best way to confirm it is to disable our add-on (or any conflicting add-on in question) and try to reproduce the issue.

Just let us know if you have any other questions.

Thank you!
 
XF1 version (Redis - Zend Cache 1.5.5) can be upgraded by this version?
Or I need to uninstall XF1 version first?

Same question for Redis backed Flood Checking 1.0.2 & Redis backed Views Counters 1.1.3.
 
How to convert my XF1 Redis Caching config to XF2?

XF1, I got:
PHP:
// Cache
$config['cache']['enabled'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
'caching' => true,
'cache_id_prefix' => 'xf_',
'automatic_serialization' => false,
'lifetime' => 0
);

$config['cache']['backend'] = 'Redis';
$config['cache']['backendOptions'] = array(
        'server' => '127.0.0.1',
        'port' => 6379,
        'connect_retries' => 2,
        'use_lua' => true,
        'compress_data' => 2,
        'read_timeout' => 1,
        'timeout' => 1,
);
require(XenForo_Application::getInstance()->getConfigDir().'/SV/RedisCache/Installer.php');
// End Cache


On XF2, I got now:
PHP:
// Cache Start
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config']  = array(
        'server' => '127.0.0.1',
        'port' => 6379,
        'compress_data' => 6,
        'connect_retries' => 2,
        'use_lua' => true
        );
// End Cache
 
I think this is enough:
PHP:
// Cache Start
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['namespace'] = 'xf_';
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config']  = array(
        'server' => '127.0.0.1',
        'port' => 6379,
        'compress_data' => 6,
        'connect_retries' => 2,
        'use_lua' => true,
        'read_timeout' => 1,
        'timeout' => 1,
        'serializer' => 'igbinary'
        );
// End Cache
 
Last edited:
  • Like
Reactions: Xon
Cause it's true by default?
Thanks!
I thought it was, but on checking it still defaults to not using it by default. I'ld recommend setting use_lua to true for load.

This helps A LOT on one of the big board I managed.
With 1,500-2,000 realtime online, redis will throw an error every minute without this addon.
Even after installing this addon, redis still throws an error but now it's all gone after enabling persistent.
Good to hear! It took a while for that feature to become reliable. I recommend reducing as much disk-io as you can as well.
 
Be aware that databases in redis clustering is not supported.

You can set which redis database is used setting $config['cache']['config']['database'] (default 0), XenForo will still prefix with a namespace.
 
Hi,
I am trying to connect my xenforo to my redis server. But I've got a problem which I don't quite understand.
As soon as I enable redis in config.php Xenforo isnt' working anymore. Site is not reachable. No PHP Error message, No HTTP Response Code, No Redis error logs.

I connected by unix socket. I tried different redis settings in the xf config.php, but everytime I enable caching xf does not respond anymore.

PHP:
 13 #$config['cache']['enabled'] = true;
14 #$config['cache']['provider'] = 'Redis';
15 #$config['cache']['config'] = [
16 #      'host' => 'unix:///var/run/redis/redis.sock'
17 #];
18
19 $config['cache']['enabled'] = true;
20 $config['cache']['provider'] = 'SV\RedisCache\Redis';
21 $config['cache']['config']  = array(
22     'server' => 'unix:///var/run/redis/redis.sock',
23     'compress_data' => 6
24 );

Is there something obvious wrong in my settings? Redis Server itself is setup perfectly and is running without errors.
I assume the cache provider `SV\RedisCache\Redis` is specific to the add-on? And the `Redis` provider as seen in the official xenforo documentation is the normal phpredis provider?
Does it make a difference if I use 'host' or 'server'? I have seen both variants.

Another question, not too important at the moment...
Your addon provides statistics in the dashboard. Is it disabled when no connection to the redis server established or the cache disabled? Because I installed the add-on and haven't found the statistic page yet.

best regards

Edit: Ok, I got it working with tcp. Stupid permission problem with the socket :(
I added the redis user to the www-data group and changed the socket owner to redis:www-data.
Then with 770 permission the unix socket is working. But I am not sure if 770 is to open.
 
Last edited:
Top Bottom