You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a difference though: getInstance() caches the category service instance. When you query Categories::getInstance($extension, $options)::get() twice for the same category, you'll get the same CategoryNode, without querying the database twice.
Joomla\CMS\Categories\CategoryServiceTrait::getCategory() creates a new categories service on each call and by that you'll not benefit from the nodes cache.
Proposed solution
Is it possible to add an instance cache to the Joomla\CMS\Categories\CategoryServiceTrait?
Open questions
The text was updated successfully, but these errors were encountered:
Problem identified
Joomla\CMS\Categories\Categories::getInstance()
has been deprecated with 4.0 and will be removed with 6.0.The suggested alternative is to use the ComponentInterface.
Factory::getApplication()->bootComponent($component)->getCategory($options, $section);
There is a difference though:
getInstance()
caches the category service instance. When you queryCategories::getInstance($extension, $options)::get()
twice for the same category, you'll get the same CategoryNode, without querying the database twice.Joomla\CMS\Categories\CategoryServiceTrait::getCategory()
creates a new categories service on each call and by that you'll not benefit from the nodes cache.Proposed solution
Is it possible to add an instance cache to the
Joomla\CMS\Categories\CategoryServiceTrait
?Open questions
The text was updated successfully, but these errors were encountered: