EBackend.CacheKeys

g EBackend.CacheKeys EBackend.CacheKeys GObject.Object GObject.Object GObject.Object->EBackend.CacheKeys

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (cache, table_name, key_column_name, value_column_name)

count_keys_sync (cancellable)

foreach_sync (func, user_data, cancellable)

get_cache ()

get_key_column_name ()

get_ref_count_sync (key, cancellable)

get_sync (key, cancellable)

get_table_name ()

get_value_column_name ()

init_table_sync (cancellable)

put_sync (key, value, inc_ref_counts, cancellable)

remove_all_sync (cancellable)

remove_sync (key, dec_ref_counts, cancellable)

Virtual Methods

Inherited:

GObject.Object (7)

do_changed ()

Properties

Name

Type

Flags

Short Description

cache

EBackend.Cache

r/w/co/en

key-column-name

str

r/w/co/en

table-name

str

r/w/co/en

value-column-name

str

r/w/co/en

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

A signal emitted when the stored keys changed, aka when a new key is added or when an existing key is removed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class EBackend.CacheKeys(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

EBackend.CacheKeysClass

Contains only private data that should be read and manipulated using the functions below.

New in version 3.48.

classmethod new(cache, table_name, key_column_name, value_column_name)
Parameters:
  • cache (EBackend.Cache) – an EBackend.Cache

  • table_name (str) – a table name to operate with

  • key_column_name (str) – column name for the keys

  • value_column_name (str) – column name for the values

Returns:

a new EBackend.CacheKeys

Return type:

EBackend.CacheKeys

Creates a new EBackend.CacheKeys, which will operate with table_name, using column key_column_name to store keys and value_column_name to store values.

The created EBackend.CacheKeys doesn’t hold a reference to the cache, the caller is supposed to make sure the cache won’t be freed before the EBackend.CacheKeys is freed. This is to avoid circular dependency between the cache and the EBackend.CacheKeys, when the EBackend.CacheKey is created by the cache itself (which is the expected use case).

New in version 3.48.

count_keys_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Raises:

GLib.Error

Returns:

Whether succeeded.

out_n_stored:

return location to set count of stored keys

Return type:

(bool, out_n_stored: int)

Counts how many keys the self stores and set it to the out_n_stored.

New in version 3.48.

foreach_sync(func, user_data, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

Whether succeeded.

Return type:

bool

Calls func for each stored key in the self, providing information about its value and reference count.

New in version 3.48.

get_cache()
Returns:

an EBackend.Cache

Return type:

EBackend.Cache

Gets an EBackend.Cache, with which the self had been created.

New in version 3.48.

get_key_column_name()
Returns:

a key column name

Return type:

str

Gets a key column name, with which the self had been created.

New in version 3.48.

get_ref_count_sync(key, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

Whether succeeded.

out_ref_count:

return location for the stored reference count for the key

Return type:

(bool, out_ref_count: int)

Gets currently stored reference count for the key. Note the reference count can be 0, which means the key is stored forever.

New in version 3.48.

get_sync(key, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

Whether succeeded.

out_value:

return location for the stored value for the key

Return type:

(bool, out_value: str)

Gets a stored value with given key, which had been previously put into the self with EBackend.CacheKeys.put_sync().

The returned string should be freed with GLib.free() when no longer needed.

New in version 3.48.

get_table_name()
Returns:

a table name

Return type:

str

Gets a table name, with which the self had been created.

New in version 3.48.

get_value_column_name()
Returns:

a value column name

Return type:

str

Get a value column name, with which the self had been created.

New in version 3.48.

init_table_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Raises:

GLib.Error

Returns:

Whether succeeded.

Return type:

bool

Initializes table in the corresponding EBackend.Cache.

New in version 3.48.

put_sync(key, value, inc_ref_counts, cancellable)
Parameters:
  • key (str) – a key identifier to put

  • value (str) – a value to put with the key

  • inc_ref_counts (int) – how many refs to add, or 0 to have it stored forever

  • cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Raises:

GLib.Error

Returns:

Whether succeeded.

Return type:

bool

Puts the key and value into the self. The function adds a new or replaces an existing key, if any such already exists in the self.

New in version 3.48.

remove_all_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Raises:

GLib.Error

Returns:

Whether succeeded.

Return type:

bool

Removes all stored keys from the self.

New in version 3.48.

remove_sync(key, dec_ref_counts, cancellable)
Parameters:
  • key (str) – a key to remove/dereference

  • dec_ref_counts (int) – reference counts to drop, 0 to remove it regardless of the current reference count

  • cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Raises:

GLib.Error

Returns:

Whether succeeded.

Return type:

bool

Dereferences use count of the key by dec_ref_counts and removes it from the cache when the reference count reaches zero. Special case is with dec_ref_counts is zero, in which case the key is removed regardless of the current reference count.

It’s not an error when the key doesn’t exist in the cache.

New in version 3.48.

do_changed() virtual

Signal Details

EBackend.CacheKeys.signals.changed(cache_keys)
Signal Name:

changed

Flags:

RUN_LAST

Parameters:

cache_keys (EBackend.CacheKeys) – The object which received the signal

A signal emitted when the stored keys changed, aka when a new key is added or when an existing key is removed. It’s not emitted when only a reference count changes for a key.

New in version 3.48.

Property Details

EBackend.CacheKeys.props.cache
Name:

cache

Type:

EBackend.Cache

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The EBackend.Cache being used for this keys table.

New in version 3.48.

EBackend.CacheKeys.props.key_column_name
Name:

key-column-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The column name for the keys.

New in version 3.48.

EBackend.CacheKeys.props.table_name
Name:

table-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The table name of this keys table.

New in version 3.48.

EBackend.CacheKeys.props.value_column_name
Name:

value-column-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The column name for the values.

New in version 3.48.