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)

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)

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

File-based cache for HTTP resources.

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.

clear()

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

This is not thread safe and must be called only from the thread that created the Soup.Cache

dump()

Synchronously writes the cache index out to disk.

Contrast with [method`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 Soup.Cache

flush()

Forces all pending writes in the self to be committed to disk.

For doing so it will iterate the [struct`GLib`.MainContext] associated with self's session as long as needed.

Contrast with [method`Cache`.dump], which writes out the cache index file.

get_max_size()
Returns:

the maximum size of the cache, in bytes.

Return type:

int

Gets the maximum size of the cache.

load()

Loads the contents of self's index into memory.

This is not thread safe and must be called only from the thread that created the Soup.Cache

set_max_size(max_size)
Parameters:

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

Sets the maximum size of the cache.

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.