:right-sidebar: True Cache =================================================================== .. currentmodule:: gi.repository.Soup .. class:: Cache(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Soup.SessionFeature` :Constructors: :: Cache(**properties) new(cache_dir:str=None, cache_type:Soup.CacheType) -> Soup.Cache Constructors ------------ .. rst-class:: interim-class .. class:: Cache :no-index: .. classmethod:: new(cache_dir: str | None, cache_type: ~gi.repository.Soup.CacheType) -> ~gi.repository.Soup.Cache Creates a new :obj:`~gi.repository.Soup.Cache`. :param cache_dir: the directory to store the cached data, or :const:`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 passing :const:`None`. :param cache_type: the :obj:`~gi.repository.Soup.CacheType` of the cache Methods ------- .. rst-class:: interim-class .. class:: Cache :no-index: .. method:: 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 :obj:`~gi.repository.Soup.Cache` .. method:: dump() -> None Synchronously writes the cache index out to disk. Contrast with :obj:`~gi.repository.Cache.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 :obj:`~gi.repository.Soup.Cache` .. method:: flush() -> None Forces all pending writes in the ``cache`` to be committed to disk. For doing so it will iterate the :obj:`~gi.repository.GLib.MainContext` associated with ``cache``'s session as long as needed. Contrast with :obj:`~gi.repository.Cache.dump`, which writes out the cache index file. .. method:: get_max_size() -> int Gets the maximum size of the cache. .. method:: load() -> None Loads the contents of ``cache``'s index into memory. This is not thread safe and must be called only from the thread that created the :obj:`~gi.repository.Soup.Cache` .. method:: set_max_size(max_size: int) -> None Sets the maximum size of the cache. :param max_size: the maximum size of the cache, in bytes Properties ---------- .. rst-class:: interim-class .. class:: Cache :no-index: .. attribute:: props.cache_dir :type: str The directory to store the cache files. .. attribute:: props.cache_type :type: ~gi.repository.Soup.CacheType Whether the cache is private or shared. Virtual Methods --------------- .. rst-class:: interim-class .. class:: Cache :no-index: .. method:: do_get_cacheability(msg: ~gi.repository.Soup.Message) -> ~gi.repository.Soup.Cacheability :param msg: Fields ------ .. rst-class:: interim-class .. class:: Cache :no-index: .. attribute:: parent_instance