diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-11 14:29:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-11 14:29:18 +0100 |
commit | 7b44f3af0b2b7674c4ee14d386022b8d96e4ceb8 (patch) | |
tree | 0b65da08283655a4830ca430d2ae7b20c28d3628 /src/libutil/hash.h | |
parent | a43df55fa537d37c93d151b0c17578eefd83eb84 (diff) | |
download | rspamd-7b44f3af0b2b7674c4ee14d386022b8d96e4ceb8.tar.gz rspamd-7b44f3af0b2b7674c4ee14d386022b8d96e4ceb8.zip |
[Rework] Use LFU algorithm in LRU cache
Avoid usage of heap as its updates are not cheap. Use LFU algorithm
described here: http://antirez.com/news/109
Diffstat (limited to 'src/libutil/hash.h')
-rw-r--r-- | src/libutil/hash.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libutil/hash.h b/src/libutil/hash.h index 30c0c99ac..80bdf8ae3 100644 --- a/src/libutil/hash.h +++ b/src/libutil/hash.h @@ -8,20 +8,11 @@ #define RSPAMD_HASH_H #include "config.h" -#include "heap.h" struct rspamd_lru_hash_s; typedef struct rspamd_lru_hash_s rspamd_lru_hash_t; - -typedef struct rspamd_lru_element_s { - struct rspamd_min_heap_elt helt; - guint ttl; - guint usages; - time_t storage; - gpointer data; - gpointer key; - rspamd_lru_hash_t *hash; -} rspamd_lru_element_t; +struct rspamd_lru_element_s; +typedef struct rspamd_lru_element_s rspamd_lru_element_t; /** @@ -85,6 +76,13 @@ void rspamd_lru_hash_destroy (rspamd_lru_hash_t *hash); * Get hash table for this lru hash (use rspamd_lru_element_t as data) */ GHashTable *rspamd_lru_hash_get_htable (rspamd_lru_hash_t *hash); + +/** + * Get element's data + * @param elt + * @return + */ +gpointer rspamd_lru_hash_element_data (rspamd_lru_element_t *elt); #endif /* |