Cache#
Superclasses: Object
Implemented Interfaces: SessionFeature
File-based cache for HTTP resources.
Constructors#
- class Cache
- classmethod new(cache_dir: str | None, cache_type: CacheType) Cache #
Creates a new
Cache
.- Parameters:
cache_dir – the directory to store the cached data, or
None
to use the default one. Note that since the cache isn’t safe to access for multiple processes at once, and the default directory isn’t namespaced by process, clients are strongly discouraged from passingNone
.cache_type – the
CacheType
of the cache
Methods#
- class Cache
- clear() None #
Will remove all entries in the
cache
plus all the cache files.This is not thread safe and must be called only from the thread that created the
Cache
- do_get_cacheability(self, msg: Message) Cacheability #
- Parameters:
msg
- dump() None #
Synchronously writes the cache index out to disk.
Contrast with
flush
, which writes pending cache entries to disk.You must call this before exiting if you want your cache data to persist between sessions.
This is not thread safe and must be called only from the thread that created the
Cache
- flush() None #
Forces all pending writes in the
cache
to be committed to disk.For doing so it will iterate the
MainContext
associated withcache
's session as long as needed.Contrast with
dump
, which writes out the cache index file.
Properties#
Virtual Methods#
- class Cache
- do_get_cacheability(msg: Message) Cacheability #
The type of the None singleton.
- Parameters:
msg
Fields#
- class Cache
- parent_instance#