Camel.DataCache

g Camel.DataCache Camel.DataCache GObject.Object GObject.Object GObject.Object->Camel.DataCache

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class new (path)
  add (path, key)
  clear (path)
  foreach_remove (path, func, *user_data)
  get (path, key)
  get_expire_enabled ()
  get_filename (path, key)
  get_path ()
  remove (path, key)
  set_expire_access (when)
  set_expire_age (when)
  set_expire_enabled (expire_enabled)
  set_path (path)

Virtual Methods

Inherited:GObject.Object (7)

Properties

Name Type Flags Short Description
expire-enabled bool r/w/c/en  
path str r/w/c/en  

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)
Name Type Access Description
parent GObject.Object r  

Class Details

class Camel.DataCache(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:Camel.DataCacheClass
classmethod new(path)
Parameters:path (str) – Base path of cache, subdirectories will be created here.
Raises:GLib.Error
Returns:A new cache object, or None if the base path cannot be written to.
Return type:Camel.DataCache

Create a new data cache.

add(path, key)
Parameters:
  • path (str) – Relative path of item to add.
  • key (str) – Key of item to add.
Raises:

GLib.Error

Returns:

a Gio.IOStream for the new cache item, or None

Return type:

Gio.IOStream

Add a new item to the cache, returning a Gio.IOStream to the new item.

The key and the path combine to form a unique key used to store the item.

Potentially, expiry processing will be performed while this call is executing.

The returned Gio.IOStream is referenced for thread-safety and must be unreferenced with GObject.Object.unref() when finished with it.

clear(path)
Parameters:path (str) – Path to the (sub) cache the item exists in.

Clear cache’s content in path.

New in version 3.2.

foreach_remove(path, func, *user_data)
Parameters:
  • path (str) – Path to the (sub) cache the items exist in
  • func (Camel.DataCacheRemoveFunc) – a callback to call for each found file in the cache
  • user_data (object or None) – user data passed to func

Traverses the self sub-cache identified by path and calls func for each found file. If the func returns True, then the file is removed, if False, it’s kept in the cache.

New in version 3.26.

get(path, key)
Parameters:
  • path (str) – Path to the (sub) cache the item exists in.
  • key (str) – Key for the cache item.
Raises:

GLib.Error

Returns:

a Gio.IOStream for the requested cache item, or None

Return type:

Gio.IOStream

Lookup an item in the cache. If the item exists, a Gio.IOStream is returned for the item. The stream may be shared by multiple callers, so ensure the stream is in a valid state through external locking.

The returned Gio.IOStream is referenced for thread-safety and must be unreferenced with GObject.Object.unref() when finished with it.

get_expire_enabled()
Returns:Whether expire is enabled.
Return type:bool

Gets whether expire of cache data is enabled.

This is a complementary property for Camel.DataCache.set_expire_age() and Camel.DataCache.set_expire_access(), which allows to disable expiry without touching the two values. Having expire enabled, but not have set any of the two times, still behaves like not having expiry enabled.

New in version 3.24.

get_filename(path, key)
Parameters:
  • path (str) – Path to the (sub) cache the item exists in.
  • key (str) – Key for the cache item.
Returns:

The filename for a cache item

Return type:

str

Lookup the filename for an item in the cache

New in version 2.26.

get_path()
Returns:the path to the data cache
Return type:str

Returns the path to the data cache.

New in version 2.32.

remove(path, key)
Parameters:
  • path (str) – Path to the (sub) cache the item exists in.
  • key (str) – Key for the cache item.
Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Remove/expire a cache item.

set_expire_access(when)
Parameters:when (int) – Timeout for access, or -1 to disable access expiry.

Set the cache expiration policy for access times.

Items in the cache which haven’t been accessed for when seconds may be expired at any time. Items are expired in a lazy manner, so it is indeterminate when the items will physically be removed.

Note you can set both an age and an access limit. The age acts as a hard limit on cache entries.

set_expire_age(when)
Parameters:when (int) – Timeout for age expiry, or -1 to disable.

Set the cache expiration policy for aged entries.

Items in the cache older than when seconds may be flushed at any time. Items are expired in a lazy manner, so it is indeterminate when the items will physically be removed.

Note you can set both an age and an access limit. The age acts as a hard limit on cache entries.

set_expire_enabled(expire_enabled)
Parameters:expire_enabled (bool) – a value to set

Sets whether expire of cache data is enabled.

This is a complementary property for Camel.DataCache.set_expire_age() and Camel.DataCache.set_expire_access(), which allows to disable expiry without touching the two values. Having expire enabled, but not have set any of the two times, still behaves like not having expiry enabled.

New in version 3.24.

set_path(path)
Parameters:path (str) – path to the data cache

Sets the path to the data cache.

New in version 2.32.

Property Details

Camel.DataCache.props.expire_enabled
Name:expire-enabled
Type:bool
Default Value:True
Flags:READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY
Camel.DataCache.props.path
Name:path
Type:str
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY