Docs for cache
Description
<class 'gluon.cache.Cache'>
|
Attributes
| cache.__call__ |
<type 'instancemethod'>
belongs to class <type 'instancemethod'>
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: `cache.ram`, `cache.disk`, or other (like `cache.memcache` if defined). It defaults to `cache.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. |
| cache.__class__ |
<type 'type'> extends (<type 'object'>,)
belongs to class <type 'type'>
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 |
| cache.__delattr__ |
<type 'method-wrapper'>
belongs to class <type 'method-wrapper'>
x.__delattr__('name') <==> del x.name |
| cache.__dict__ |
<type 'dict'>
belongs to class <type 'dict'>
dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
| cache.__doc__ |
<type 'str'>
belongs to class <type 'str'>
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object. |
| cache.__getattribute__ |
<type 'method-wrapper'>
belongs to class <type 'method-wrapper'>
x.__getattribute__('name') <==> x.name |
| cache.__hash__ |
<type 'method-wrapper'>
belongs to class <type 'method-wrapper'>
x.__hash__() <==> hash(x) |
| cache.__init__ |
<type 'instancemethod'>
belongs to class <type 'instancemethod'>
Parameters ---------- request: the global request object |
| cache.__module__ |
<type 'str'>
belongs to class <type 'str'>
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object. |
| cache.__new__ |
<type 'builtin_function_or_method'>
belongs to class <type 'builtin_function_or_method'>
T.__new__(S, ...) -> a new object with type S, a subtype of T |
| cache.__reduce__ |
<type 'builtin_function_or_method'>
belongs to class <type 'builtin_function_or_method'>
helper for pickle |
| cache.__reduce_ex__ |
<type 'builtin_function_or_method'>
belongs to class <type 'builtin_function_or_method'>
helper for pickle |
| cache.__repr__ |
<type 'method-wrapper'>
belongs to class <type 'method-wrapper'>
x.__repr__() <==> repr(x) |
| cache.__setattr__ |
<type 'method-wrapper'>
belongs to class <type 'method-wrapper'>
x.__setattr__('name', value) <==> x.name = value |
| cache.__str__ |
<type 'method-wrapper'>
belongs to class <type 'method-wrapper'>
x.__str__() <==> str(x) |
| cache.__weakref__ |
<type 'NoneType'>
belongs to class <type 'NoneType'>
|
| cache.disk |
<class 'gluon.cache.CacheOnDisk'>
belongs to class <class 'gluon.cache.CacheOnDisk'>
Disk based cache This is implemented as a shelve object and it is shared by multiple web2py processes (and threads) as long as they share the same filesystem. The file is locked wen accessed. Disk cache provides persistance when web2py is started/stopped but it slower than `CacheInRam` Values stored in disk cache must be pickable. |
| cache.ram |
<class 'gluon.cache.CacheInRam'>
belongs to class <class 'gluon.cache.CacheInRam'>
Ram based caching This is implemented as global (per process, shared by all threads) dictionary. A mutex-lock mechanism avoid conflicts. |