lightspeedretail / webstore

Web Store eCommerce solution for Lightspeed
http://www.lightspeedpos.com/webstore
Open Software License 3.0
85 stars 63 forks source link

Product Model should Cache SQL Queries #573

Closed Dragony closed 9 years ago

Dragony commented 10 years ago

Hello!

I recently started working with your webshop and I noticed that none of the methods on the Product Model are cached. At the moment I'm working directly with the model in my theme and I encountered the problem that every time I access a property, that requires a db query, it queries the database again. Sure I could just do this myself in the controller, but this would be an awesome feature to have out of the box.

Example for clarification:

public function getSomething(){
    if(isset($this->cache['something'])){
        return $this->cache['something'];
    }

    // function code

    $this->cache['something'] = $result;
    return $result;
}

To be 100% backwards compatible you could tie the cache to a flag of some sort. If you would like a pull request, I can provide :).

Best Regards Mattias

gabeguz commented 9 years ago

Hi @Dragony -- While I agree that we should be cacheing results of SQL queries, this doesn't seem like something we will be adding to Web Store any time soon. I'm going to close this issue.