Soup.Cache

g GObject.GInterface GObject.GInterface Soup.SessionFeature Soup.SessionFeature GObject.GInterface->Soup.SessionFeature GObject.Object GObject.Object Soup.Cache Soup.Cache GObject.Object->Soup.Cache Soup.SessionFeature->Soup.Cache

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Soup.SessionFeature (5)

Structs:

GObject.ObjectClass (5)

class

new (cache_dir, cache_type)

clear ()

dump ()

flush ()

get_max_size ()

load ()

set_max_size (max_size)

Virtual Methods

Inherited:

GObject.Object (7), Soup.SessionFeature (8)

do_get_cacheability (msg)

Properties

Name

Type

Flags

Short Description

cache-dir

str

r/w/co

The directory to store the cache files

cache-type

Soup.CacheType

r/w/co

Whether the cache is private or shared

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Soup.Cache(**kwargs)
Bases:

GObject.Object, Soup.SessionFeature

Abstract:

No

Structure:

Soup.CacheClass

classmethod new(cache_dir, cache_type)
Parameters:
  • cache_dir (str or None) – 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 passing None.

  • cache_type (Soup.CacheType) – the Soup.CacheType of the cache

Returns:

a new Soup.Cache

Return type:

Soup.Cache

Creates a new Soup.Cache.

New in version 2.34.

clear()

Will remove all entries in the self plus all the cache files.

New in version 2.34.

dump()

Synchronously writes the cache index out to disk. Contrast with Soup.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.

New in version 2.34..

flush()

This function will force all pending writes in the self to be committed to disk. For doing so it will iterate the GLib.MainContext associated with self's session as long as needed.

Contrast with Soup.Cache.dump(), which writes out the cache index file.

New in version 2.34.

get_max_size()
Returns:

the maximum size of the cache, in bytes.

Return type:

int

Gets the maximum size of the cache.

New in version 2.34.

load()

Loads the contents of self's index into memory.

New in version 2.34.

set_max_size(max_size)
Parameters:

max_size (int) – the maximum size of the cache, in bytes

Sets the maximum size of the cache.

New in version 2.34.

do_get_cacheability(msg) virtual
Parameters:

msg (Soup.Message) –

Return type:

Soup.Cacheability

Property Details

Soup.Cache.props.cache_dir
Name:

cache-dir

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The directory to store the cache files

Soup.Cache.props.cache_type
Name:

cache-type

Type:

Soup.CacheType

Default Value:

Soup.CacheType.SINGLE_USER

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether the cache is private or shared