Redis Cache By Xon

Redis Cache By Xon 2.17.2

No permission to download
2.1.1 - Bugfix update

Version no are not updated here?

k_5qodAnTNOqycTiv1518w.png
 
Do you have a slave connected?

How to check slave connect? I am using this code.

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',
);
// END Redis configuration //

Previously it was creating 5 of them which was missleading.

Yes, v2.1.0 will showing slave info but now no info about slave.

fu9Qg1PbSjaeiuIV9WXe0A.png
 
That number was incorrect before (I was blindly appending 4 copies of the 0'th entry to an array), that count comes from counting the contents of that array.

The slave stats are separate instances of Redis, you can see if there are any slaves connected to your redis instance via redis-cli info | grep slave
 
The slave stats are separate instances of Redis, you can see if there are any slaves connected to your redis instance via redis-cli info | grep slave

So how to connect slave?

Code:
[root@na ~]# redis-cli info | grep slave
connected_slaves:0
[root@na ~]#

Code:
[root@na ~]# ss -nlp|grep redis
tcp    LISTEN     0      128    127.0.0.1:6379                  *:*                   users:(("redis-server",pid=6502,fd=4))
[root@na ~]#

Do we need adding $config['cache']['config']['load_from_slaves'] = true;

Example:

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,

'load_from_slaves' = true,

'connect_retries' => 2,

'use_lua' => true,

'compress_data' => 6,

'read_timeout' => 1,

'timeout' => 1,

'serializer' => 'igbinary',

//        'serializer' => 'php',

);

// END Redis configuration //
 
Last edited:
OK I do enable slaveof 192.0.2.100 6379 Slave. Now getting Server error logs.

Code:
[root@na ~]# redis-cli info | grep slave
role:slave
slave_repl_offset:1
slave_priority:100
slave_read_only:1
connected_slaves:0
[root@na ~]#

Code:
CredisException: Template public:forum_list error: READONLY You can't write against a read only slave. src/addons/SV/RedisCache/Credis/Client.php:1157

Generated by: rokon15 Feb 4, 2018 at 12:34 AM

Stack trace

#0 src/addons/SV/RedisCache/Redis.php(301): Credis_Client->__call('set', Array)
#1 src/addons/SV/RedisCache/CacheProvider.php(87): SV\RedisCache\Redis->doSave('xfredis__data_d...', '\x00\x00\x00\x02\x14\x01\x06\x01\x14\x1E\x11\x07dri...', 3600)
#2 src/XF/DataRegistry.php(187): SV\RedisCache\CacheProvider->save('data_dbt_donate...', Array, 3600)
#3 src/XF/DataRegistry.php(156): XF\DataRegistry->setInCache('dbt_donate_driv...', Array)
#4 src/XF/DataRegistry.php(82): XF\DataRegistry->readFromDb(Array, Array)
#5 src/addons/DBTech/Donate/Application/AbstractCache.php(205): XF\DataRegistry->get(Array)
#6 src/addons/DBTech/Donate/Application/AbstractCache.php(150): DBTech\Donate\Application\AbstractCache->fetchFromDatastore()
#7 src/addons/DBTech/Donate/Application/EntityManager.php(109): DBTech\Donate\Application\AbstractCache->get('drive')
#8 src/addons/DBTech/Donate/XF/Widget/Drives.php(28): DBTech\Donate\Application\EntityManager->findCached('DBTech\\Donate:D...')
#9 src/XF/Template/Templater.php(1522): DBTech\Donate\XF\Widget\Drives->render()
#10 internal_data/code_cache/templates/l1/s21/public/forum_list.php(206): XF\Template\Templater->widgetPosition('forum_list_side...', Array)
#11 src/XF/Template/Templater.php(1246): XF\Template\Templater->{closure}(Object(ThemeHouse\Reactions\XF\Template\Templater), Array)
#12 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#13 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#14 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#15 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#16 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#17 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#18 src/XF.php(328): XF\App->run()
#19 index.php(13): XF::runApp('XF\\Pub\\App')
#20 {main}

-------------

Previous RedisException: READONLY You can't write against a read only slave. - src/addons/SV/RedisCache/Credis/Client.php:1139
#0 src/addons/SV/RedisCache/Credis/Client.php(1139): Redis->set('xfredis__data_d...', '\x00\x00\x00\x02\x14\x01\x06\x01\x14\x1E\x11\x07dri...', 3600)
#1 src/addons/SV/RedisCache/Redis.php(301): Credis_Client->__call('set', Array)
#2 src/addons/SV/RedisCache/CacheProvider.php(87): SV\RedisCache\Redis->doSave('xfredis__data_d...', '\x00\x00\x00\x02\x14\x01\x06\x01\x14\x1E\x11\x07dri...', 3600)
#3 src/XF/DataRegistry.php(187): SV\RedisCache\CacheProvider->save('data_dbt_donate...', Array, 3600)
#4 src/XF/DataRegistry.php(156): XF\DataRegistry->setInCache('dbt_donate_driv...', Array)
#5 src/XF/DataRegistry.php(82): XF\DataRegistry->readFromDb(Array, Array)
#6 src/addons/DBTech/Donate/Application/AbstractCache.php(205): XF\DataRegistry->get(Array)
#7 src/addons/DBTech/Donate/Application/AbstractCache.php(150): DBTech\Donate\Application\AbstractCache->fetchFromDatastore()
#8 src/addons/DBTech/Donate/Application/EntityManager.php(109): DBTech\Donate\Application\AbstractCache->get('drive')
#9 src/addons/DBTech/Donate/XF/Widget/Drives.php(28): DBTech\Donate\Application\EntityManager->findCached('DBTech\\Donate:D...')
#10 src/XF/Template/Templater.php(1522): DBTech\Donate\XF\Widget\Drives->render()
#11 internal_data/code_cache/templates/l1/s21/public/forum_list.php(206): XF\Template\Templater->widgetPosition('forum_list_side...', Array)
#12 src/XF/Template/Templater.php(1246): XF\Template\Templater->{closure}(Object(ThemeHouse\Reactions\XF\Template\Templater), Array)
#13 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#14 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#15 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#16 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#17 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#18 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#19 src/XF.php(328): XF\App->run()
#20 index.php(13): XF::runApp('XF\\Pub\\App')
#21 {main}

Request state

