Decorator to wrap this cache around a function. In order for this to function correctly, you must provide
Flushes the cache. Its possible the flush only a part of the cache by specifying
- core.cache.enableCache(urls, userSensitive=0, languageSensitive=False, evaluatedArgs=None, maxCacheTime=None)¶
Decorator to wrap this cache around a function. In order for this to function correctly, you must provide additional information so ViUR can determine in which situations it’s possible to re-use an already cached result and when to call the wrapped function instead.
- ..Warning: It’s not possible to cache the result of a function relying on reading/modifying
the environment (ie. setting custom http-headers). The only exception is the content-type header which will be stored along with the cached response.
urls (List[str]) – A list of urls for this function, for which the cache should be enabled. A function can have several urls (eg. /page/view or /pdf/page/view), and it might should not be cached under all urls (eg. /admin/page/view).
userSensitive (int) – Signals wherever the output of f depends on the current user. 0 means independent of wherever the user is a guest or known, all will get the same content. 1 means cache only for guests, no cache will be performed if the user is logged-in. 2 means cache in two groups, one for guests and one for all users 3 will cache the result of that function for each individual users separately.
languageSensitive (bool) – If true, signals that the output of f might got translated. If true, the result of that function is cached separately for each language.
evaluatedArgs (Union[List[str], None]) – List of keyword-arguments having influence to the output generated by that function. This list must be complete! Parameters not named here are ignored! Warning: Double-check this list! F.e. if that function generates a list of entries and you miss the parameter “order” here, it would be impossible to sort the list. It would always have the ordering it had when the cache-entry was created.
maxCacheTime (Union[int, None]) – Specifies the maximum time an entry stays in the cache in seconds. Note: Its not erased from the db after that time, but it won’t be served anymore. If None, the cache stays valid forever (until manually erased by calling flushCache.
- core.cache.flushCache(prefix=None, key=None, kind=None)¶
Flushes the cache. Its possible the flush only a part of the cache by specifying the path-prefix. The path is equal to the url that caused it to be cached (eg /page/view) and must be one listed in the ‘url’ param of
prefix (str) – Path or prefix that should be flushed.
key (Union[viur.core.db.Key, None]) – Flush all cache entries which may contain this key. Also flushes entries which executed a query over that kind.
kind (Union[str, None]) – Flush all cache entries which executed a query over that kind.
“/” would flush the main page (and only that),
“/” everything from the cache, “/page/” everything from the page-module (default render),
and “/page/view/*” only that specific subset of the page-module.