FolksObjectCache 3 FOLKS Library
FolksObjectCache 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 GVariants.

## Functions

void | folks_object_cache_load_objects ()
GeeSet * | folks_object_cache_load_objects_finish ()
void | folks_object_cache_store_objects ()
void | folks_object_cache_store_objects_finish ()
void | folks_object_cache_clear_cache ()
void | folks_object_cache_clear_cache_finish ()
const gchar * | folks_object_cache_get_type_id ()
const gchar * | folks_object_cache_get_id ()

## Types and Values

#define | FOLKS_TYPE_OBJECT_CACHE
struct | FolksObjectCache
struct | FolksObjectCacheClass

## Description

It's intended that this class be used for providing caching layers for FolksPersonaStores, for example.

## Functions

### folks_object_cache_load_objects ()

    void
    folks_object_cache_load_objects (FolksObjectCache *self,
                                     GCancellable *cancellable,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);

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).

Loading the objects can be cancelled using `cancellable`. If it is, `null` will be returned.

If any errors are encountered while loading the objects, warnings will be logged as appropriate and `null` will be returned.

This method is safe to call multiple times concurrently.

See also: ``folks_object_cache_load_objects_finish()``

#### Parameters

self | the FolksObjectCache instance |
cancellable | . A GCancellable for the operation, or `null`. . | [in][allow-none]
_callback_ | callback to call when the request is satisfied. | [scope async]
_user_data_ | the data to pass to _callback_ function. | [closure]

Since: 0.6.0

folks_object_cache_load_objects

### folks_object_cache_load_objects_finish ()

    GeeSet *
    folks_object_cache_load_objects_finish
                                   (FolksObjectCache *self,
                                    GAsyncResult *_res_);

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).

Loading the objects can be cancelled using `cancellable`. If it is, `null` will be returned.

If any errors are encountered while loading the objects, warnings will be logged as appropriate and `null` will be returned.

This method is safe to call multiple times concurrently.

See also: ``folks_object_cache_load_objects()``

#### Parameters

self | the FolksObjectCache instance |
_res_ | a GAsyncResult |

#### Returns

A set of objects from the cache, or `null`.

Since: 0.6.0

folks_object_cache_load_objects_finish

### folks_object_cache_store_objects ()

    void
    folks_object_cache_store_objects (FolksObjectCache *self,
                                      GeeSet *objects,
                                      GCancellable *cancellable,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);

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.

Storing the objects can be cancelled using `cancellable`. If it is, the cache will be left in a consistent state, but may be storing the old set of objects or the new set.

This method is safe to call multiple times concurrently.

See also: ``folks_object_cache_store_objects_finish()``

#### Parameters

self | the FolksObjectCache instance |
objects | . A set of objects to store. This may be empty, but may not be `null`. . | [in]
cancellable | . A GCancellable for the operation, or `null`. . | [in][allow-none]
_callback_ | callback to call when the request is satisfied. | [scope async]
_user_data_ | the data to pass to _callback_ function. | [closure]

Since: 0.6.0

folks_object_cache_store_objects

### folks_object_cache_store_objects_finish ()

    void
    folks_object_cache_store_objects_finish
                                   (FolksObjectCache *self,
                                    GAsyncResult *_res_);

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.

Storing the objects can be cancelled using `cancellable`. If it is, the cache will be left in a consistent state, but may be storing the old set of objects or the new set.

This method is safe to call multiple times concurrently.

See also: ``folks_object_cache_store_objects()``

#### Parameters

self | the FolksObjectCache instance |
_res_ | a GAsyncResult |

Since: 0.6.0

folks_object_cache_store_objects_finish

### folks_object_cache_clear_cache ()

    void
    folks_object_cache_clear_cache (FolksObjectCache *self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);

Clear this cache object, deleting its backing file.

See also: ``folks_object_cache_clear_cache_finish()``

#### Parameters

self | the FolksObjectCache instance |
_callback_ | callback to call when the request is satisfied. | [scope async]
_user_data_ | the data to pass to _callback_ function. | [closure]

Since: 0.6.0

folks_object_cache_clear_cache

### folks_object_cache_clear_cache_finish ()

    void
    folks_object_cache_clear_cache_finish (FolksObjectCache *self,
                                           GAsyncResult *_res_);

Clear this cache object, deleting its backing file.

See also: ``folks_object_cache_clear_cache()``

#### Parameters

self | the FolksObjectCache instance |
_res_ | a GAsyncResult |

Since: 0.6.0

folks_object_cache_clear_cache_finish

### folks_object_cache_get_type_id ()

    const gchar *
    folks_object_cache_get_type_id (FolksObjectCache *self);

Get and return the current value of the "type-id" property.

A string identifying the type of object being cached.

This has to be suitable for use as a directory name; i.e. lower case, hyphen-separated tokens.

#### Parameters

self | the FolksObjectCache instance to query |

#### Returns

the value of the "type-id" property

Since: 0.6.6

folks_object_cache_get_type_id

### folks_object_cache_get_id ()

    const gchar *
    folks_object_cache_get_id (FolksObjectCache *self);

Get and return the current value of the "id" property.

A string identifying the particular cache instance.

This will form the file name of the cache file, but will be escaped beforehand, so can be an arbitrary non-empty string.

#### Parameters

self | the FolksObjectCache instance to query |

#### Returns

the value of the "id" property

Since: 0.6.6

folks_object_cache_get_id

## Types and Values

### FOLKS_TYPE_OBJECT_CACHE

    #define FOLKS_TYPE_OBJECT_CACHE (folks_object_cache_get_type ())

The type for FolksObjectCache.

FOLKS_TYPE_OBJECT_CACHE

### struct FolksObjectCache

    struct FolksObjectCache {
    	GObject parent_instance;
    	FolksObjectCachePrivate * priv;
    };

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 GVariants.

It's intended that this class be used for providing caching layers for FolksPersonaStores, for example.

Since: 0.6.0

FolksObjectCache

### struct FolksObjectCacheClass

    struct FolksObjectCacheClass {
    	GObjectClass parent_class;
    	GVariantType* (*get_serialised_object_type) (FolksObjectCache* self, guint8 object_version);
    	guint8 (*get_serialised_object_version) (FolksObjectCache* self);
    	GVariant* (*serialise_object) (FolksObjectCache* self, gconstpointer object);
    	gpointer (*deserialise_object) (FolksObjectCache* self, GVariant* variant, guint8 object_version);
    };

The class structure for `FOLKS_TYPE_OBJECT_CACHE`. All the fields in this structure are private and should never be accessed directly.

#### Members

get_serialised_object_type () | virtual method used internally |
get_serialised_object_version () | virtual method used internally |
serialise_object () | virtual method used internally |
deserialise_object () | virtual method used internally |

FolksObjectCacheClass