Jump to content

Tutorial / Help On Cache Functions


Recommended Posts

I'm a bit confused about the best way to use the cache functions (Module and Tools classes)

Let say:

I have a simple module that displays the product on the day on the homepage

1. I make a query to the Database to retrieve the product

2. I return the result to a tempate product_of_the_day.tpl

 

I would like to understand how to cache the result and the template for the current day.

I have tried a strategy based on this :$this->_clearCache('product_of_the_day.tpl', $this->getCacheId(date('z'))); but it seems to never be cached.

 

Can someone explain me the proper strategy to control the caching system or point me to a google tutorial on the web?

Thanks

Link to comment
Share on other sites

I do have a lesson on cache in my modules course, but if you are only interested in that I guess it's a bit expensive. You need to set the cache with

return $this->display(__FILE__, 'leftColumn.tpl', $this->getCacheId('leftColumn'));

(leftColumn is just an example)

When you display a file, then you can check with isCached on the same method,

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...