Home | Trees | Indices | Help |
|
---|
|
object --+ | Cache
Sets up generic caching, creating an instance of both CacheInRam and CacheOnDisk. In case of GAE will make use of gluon.contrib.gae_memcache. - self.ram is an instance of CacheInRam - self.disk is an instance of CacheOnDisk
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
|
|
|||
autokey =
|
|
|||
Inherited from |
|
Decorator function that can be used to cache any function/method. Args: key(str) : the key of the object to be store or retrieved time_expire(int) : expiration of the cache in seconds `time_expire` is used to compare the current time with the time when the requested object was last saved in cache. It does not affect future requests. Setting `time_expire` to 0 or negative value forces the cache to refresh. cache_model(str): can be "ram", "disk" or other (like "memcache"). Defaults to "ram" When the function `f` is called, web2py tries to retrieve the value corresponding to `key` from the cache if the object exists and if it did not expire, else it calles the function `f` and stores the output in the cache corresponding to `key`. In the case the output of the function is returned. Example: :: @cache('key', 5000, cache.ram) def f(): return time.ctime() Note: If the function `f` is an action, we suggest using @cache.action instead |
Args: request: the global request object
|
Better fit for caching an action Warning: Experimental! Currently only HTTP 1.1 compliant reference : http://code.google.com/p/doctype-mirror/wiki/ArticleHttpCaching Args: time_expire(int): same as @cache cache_model(str): same as @cache prefix(str): add a prefix to the calculated key session(bool): adds response.session_id to the key vars(bool): adds request.env.query_string lang(bool): adds T.accepted_language user_agent(bool or dict): if True, adds is_mobile and is_tablet to the key. Pass a dict to use all the needed values (uses str(.items())) (e.g. user_agent=request.user_agent()). Used only if session is not True public(bool): if False forces the Cache-Control to be 'private' valid_statuses: by default only status codes starting with 1,2,3 will be cached. pass an explicit list of statuses on which turn the cache on quick: Session,Vars,Lang,User-agent,Public: fast overrides with initials, e.g. 'SVLP' or 'VLP', or 'VLP' |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 16 02:36:11 2014 | http://epydoc.sourceforge.net |