Folks.AvatarCache – folks – Vala Binding Reference

Folks.AvatarCache – folks Reference Manual

# AvatarCache

## Object Hierarchy:

## Description:

public class AvatarCache : Object

A singleton persistent cache for avatars in folks.

Avatars may be added to the cache, and referred to by a persistent URI from that point onwards. The avatars will be stored on disk in the user's XDG cache directory.

The avatar cache is typically used by backends where retrieving avatars is an expensive operation (for example, they have to be downloaded from the network every time they're used).

All avatars from all users of the Folks.AvatarCache are stored in the same namespace, so callers must ensure that the IDs they use for avatars are globally unique (e.g. by using the corresponding Folks.Persona.uid).

Ongoing store operations (Folks.AvatarCache.store_avatar) are rate limited to try and prevent file descriptor exhaustion. Load operations ( Folks.AvatarCache.load_avatar) must be rate limited by the client, as the file I/O occurs when calling GLib.LoadableIcon.load rather than when retrieving the GLib.LoadableIcon from the cache.

## Since:

0.6.0

Namespace: Folks
Package: folks

## Content:

### Static methods:

- public static AvatarCache dup ()
  Create or return the singleton Folks.AvatarCache class instance. If the instance doesn't exist already, it will be created.

### Methods:

- public string build_uri_for_avatar (string id)
  Build the URI of an avatar file in the cache from a globally unique ID. This will always succeed, even if the avatar doesn't exist in the cache.
- public async LoadableIcon? load_avatar (string id) throws Error
  Fetch an avatar from the cache by its globally unique ID.
- public async void remove_avatar (string id) throws Error
  Remove an avatar from the cache, if it exists in the cache. If the avatar exists in the cache but there is a problem in removing it, a GLib.Error will be thrown.
- public async string store_avatar (string id, LoadableIcon avatar) throws Error
  Store an avatar in the cache, assigning the given globally unique ID to it, which can later be used to load and remove the avatar from the cache. For example, this ID could be the UID of a persona. The URI of the cached avatar file will be returned.

### Inherited Members:

All known members inherited from class GLib.Object

- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data

- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer

- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref