I've built a custom component, and I'm trying to make it a bit faster, and while I was rooting through model core files I saw that their getItems()
uses a caching to reduce DB queries:
$store = $this->getStoreId();
if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
try
{
// Load the list items and add the items to the internal cache.
$this->cache[$store] = $this->_getList($this->_getListQuery(), $this->getStart(), $this->getState('list.limit'));
}
So I'm attempting to duplicate this for my component. Code is practically the same, but whenever I check isset($this->cache[$store])
it is always unset. I'm unsure if I'm having a problem fetching $this->cache[$store]
or saving to it.