array(4) {
  ["url"] => string(1) "/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
CredisException: READONLY You can't write against a read only slave. src/addons/SV/RedisCache/Credis/Client.php:1193

Generated by: rokon15 Feb 4, 2018 at 12:34 AM

Stack trace

#0 src/addons/SV/RedisCache/Redis.php(247): Credis_Client->__call('mget', Array)
#1 src/addons/SV/RedisCache/CacheProvider.php(60): SV\RedisCache\Redis->doFetchMultiple(Array)
#2 src/XF/DataRegistry.php(113): SV\RedisCache\CacheProvider->fetchMultiple(Array)
#3 src/XF/DataRegistry.php(81): XF\DataRegistry->readFromCache(Array, Array)
#4 src/addons/DBTech/Donate/Application/AbstractCache.php(205): XF\DataRegistry->get(Array)
#5 src/addons/DBTech/Donate/Application/AbstractCache.php(150): DBTech\Donate\Application\AbstractCache->fetchFromDatastore()
#6 src/addons/DBTech/Donate/Application/EntityManager.php(109): DBTech\Donate\Application\AbstractCache->get('drive')
#7 src/addons/DBTech/Donate/XF/Navigation.php(19): DBTech\Donate\Application\EntityManager->findCached('DBTech\\Donate:D...')
#8 src/addons/DBTech/Donate/XF/EventListener/NavigationSetup.php(10): DBTech\Donate\XF\Navigation::compile(Object(XF\Pub\App), Array, Array)
#9 [internal function]: DBTech\Donate\XF\EventListener\NavigationSetup::fire(Object(XF\Pub\App), Array, Array)
#10 src/XF/Extension.php(67): call_user_func_array(Array, Array)
#11 src/XF/App.php(2350): XF\Extension->fire('navigation_setu...', Array, NULL)
#12 src/XF/Pub/App.php(474): XF\App->fire('navigation_setu...', Array)
#13 src/XF/Pub/App.php(415): XF\Pub\App->getNavigation(Array, 'forums')
#14 src/XF/App.php(1724): XF\Pub\App->renderPageHtml('\n\n\n\n\n\n\n\n', Array, Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#15 src/XF/Mvc/Dispatcher.php(310): XF\App->renderPage('\n\n\n\n\n\n\n\n', Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#16 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#17 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#18 src/XF.php(328): XF\App->run()
#19 index.php(13): XF::runApp('XF\\Pub\\App')
#20 {main}

Request state

array(4) {
  ["url"] => string(1) "/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
So how to connect slave?
You likely do not need to setup a redis slave instance, and this is fairly advanced functionality which can rapidly become very complex. And is well outside the scope of this add-on's support.

Do we need adding $config['cache']['config']['load_from_slaves'] = true;
Kinda, please look at the FAQ; 'Sample Single Redis Slave Configuration' and ' Sample Redis Sentinel Configuration' sections.

For general use, this add-on does not do dynamic slave discovery, and relies on Redis Sentinel for that.

load_from_slaves assumes you are connected to a redis sentinel which can report a master and any slaves.

OK I do enable slaveof 192.0.2.100 6379 Slave. Now getting Server error logs.

Code:
[root@na ~]# redis-cli info | grep slave
role:slave
slave_repl_offset:1
slave_priority:100
slave_read_only:1
connected_slaves:0
[root@na ~]#

Code:
CredisException: Template public:forum_list error: READONLY You can't write against a read only slave. src/addons/SV/RedisCache/Credis/Client.php:1157

Generated by: rokon15 Feb 4, 2018 at 12:34 AM

Stack trace

#0 src/addons/SV/RedisCache/Redis.php(301): Credis_Client->__call('set', Array)
#1 src/addons/SV/RedisCache/CacheProvider.php(87): SV\RedisCache\Redis->doSave('xfredis__data_d...', '\x00\x00\x00\x02\x14\x01\x06\x01\x14\x1E\x11\x07dri...', 3600)
#2 src/XF/DataRegistry.php(187): SV\RedisCache\CacheProvider->save('data_dbt_donate...', Array, 3600)
#3 src/XF/DataRegistry.php(156): XF\DataRegistry->setInCache('dbt_donate_driv...', Array)
#4 src/XF/DataRegistry.php(82): XF\DataRegistry->readFromDb(Array, Array)
#5 src/addons/DBTech/Donate/Application/AbstractCache.php(205): XF\DataRegistry->get(Array)
#6 src/addons/DBTech/Donate/Application/AbstractCache.php(150): DBTech\Donate\Application\AbstractCache->fetchFromDatastore()
#7 src/addons/DBTech/Donate/Application/EntityManager.php(109): DBTech\Donate\Application\AbstractCache->get('drive')
#8 src/addons/DBTech/Donate/XF/Widget/Drives.php(28): DBTech\Donate\Application\EntityManager->findCached('DBTech\\Donate:D...')
#9 src/XF/Template/Templater.php(1522): DBTech\Donate\XF\Widget\Drives->render()
#10 internal_data/code_cache/templates/l1/s21/public/forum_list.php(206): XF\Template\Templater->widgetPosition('forum_list_side...', Array)
#11 src/XF/Template/Templater.php(1246): XF\Template\Templater->{closure}(Object(ThemeHouse\Reactions\XF\Template\Templater), Array)
#12 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#13 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#14 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#15 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#16 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#17 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#18 src/XF.php(328): XF\App->run()
#19 index.php(13): XF::runApp('XF\\Pub\\App')
#20 {main}

-------------

Previous RedisException: READONLY You can't write against a read only slave. - src/addons/SV/RedisCache/Credis/Client.php:1139
#0 src/addons/SV/RedisCache/Credis/Client.php(1139): Redis->set('xfredis__data_d...', '\x00\x00\x00\x02\x14\x01\x06\x01\x14\x1E\x11\x07dri...', 3600)
#1 src/addons/SV/RedisCache/Redis.php(301): Credis_Client->__call('set', Array)
#2 src/addons/SV/RedisCache/CacheProvider.php(87): SV\RedisCache\Redis->doSave('xfredis__data_d...', '\x00\x00\x00\x02\x14\x01\x06\x01\x14\x1E\x11\x07dri...', 3600)
#3 src/XF/DataRegistry.php(187): SV\RedisCache\CacheProvider->save('data_dbt_donate...', Array, 3600)
#4 src/XF/DataRegistry.php(156): XF\DataRegistry->setInCache('dbt_donate_driv...', Array)
#5 src/XF/DataRegistry.php(82): XF\DataRegistry->readFromDb(Array, Array)
#6 src/addons/DBTech/Donate/Application/AbstractCache.php(205): XF\DataRegistry->get(Array)
#7 src/addons/DBTech/Donate/Application/AbstractCache.php(150): DBTech\Donate\Application\AbstractCache->fetchFromDatastore()
#8 src/addons/DBTech/Donate/Application/EntityManager.php(109): DBTech\Donate\Application\AbstractCache->get('drive')
#9 src/addons/DBTech/Donate/XF/Widget/Drives.php(28): DBTech\Donate\Application\EntityManager->findCached('DBTech\\Donate:D...')
#10 src/XF/Template/Templater.php(1522): DBTech\Donate\XF\Widget\Drives->render()
#11 internal_data/code_cache/templates/l1/s21/public/forum_list.php(206): XF\Template\Templater->widgetPosition('forum_list_side...', Array)
#12 src/XF/Template/Templater.php(1246): XF\Template\Templater->{closure}(Object(ThemeHouse\Reactions\XF\Template\Templater), Array)
#13 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#14 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#15 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#16 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#17 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#18 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#19 src/XF.php(328): XF\App->run()
#20 index.php(13): XF::runApp('XF\\Pub\\App')
#21 {main}

Request state

array(4) {
  ["url"] => string(1) "/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
CredisException: READONLY You can't write against a read only slave. src/addons/SV/RedisCache/Credis/Client.php:1193

Generated by: rokon15 Feb 4, 2018 at 12:34 AM

Stack trace

#0 src/addons/SV/RedisCache/Redis.php(247): Credis_Client->__call('mget', Array)
#1 src/addons/SV/RedisCache/CacheProvider.php(60): SV\RedisCache\Redis->doFetchMultiple(Array)
#2 src/XF/DataRegistry.php(113): SV\RedisCache\CacheProvider->fetchMultiple(Array)
#3 src/XF/DataRegistry.php(81): XF\DataRegistry->readFromCache(Array, Array)
#4 src/addons/DBTech/Donate/Application/AbstractCache.php(205): XF\DataRegistry->get(Array)
#5 src/addons/DBTech/Donate/Application/AbstractCache.php(150): DBTech\Donate\Application\AbstractCache->fetchFromDatastore()
#6 src/addons/DBTech/Donate/Application/EntityManager.php(109): DBTech\Donate\Application\AbstractCache->get('drive')
#7 src/addons/DBTech/Donate/XF/Navigation.php(19): DBTech\Donate\Application\EntityManager->findCached('DBTech\\Donate:D...')
#8 src/addons/DBTech/Donate/XF/EventListener/NavigationSetup.php(10): DBTech\Donate\XF\Navigation::compile(Object(XF\Pub\App), Array, Array)
#9 [internal function]: DBTech\Donate\XF\EventListener\NavigationSetup::fire(Object(XF\Pub\App), Array, Array)
#10 src/XF/Extension.php(67): call_user_func_array(Array, Array)
#11 src/XF/App.php(2350): XF\Extension->fire('navigation_setu...', Array, NULL)
#12 src/XF/Pub/App.php(474): XF\App->fire('navigation_setu...', Array)
#13 src/XF/Pub/App.php(415): XF\Pub\App->getNavigation(Array, 'forums')
#14 src/XF/App.php(1724): XF\Pub\App->renderPageHtml('\n\n\n\n\n\n\n\n', Array, Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#15 src/XF/Mvc/Dispatcher.php(310): XF\App->renderPage('\n\n\n\n\n\n\n\n', Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#16 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#17 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#18 src/XF.php(328): XF\App->run()
#19 index.php(13): XF::runApp('XF\\Pub\\App')
#20 {main}

Request state

array(4) {
  ["url"] => string(1) "/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
You need to point the redis config at either a writable redis master or redis sentinel so it can find the writable master.
 
You likely do not need to setup a redis slave instance

OK I am not going enable redis slave instance. What the benefit with enable redis slave? I have one issue, deleted/move thread are not update instantly forum info.
 
OK I am not going enable redis slave instance. What the benefit with enable redis slave? I have one issue, deleted/move thread are not update instantly forum info.
Disable Thread Count caching, or lower the timeout:
redis-options-png.168106


You could raise the 'small forum threshold' so the shorter time hits more often, the alternative is to just not care since it is normally rare to move multiple pages of threads at once.
 
I'm 100% positive I've done something wrong, but when I change $config['cache']['provider'] = 'Redis'; to $config['cache']['provider'] = 'SV\RedisCache\Redis'; I get an error message that says my website isn't able to handle my request. I've made sure Redis is running and all. Any would be appreciated.

Thanks!
 
I'm 100% positive I've done something wrong, but when I change $config['cache']['provider'] = 'Redis'; to $config['cache']['provider'] = 'SV\RedisCache\Redis'; I get an error message that says my website isn't able to handle my request. I've made sure Redis is running and all. Any would be appreciated.

Thanks!

Make sure you have a config part like the following:
Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config']  = array(
        'server' => '127.0.0.1',
        'port' => 6379,
    );

And check the files are readable by XenForo.
 
Make sure you have a config part like the following:
Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config']  = array(
        'server' => '127.0.0.1',
        'port' => 6379,
    );

And check the files are readable by XenForo.

That got it working! Thank you very much.
 
  • Like
Reactions: Xon
Top Bottom