| Top |
| gboolean | (*CamelDataCacheRemoveFunc) () |
| CamelDataCache * | camel_data_cache_new () |
| const gchar * | camel_data_cache_get_path () |
| void | camel_data_cache_set_path () |
| gboolean | camel_data_cache_get_expire_enabled () |
| void | camel_data_cache_set_expire_enabled () |
| void | camel_data_cache_set_expire_age () |
| void | camel_data_cache_set_expire_access () |
| GIOStream * | camel_data_cache_get () |
| gint | camel_data_cache_remove () |
| gchar * | camel_data_cache_get_filename () |
| void | camel_data_cache_clear () |
| void | camel_data_cache_foreach_remove () |
| GIOStream * | camel_data_cache_add_atomic () |
| GIOStream * | camel_data_cache_commit_atomic () |
| void | camel_data_cache_discard_atomic () |
gboolean (*CamelDataCacheRemoveFunc) (CamelDataCache *cdc,const gchar *filename,gpointer user_data);
A callback called for each found file in the cache, used
by camel_data_cache_foreach_remove(). The filename
corresponds
to the result of camel_data_cache_get_filename().
cdc |
||
filename |
a file name found in the cache |
|
user_data |
user data passed to |
Since: 3.26
CamelDataCache * camel_data_cache_new (const gchar *path,GError **error);
Create a new data cache.
const gchar *
camel_data_cache_get_path (CamelDataCache *cdc);
Returns the path to the data cache.
Since: 2.32
void camel_data_cache_set_path (CamelDataCache *cdc,const gchar *path);
Sets the path to the data cache.
Since: 2.32
gboolean
camel_data_cache_get_expire_enabled (CamelDataCache *cdc);
Gets whether expire of cache data is enabled.
This is a complementary property for camel_data_cache_set_expire_age()
and camel_data_cache_set_expire_access(), which allows to disable expiry
without touching the two values. Having expire enabled, but not have set
any of the two times, still behaves like not having expiry enabled.
Since: 3.24
void camel_data_cache_set_expire_enabled (CamelDataCache *cdc,gboolean expire_enabled);
Sets whether expire of cache data is enabled.
This is a complementary property for camel_data_cache_set_expire_age()
and camel_data_cache_set_expire_access(), which allows to disable expiry
without touching the two values. Having expire enabled, but not have set
any of the two times, still behaves like not having expiry enabled.
Since: 3.24
void camel_data_cache_set_expire_age (CamelDataCache *cdc,time_t when);
Set the cache expiration policy for aged entries.
Items in the cache older than when
seconds may be
flushed at any time. Items are expired in a lazy
manner, so it is indeterminate when the items will
physically be removed.
Note you can set both an age and an access limit. The age acts as a hard limit on cache entries.
void camel_data_cache_set_expire_access (CamelDataCache *cdc,time_t when);
Set the cache expiration policy for access times.
Items in the cache which haven't been accessed for when
seconds may be expired at any time. Items are expired in a lazy
manner, so it is indeterminate when the items will
physically be removed.
Note you can set both an age and an access limit. The age acts as a hard limit on cache entries.
GIOStream * camel_data_cache_get (CamelDataCache *cdc,const gchar *path,const gchar *key,GError **error);
Lookup an item in the cache. If the item exists, a GIOStream is returned for the item. The stream may be shared by multiple callers, so ensure the stream is in a valid state through external locking.
The returned GIOStream is referenced for thread-safety and must be
unreferenced with g_object_unref() when finished with it.
gint camel_data_cache_remove (CamelDataCache *cdc,const gchar *path,const gchar *key,GError **error);
Remove/expire a cache item.
gchar * camel_data_cache_get_filename (CamelDataCache *cdc,const gchar *path,const gchar *key);
Lookup the filename for an item in the cache
Since: 2.26
void camel_data_cache_clear (CamelDataCache *cdc,const gchar *path);
Clear cache's content in path
.
Since: 3.2
void camel_data_cache_foreach_remove (CamelDataCache *cdc,const gchar *path,CamelDataCacheRemoveFunc func,gpointer user_data);
Traverses the cdc
sub-cache identified by path
and calls func
for each found file.
If the func
returns TRUE, then the file is removed, if FALSE, it's kept in the cache.
cdc |
||
path |
Path to the (sub) cache the items exist in |
|
func |
a callback to call for each found file in the cache. |
[scope call][closure user_data] |
user_data |
user data passed to |
Since: 3.26
GIOStream * camel_data_cache_add_atomic (CamelDataCache *cdc,const gchar *path,const gchar *key,GError **error);
Open a temporary file for writing a new cache item identified by path
and key
. The temporary file lives in the same directory as the final
target so that camel_data_cache_commit_atomic() can rename it into place
atomically (same-filesystem rename).
Any concurrent call to camel_data_cache_get() for the same path
/key
will
block until the caller either commits or discards the stream.
On success, pass the returned stream to camel_data_cache_commit_atomic()
or camel_data_cache_discard_atomic(); the stream is consumed
(transfer full) by both functions. Do not call g_object_unref() on it
directly.
cdc |
||
path |
Relative path of item to add. |
|
key |
Key of item to add. |
|
error |
return location for a GError, or |
Since: 3.62
GIOStream * camel_data_cache_commit_atomic (CamelDataCache *cdc,GIOStream *stream,GError **error);
Finalise an atomic cache write. stream
is closed and unreffed, the
temporary file is renamed to its final location, and a new GIOStream
opened on the committed file is returned (equivalent to calling
camel_data_cache_get() after a successful write).
On failure the temporary file is removed and the bag reservation is
released, so the caller does not need to call
camel_data_cache_discard_atomic().
cdc |
||
stream |
the GIOStream returned by |
[transfer full] |
error |
return location for a GError, or |
Since: 3.62
void camel_data_cache_discard_atomic (CamelDataCache *cdc,GIOStream *stream);
Discard an atomic cache write. stream
is closed and unreffed, the
temporary file is removed, and the bag reservation is released so that
other threads can retry the operation.
Call this on any error path before camel_data_cache_commit_atomic().
Since: 3.62