ormcache

This one is the simplest and most-used cache decorators. You need to pass the parameter name on which the method's output depends. The following is an example method with the ormcache decorator:

@tools.ormcache('mode')
def fetch_mode_data(self, mode):
# some calculations
return result

When you call this method for the first time, it will be executed and the result will be returned. ormcache will store this result based on the value of the mode parameter. When you call the method again with the same mode value, the result will be served from the cache without executing the actual method.

Sometimes, your method's result depends on the environment attributes. In these cases, you can declare the method as follows:

@tools.ormcache('self.env.uid', 'mode')
def fetch_data(self, mode):
# some calculations
return result

The method given in this example will store the cache based on the environment user and the value of the mode parameter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset