| 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.
Example::
@cache('key', 5000, cache.ram)
def f():
return time.ctime()
When the function f is called, web2py tries to retrieve
the value corresponding to `key` from the cache of 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.
:param key: the key of the object to be store or retrieved
:param time_expire: expiration of the cache in microseconds
:param cache_model: "ram", "disk", or other
(like "memcache" if defined). It defaults to "ram".
Notes
-----
`time_expire` is used to compare the curret 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.
If the function `f` is an action, we suggest using
`request.env.path_info` as key.
|
Parameters
----------
request:
the global request object
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Dec 24 13:54:40 2012 | http://epydoc.sourceforge.net |