ObjectCache
Object Hierarchy:
Description:
public abstract class ObjectCache<
T> :
Object
A generic abstract cache for sets of objects. This can be used by subclasses to implement caching of homogeneous sets of objects.
Subclasses simply have to implement serialisation and deserialisation of the objects to and from GLib.Variant
s.
It's intended that this class be used for providing caching layers for
PersonaStores, for example.
Since:
0.6.0
Namespace: Folks
Package: folks
Content:
Properties:
Creation methods:
Methods:
- protected abstract
VariantType
? get_serialised_object_type (uint8
object_version)
Get the GLib.VariantType
of the serialised form of an
object stored in this cache.
- protected abstract
uint8
get_serialised_object_version ()
Get the version of the variant type returned by
ObjectCache.get_serialised_object_type. This
must be incremented every time the variant type changes so that old cache files aren't misinterpreted.
- protected abstract
Variant
serialise_object (T object)
- protected abstract T deserialise_object (
Variant
variant, uint8
object_version)
- public async
Set
<T>? load_objects (Cancellable
? cancellable = null)
Load a set of objects from the cache and return them as a new set. If
the cache file doesn't exist, `null` will be returned. An empty set will be returned if the cache file existed but was empty (i.e. was
stored with an empty set originally).
- public async void store_objects (
Set
<T> objects, Cancellable
? cancellable = null)
Store a set of objects to the cache file, overwriting any existing set
of objects in the cache, or creating the cache file from scratch if it didn't previously exist.
- public async void clear_cache ()
Clear this cache object, deleting its backing file.