web2py.gluon.cache.CacheOnDisk

Package web2py :: Package gluon :: Module cache :: Class CacheOnDisk |
[hide private]
[frames] | no frames]

# Class CacheOnDisk

source code

       object --+
                |
    CacheAbstract --+
                    |
                   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.

Instance Methods | [hide private]
__call__(self, key, f, time_expire=300) Tries retrieve the value corresponding to `key` from the cache of the object exists and if it did not expire, else it called the function `f` and stores the output in the cache corresponding to `key`. | source code
__init__(self, request, folder=global_settings.applications_parent) Paremeters... | source code
clear(self, regex=global_settings.applications_parent) Clears the cache of all keys that match the provided regular expression. | source code
increment(self, key, value=global_settings.applications_parent) Increments the cached value for the given key by the amount in value... | source code
Inherited from `CacheAbstract` (private): `_clear` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables | [hide private]
| speedup_checks = ``set([``])``
Inherited from `CacheAbstract`: `cache_stats_name`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __call__(self, key, f, time_expire=300) (Call operator) | source code
    Tries retrieve the value corresponding to `key` from the cache of the
    object exists and if it did not expire, else it called 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 f: the function, whose output is to be cached
    :param time_expire: expiration of the cache in microseconds

    - `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.

    If the function `f` is `None` the cache is cleared.
Overrides: CacheAbstract.__call__ (inherited documentation)

### __init__(self, request, folder=global_settings.applications_parent) (Constructor) | source code
    Paremeters
    ----------
    request:
        the global request object
Overrides: CacheAbstract.__init__ (inherited documentation)

### clear(self, regex=global_settings.applications_parent) | source code
    Clears the cache of all keys that match the provided regular expression.
    If no regular expression is provided, it clears all entries in cache.

    Parameters
    ----------
    regex:
        if provided, only keys matching the regex will be cleared.
        Otherwise all keys are cleared.
Overrides: CacheAbstract.clear (inherited documentation)

### increment(self, key, value=global_settings.applications_parent) | source code
    Increments the cached value for the given key by the amount in value

    Parameters
    ----------
    key:
        key for the cached object to be incremeneted
    value:
        amount of the increment (defaults to 1, can be negative)
Overrides: CacheAbstract.increment (inherited documentation)