EBackend.CacheKeys¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co/en |
|||
r/w/co/en |
|||
r/w/co/en |
|||
r/w/co/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
A signal emitted when the stored keys changed, aka when a new key is added or when an existing key is removed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class EBackend.CacheKeys(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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
) – anEBackend.Cache
table_name (
str
) – a table name to operate withkey_column_name (
str
) – column name for the keysvalue_column_name (
str
) – column name for the values
- Returns:
a new
EBackend.CacheKeys
- Return type:
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 theEBackend.CacheKeys
is freed. This is to avoid circular dependency between the cache and theEBackend.CacheKeys
, when theEBackend.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
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- out_n_stored:
return location to set count of stored keys
- Return type:
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:
func (
EBackend.CacheKeysForeachFunc
) – anEBackend.CacheKeysForeachFunc
, which is called for each stored keycancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
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:
- Return type:
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:
Gets a key column name, with which the self had been created.
New in version 3.48.
- get_ref_count_sync(key, cancellable)¶
- Parameters:
key (
str
) – a key to get reference count forcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- out_ref_count:
return location for the stored reference count for the key
- Return type:
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:
key (
str
) – a key to getcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- out_value:
return location for the stored value for the key
- Return type:
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:
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:
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
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
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 putvalue (
str
) – a value to put with the keyinc_ref_counts (
int
) – how many refs to add, or 0 to have it stored forevercancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
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
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
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/dereferencedec_ref_counts (
int
) – reference counts to drop, 0 to remove it regardless of the current reference countcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
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:
- 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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
The column name for the keys.
New in version 3.48.
- EBackend.CacheKeys.props.table_name¶
- Name:
table-name
- Type:
- Default Value:
- Flags:
The table name of this keys table.
New in version 3.48.
- EBackend.CacheKeys.props.value_column_name¶
- Name:
value-column-name
- Type:
- Default Value:
- Flags:
The column name for the values.
New in version 3.48.