]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow explicit deletion from LRU cache
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 May 2017 08:48:20 +0000 (09:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 May 2017 08:48:20 +0000 (09:48 +0100)
src/libutil/hash.c
src/libutil/hash.h

index 591af9027f5ef5173c08375ad94ce623cef2511e..1afe947eec6ebb204fe74de6bcf4f899cc089666 100644 (file)
@@ -342,6 +342,23 @@ rspamd_lru_hash_lookup (rspamd_lru_hash_t *hash, gconstpointer key, time_t now)
        return NULL;
 }
 
+gboolean
+rspamd_lru_hash_remove (rspamd_lru_hash_t *hash,
+               gconstpointer key)
+{
+       rspamd_lru_element_t *res;
+
+       res = g_hash_table_lookup (hash->tbl, key);
+
+       if (res != NULL) {
+               rspamd_lru_hash_remove_node (hash, res);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 void
 rspamd_lru_hash_insert (rspamd_lru_hash_t *hash, gpointer key, gpointer value,
        time_t now, guint ttl)
index 80bdf8ae3c57a87d39c49285b507d8274cad1795..7638d6397e8d7926230a6c914ba86953d4de7e2a 100644 (file)
@@ -53,6 +53,15 @@ rspamd_lru_hash_t * rspamd_lru_hash_new_full (
 gpointer rspamd_lru_hash_lookup (rspamd_lru_hash_t *hash,
        gconstpointer key,
        time_t now);
+
+/**
+ * Removes key from LRU cache
+ * @param hash
+ * @param key
+ * @return TRUE if key has been found and removed
+ */
+gboolean rspamd_lru_hash_remove (rspamd_lru_hash_t *hash,
+               gconstpointer key);
 /**
  * Insert item in hash
  * @param hash hash object