[libsoup/cache] soup-cache: add soup_cache_clear
- From: Xan Lopez <xan src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libsoup/cache] soup-cache: add soup_cache_clear
- Date: Tue, 4 Aug 2009 07:28:22 +0000 (UTC)
commit f0fd331f74806005ff4a7cac1d3485a25ea02031
Author: Xan Lopez <xan gnome org>
Date: Tue Aug 4 10:16:10 2009 +0300
soup-cache: add soup_cache_clear
Clears all entries from the cache, including their cache files.
libsoup/soup-cache.c | 27 +++++++++++++++++++++++++++
libsoup/soup-cache.h | 2 ++
2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/libsoup/soup-cache.c b/libsoup/soup-cache.c
index 96fbeed..d9b4123 100644
--- a/libsoup/soup-cache.c
+++ b/libsoup/soup-cache.c
@@ -980,3 +980,30 @@ soup_cache_flush (SoupCache *cache, SoupSession *session)
g_main_context_iteration (async_context, TRUE);
}
+static void
+remove_cache_item (gpointer key,
+ gpointer value,
+ SoupCache *cache)
+{
+ soup_cache_entry_delete_by_key (cache, key);
+}
+
+/**
+ * soup_cache_clear:
+ * @cache: a #SoupCache
+ *
+ * Will remove all entries in the @cache plus all the cache files
+ * associated with them.
+ **/
+void
+soup_cache_clear (SoupCache *cache)
+{
+ GHashTable *hash;
+
+ g_return_if_fail (SOUP_IS_CACHE (cache));
+
+ hash = cache->priv->cache;
+ g_return_if_fail (hash);
+
+ g_hash_table_foreach (hash, (GHFunc)remove_cache_item, cache);
+}
diff --git a/libsoup/soup-cache.h b/libsoup/soup-cache.h
index 9dfe18a..e19fdde 100644
--- a/libsoup/soup-cache.h
+++ b/libsoup/soup-cache.h
@@ -54,6 +54,8 @@ void soup_cache_send_response (SoupCache *cache,
SoupCacheability soup_cache_get_cacheability (SoupCache *cache,
SoupMessage *msg);
void soup_cache_flush (SoupCache *cache,
+ SoupSession *session);
+void soup_cache_clear (SoupCache *cache);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]