EBackend.Cache¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class EBackend.Cache(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
Contains only private data that should be read and manipulated using the functions below.
New in version 3.26.
- classmethod sqlite_stmt_free(stmt)¶
- Parameters:
stmt (
str) – a statement to free
Frees a statement previously constructed with e_cache_sqlite_stmt_printf().
New in version 3.26.
- change_revision()¶
Instructs the self to change its revision. In case the revision change is frozen with
EBackend.Cache.freeze_revision_change() it notes to change the revision once the revision change is fully thaw.New in version 3.26.
- clear_offline_changes(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone- Raises:
- Returns:
Whether succeeded.
- Return type:
Marks all objects as being fully synchronized with the server and removes those which are marked as locally deleted.
New in version 3.26.
- contains(uid, deleted_flag)¶
- Parameters:
uid (
str) – a unique identifier of an objectdeleted_flag (
EBackend.CacheDeletedFlag) – one ofEBackend.CacheDeletedFlagenum
- Returns:
Whether the object had been found.
- Return type:
Checkes whether the self contains an object with the given uid.
New in version 3.26.
- copy_missing_to_column_values(column_names, column_values, other_columns)¶
- Parameters:
column_names ([
str]) – column namescolumn_values ([
str]) – column valuesother_columns (
EBackend.CacheColumnValues) – anEBackend.CacheColumnValuesto fill
- Returns:
an
EBackend.CacheColumnValuesto fill- Return type:
other_columns:
EBackend.CacheColumnValues
Adds every column value which is not
Camel.partof the other_columns to it, except ofEBackend.CACHE_COLUMN_UID,EBackend.CACHE_COLUMN_REVISION,EBackend.CACHE_COLUMN_OBJECTandEBackend.CACHE_COLUMN_STATEcolumns.This can be used within the callback of
EBackend.Cache.foreach_update().New in version 3.32.
- dup_key(key)¶
- Parameters:
key (
str) – a key name- Raises:
- Returns:
a value of the key. Free the returned string with
GLib.free(), when no longer needed.- Return type:
New in version 3.26.
- dup_revision()¶
- Returns:
A revision of the whole self. This is meant to be used by the descendants. Free the returned pointer with
GLib.free(), when no longer needed.- Return type:
New in version 3.26.
- erase()¶
Erases the cache and all of its content from the disk. The only valid operation after this is to free the self.
New in version 3.26.
- foreach(deleted_flag, where_clause, func, user_data, cancellable)¶
- Parameters:
deleted_flag (
EBackend.CacheDeletedFlag) – one ofEBackend.CacheDeletedFlagenumwhere_clause (
strorNone) – an optional SQLite WHERE clauseCamel.part, orNonefunc (
EBackend.CacheForeachFunc) – anEBackend.CacheForeachFuncfunction to call for each objectcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Calls func for each found object, which satisfies the criteria for both deleted_flag and where_clause.
Note the func should not call any SQLite commands, because it’s invoked within a SELECT statement execution.
New in version 3.26.
- foreach_update(deleted_flag, where_clause, func, user_data, cancellable)¶
- Parameters:
deleted_flag (
EBackend.CacheDeletedFlag) – one ofEBackend.CacheDeletedFlagenumwhere_clause (
strorNone) – an optional SQLite WHERE clauseCamel.part, orNonefunc (
EBackend.CacheUpdateFunc) – anEBackend.CacheUpdateFuncfunction to call for each objectcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Calls func for each found object, which satisfies the criteria for both deleted_flag and where_clause, letting the caller update values where necessary. The return value of func is used to determine whether the call was successful, not whether there are any changes to be saved. If anything fails during the call then the all changes are reverted.
When there are requested any changes by the func, this function also calls
EBackend.Cache.copy_missing_to_column_values() to ensure no descendant column data is lost.New in version 3.26.
- freeze_revision_change()¶
Freezes automatic revision change for the self. The function can be called multiple times, but each such call requires its pair function
EBackend.Cache.thaw_revision_change() call. See alsoEBackend.Cache.change_revision().New in version 3.26.
- get(uid, cancellable)¶
- Parameters:
uid (
str) – a unique identifier of an objectcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
An object with the given uid. Free it with
GLib.free(), when no longer needed. ReturnsNoneon error, like when the object could not be found.- out_revision:
an out variable for a revision of the object, or
Noneto ignore- out_other_columns:
an out variable for
EBackend.CacheColumnValuesother columns, as defined when creating the self, orNoneto ignore
- Return type:
(
strorNone, out_revision:strorNone, out_other_columns:EBackend.CacheColumnValuesorNone)
Returns an object with the given uid. This function does not consider locally deleted objects. The out_revision is set to the object revision, if not
None. Free it withGLib.free() when no longer needed. Similarly the out_other_columns contains a column name to column value strings for additional columns which had been requested when callingEBackend.Cache.initialize_sync(), if notNone. Free the returnedEBackend.CacheColumnValueswithEBackend.CacheColumnValues.free(), when no longer needed.New in version 3.26.
- get_count(deleted_flag, cancellable)¶
- Parameters:
deleted_flag (
EBackend.CacheDeletedFlag) – one ofEBackend.CacheDeletedFlagenumcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Count of objects stored in the self.
- Return type:
New in version 3.26.
- get_filename()¶
- Returns:
a filename of the self, with which it had been initialized.
- Return type:
New in version 3.26.
- get_key_int(key)¶
- Parameters:
key (
str) – a key name- Raises:
- Returns:
The user key value or -1 on error.
- Return type:
Reads the user key value as an integer.
New in version 3.26.
- get_object_include_deleted(uid, cancellable)¶
- Parameters:
uid (
str) – a unique identifier of an objectcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
An object with the given uid. Free it with
GLib.free(), when no longer needed. ReturnsNoneon error, like when the object could not be found.- out_revision:
an out variable for a revision of the object, or
Noneto ignore- out_other_columns:
an out variable for
EBackend.CacheColumnValuesother columns, as defined when creating the self, orNoneto ignore
- Return type:
(
strorNone, out_revision:strorNone, out_other_columns:EBackend.CacheColumnValuesorNone)
The same as
EBackend.Cache.get(), only considers also locally deleted objects.New in version 3.30.
- get_objects(deleted_flag, cancellable)¶
- Parameters:
deleted_flag (
EBackend.CacheDeletedFlag) – one ofEBackend.CacheDeletedFlagenumcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded. It doesn’t necessarily mean that there was any object stored in the self.
- out_objects:
a pointer to
GLib.SListto store the found objects to- out_revisions:
a pointer to
GLib.SListto store the found revisions to, orNone
- Return type:
Gets a list of objects stored in the self, optionally together with their revisions. The uids are not returned in any particular order, but the position between out_objects and out_revisions matches the same object.
Both out_objects and out_revisions contain newly allocated
GLib.SList, which should be freed with g_slist_free_full (slist,GLib.free); when no longer needed.New in version 3.26.
- get_offline_changes(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone- Raises:
- Returns:
A newly allocated list of all offline changes. Free it with g_slist_free_full (slist,
EBackend.CacheOfflineChange.free); when no longer needed.- Return type:
Gathers the list of all offline changes being done so far. The returned
GLib.SListcontainsEBackend.CacheOfflineChangestructure. UseEBackend.Cache.clear_offline_changes() to clear all offline changes at once.New in version 3.26.
- get_offline_state(uid, cancellable)¶
- Parameters:
uid (
str) – a unique identifier of an objectcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Current offline state
EBackend.OfflineStatefor the given object. It returnsEBackend.OfflineState.UNKNOWNwhen the object could not be found or other error happened.- Return type:
New in version 3.26.
- get_sqlitedb()¶
-
New in version 3.26.
- get_uids(deleted_flag, cancellable)¶
- Parameters:
deleted_flag (
EBackend.CacheDeletedFlag) – one ofEBackend.CacheDeletedFlagenumcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded. It doesn’t necessarily mean that there was any object stored in the self.
- out_uids:
a pointer to
GLib.SListto store the found uid to- out_revisions:
a pointer to
GLib.SListto store the found revisions to, orNone
- Return type:
Gets a list of unique object identifiers stored in the self, optionally together with their revisions. The uids are not returned in any particular order, but the position between out_uids and out_revisions matches the same object.
Both out_uids and out_revisions contain newly allocated
GLib.SList, which should be freed with g_slist_free_full (slist,GLib.free); when no longer needed.New in version 3.26.
- get_version()¶
- Returns:
A cache data version. This is meant to be used by the descendants.
- Return type:
New in version 3.26.
- initialize_sync(filename, other_columns, cancellable)¶
- Parameters:
filename (
str) – a filename of an SQLite database to useother_columns ([
EBackend.CacheColumnInfo] orNone) – an optionalGLib.SListwith additional columns to add to the objects tablecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Initializes the self and opens the filename database. This should be called by the descendant.
The other_columns are added to the objects table (
EBackend.CACHE_TABLE_OBJECTS). Values for these columns are returned byEBackend.Cache.get() and can be stored withEBackend.Cache.put().New in version 3.26.
- is_revision_change_frozen()¶
- Returns:
Whether automatic revision change for the self is currently frozen.
- Return type:
New in version 3.26.
- lock(lock_type)¶
- Parameters:
lock_type (
EBackend.CacheLockType) – anEBackend.CacheLockType
Locks the self thus other threads cannot use it. This can be called recursively within one thread. Each call should have its pair
EBackend.Cache.unlock().New in version 3.26.
- put(uid, revision, object, other_columns, offline_flag, cancellable)¶
- Parameters:
uid (
str) – a unique identifier of an objectobject (
str) – the object itselfother_columns (
EBackend.CacheColumnValuesorNone) – anEBackend.CacheColumnValueswith other columns to set; can beNoneoffline_flag (
EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether putting this object in offlinecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Stores an object into the cache. Depending on offline_flag, this update the object’s offline state accordingly. When the offline_flag is set to
EBackend.CacheOfflineFlag.IS_ONLINE, then it’s set toEBackend.OfflineState.SYNCED, like to be fully synchronized with the server, regardless of its previous offline state. Overwriting locally deleted object behaves like an addition of a completely new object.New in version 3.26.
- remove(uid, offline_flag, cancellable)¶
- Parameters:
uid (
str) – a unique identifier of an objectoffline_flag (
EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether removing the object in offlinecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Removes the object with the given uid from the self. Based on the offline_flag, it can remove also any information about locally made offline changes. Removing the object with
EBackend.CacheOfflineFlag.IS_OFFLINEwill still remember it for later use withEBackend.Cache.get_offline_changes().New in version 3.26.
- remove_all(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone- Raises:
- Returns:
Whether succeeded.
- Return type:
Removes all objects from the self in one call.
New in version 3.26.
- set_key(key, value)¶
- Parameters:
- Raises:
- Returns:
Whether succeeded.
- Return type:
Sets a value of the user key, or deletes it, if the value is
None.New in version 3.26.
- set_key_int(key, value)¶
- Parameters:
- Raises:
- Returns:
Whether succeeded.
- Return type:
Sets an integer value for the user key.
New in version 3.26.
- set_offline_state(uid, state, cancellable)¶
- Parameters:
uid (
str) – a unique identifier of an objectstate (
EBackend.OfflineState) – anEBackend.OfflineStateto setcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Sets an offline state for the object identified by uid.
New in version 3.26.
- set_revision(revision)¶
-
Sets the revision of the whole self. This is not meant to be used by the descendants, because the revision is updated automatically when needed. The descendants can listen to “revision-changed” signal.
New in version 3.26.
- set_version(version)¶
- Parameters:
version (
int) – a cache data version to set
Sets a cache data version. This is meant to be used by the descendants. The version should be greater than zero.
New in version 3.26.
- sqlite_exec(sql_stmt, cancellable)¶
- Parameters:
sql_stmt (
str) – an SQLite statement to executecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Executes an SQLite statement. Use
EBackend.Cache.sqlite_select() for SELECT statements.New in version 3.26.
- sqlite_maybe_vacuum(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone- Raises:
- Returns:
Whether succeeded. It doesn’t mean that the vacuum had been run, only that no error happened during the call.
- Return type:
Runs vacuum (compacts the database file), if needed.
New in version 3.26.
- sqlite_select(sql_stmt, func, user_data, cancellable)¶
- Parameters:
sql_stmt (
str) – an SQLite SELECT statement to executefunc (
EBackend.CacheSelectFunc) – anEBackend.CacheSelectFuncfunction to call for each rowcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Executes a SELECT statement sql_stmt and calls func for each row of the result. Use
EBackend.Cache.sqlite_exec() for statements which do not return row sets.New in version 3.26.
- thaw_revision_change()¶
Thaws automatic revision change for the self. It’s the pair function of
EBackend.Cache.freeze_revision_change().New in version 3.26.
- unlock(action)¶
- Parameters:
action (
EBackend.CacheUnlockAction) – anEBackend.CacheUnlockAction
Unlocks the cache which was previouly locked with
EBackend.Cache.lock(). The cache locked withEBackend.CacheLockType.WRITEshould use either actionEBackend.CacheUnlockAction.COMMITorEBackend.CacheUnlockAction.ROLLBACK, while theEBackend.CacheLockType.READshould useEBackend.CacheUnlockAction.NONEaction.New in version 3.26.
- do_before_put(uid, revision, object, other_columns, is_replace, cancellable) virtual¶
- Parameters:
uid (
str) –revision (
str) –object (
str) –other_columns (
EBackend.CacheColumnValues) –is_replace (
bool) –cancellable (
Gio.CancellableorNone) –
- Return type:
- do_before_remove(uid, cancellable) virtual¶
- Parameters:
uid (
str) –cancellable (
Gio.CancellableorNone) –
- Return type:
- do_clear_offline_changes_locked(cancellable) virtual¶
- Parameters:
cancellable (
Gio.CancellableorNone) –- Return type:
- do_erase() virtual¶
Erases the cache and all of its content from the disk. The only valid operation after this is to free the cache.
New in version 3.26.
- do_put_locked(uid, revision, object, other_columns, offline_state, is_replace, cancellable) virtual¶
- Parameters:
uid (
str) –revision (
str) –object (
str) –other_columns (
EBackend.CacheColumnValues) –offline_state (
EBackend.OfflineState) –is_replace (
bool) –cancellable (
Gio.CancellableorNone) –
- Return type:
- do_remove_locked(uid, cancellable) virtual¶
- Parameters:
uid (
str) –cancellable (
Gio.CancellableorNone) –
- Return type:
- do_revision_changed() virtual¶
Signal Details¶
- EBackend.Cache.signals.before_put(cache, object, p0, p1, p2, p3, p4, p5)¶
- Signal Name:
before-put- Flags:
- Parameters:
cache (
EBackend.Cache) – The object which received the signalobject (
str) –p0 (
str) –p1 (
str) –p2 (
EBackend.CacheColumnValues) –p3 (
bool) –p4 (
Gio.CancellableorNone) –
- Return type:
- EBackend.Cache.signals.before_remove(cache, object, p0, p1)¶
- Signal Name:
before-remove- Flags:
- Parameters:
cache (
EBackend.Cache) – The object which received the signalobject (
str) –p0 (
Gio.CancellableorNone) –
- Return type:
- EBackend.Cache.signals.revision_changed(cache)¶
- Signal Name:
revision-changed- Flags:
- Parameters:
cache (
EBackend.Cache) – The object which received the signal