6 struct lru_cache_entry
{
7 struct lru_cache_entry
*next
;
8 struct lru_cache_entry
*prev
;
9 struct lru_cache_entry
*hash_next
;
10 unsigned long hash_slot
;
12 typedef struct lru_cache_entry lru_entry_t
;
16 A function which, given an entry, returns a pointer to a buffer
17 and a number of bytes to use to generate a hash of the entry.
19 typedef void (lru_hash_feed_fn
)(lru_entry_t
*, char **, size_t *);
22 A function which compares two entries for equality.
24 typedef int (lru_entry_cmp_fn
)(lru_entry_t
*, lru_entry_t
*);
26 struct lru_cache_hashslot_
{
28 struct lru_cache_entry
*entry
;
33 const size_t capacity
;
35 lru_hash_feed_fn
*feed_fn
;
36 lru_entry_cmp_fn
*cmp_fn
;
39 struct lru_cache_entry
*newest
;
40 struct lru_cache_entry
*oldest
;
41 struct lru_cache_hashslot_ hash
[1];
44 struct lru_cache
*lru_cache_new(size_t, size_t, lru_hash_feed_fn
*, lru_entry_cmp_fn
*);
45 void lru_cache_insert(struct lru_cache
*, lru_entry_t
*, lru_entry_t
**);
46 void lru_cache_extract(struct lru_cache
*, lru_entry_t
*);
47 lru_entry_t
*lru_cache_locate(struct lru_cache
*, lru_entry_t
*);
48 void lru_cache_foreach(struct lru_cache
*, void (*)(lru_entry_t
*, size_t, void *), void *);
50 #endif /* LRU_CACHE_H */