elkarte / Elkarte

ElkArte Forum. A free, open source, modern discussion forum / BB
https://elkarte.github.io/Elkarte/
BSD 3-Clause "New" or "Revised" License
175 stars 61 forks source link

Cache Mechanism creates two cache objects #3712

Open tinoest opened 1 year ago

tinoest commented 1 year ago

When creating the cache instance it first creates a cache object in $this->_cache_obj it then creates a new instance when called statically.

#0  ElkArte\Cache\CacheMethod\Redis->addServers() called at [/var/www/html/sources/ElkArte/Cache/CacheMethod/Redis.php:45]
#1  ElkArte\Cache\CacheMethod\Redis->__construct(Array ([servers] => Array ([0] => 172.19.0.5:6379))) called at [/var/www/html/sources/ElkArte/Cache/Cache.php:118]
#2  ElkArte\Cache\Cache->_init() called at [/var/www/html/sources/ElkArte/Cache/Cache.php:101]
#3  ElkArte\Cache\Cache->enable(1) called at [/var/www/html/sources/ElkArte/Cache/Cache.php:76]
#4  ElkArte\Cache\Cache->__construct(1, redis, Array ([servers] => Array ([0] => 172.19.0.5:6379))) called at [/var/www/html/sources/ElkArte/Cache/Cache.php:174]
#5  ElkArte\Cache\Cache::instance() called at [/var/www/html/sources/Load.php:53]
#6  reloadSettings() called at [/var/www/html/bootstrap.php:311]
#7  Bootstrap->bringUp() called at [/var/www/html/bootstrap.php:93]
#8  Bootstrap->bringUpBasics() called at [/var/www/html/bootstrap.php:69]
#9  Bootstrap->__construct() called at [/var/www/html/index.php:26]
#0  ElkArte\Cache\CacheMethod\Redis->addServers() called at [/var/www/html/sources/ElkArte/Cache/CacheMethod/Redis.php:45]
#1  ElkArte\Cache\CacheMethod\Redis->__construct(Array ([servers] => Array ([0] => 172.19.0.5:6379))) called at [/var/www/html/sources/ElkArte/Cache/Cache.php:118]
#2  ElkArte\Cache\Cache->_init() called at [/var/www/html/sources/ElkArte/Cache/Cache.php:86]
#3  ElkArte\Cache\Cache->__construct(1, redis, Array ([servers] => Array ([0] => 172.19.0.5:6379))) called at [/var/www/html/sources/ElkArte/Cache/Cache.php:174]
#4  ElkArte\Cache\Cache::instance() called at [/var/www/html/sources/Load.php:53]
#5  reloadSettings() called at [/var/www/html/bootstrap.php:311]
#6  Bootstrap->bringUp() called at [/var/www/html/bootstrap.php:93]
#7  Bootstrap->bringUpBasics() called at [/var/www/html/bootstrap.php:69]
#8  Bootstrap->__construct() called at [/var/www/html/index.php:26]
Spuds commented 1 year ago

Thanks for the catch ... not sure what to do ATM, need some time to look into why that is occurring.

Spuds commented 3 months ago

Yeah its been a year ... I did find that a second object was created when you were in the admin panel cache settings. I've fixed that here: https://github.com/elkarte/Elkarte/commit/264974ef5984a1bf831793127c21e55abf113fc8 where it checks if a cache is enabled and if so grabs that object to checking (with a new getter in the base cache class)