Browse Source

[Minor] Allow explicit deletion from LRU cache

tags/1.6.0
Vsevolod Stakhov 7 years ago
parent
commit
bc5cf4c240
2 changed files with 26 additions and 0 deletions
  1. 17
    0
      src/libutil/hash.c
  2. 9
    0
      src/libutil/hash.h

+ 17
- 0
src/libutil/hash.c View 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)

+ 9
- 0
src/libutil/hash.h View 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

Loading…
Cancel
Save