X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=cache.h;h=ec0e974ae3122c9908d94f801e12d941b45eae5c;hb=b25580915c7223c276348c39d5e7ed496a58a26e;hp=f2014dfd8c6a1037f90ed2190bb0f68bd1bb6b1d;hpb=33ccd714ea9469b5b7d3b36bbe468ba1b0f31dfc;p=catta diff --git a/cache.h b/cache.h index f2014df..ec0e974 100644 --- a/cache.h +++ b/cache.h @@ -1,22 +1,56 @@ #ifndef foocachehfoo #define foocachehfoo +#include + +struct _flxCache; +typedef struct _flxCache flxCache; + +#include "prioq.h" +#include "server.h" +#include "llist.h" + typedef enum { FLX_CACHE_VALID, FLX_CACHE_EXPIRY1, FLX_CACHE_EXPIRY2, FLX_CACHE_EXPIRY3 -} flxCacheEntry; +} flxCacheEntryState; + +typedef struct flxCacheEntry flxCacheEntry; -typedef struct flxCacheEntry { +struct flxCacheEntry { + flxRecord *record; GTimeVal timestamp; - flxRecord rr; - gint interface; + GTimeVal expiry; + flxAddress origin; flxCacheEntryState state; + + FLX_LLIST_FIELDS(flxCacheEntry, by_name); + + flxPrioQueueNode *node; -} flxCacheEntry; +}; + +struct _flxCache { + flxServer *server; + flxInterface *interface; + + GHashTable *hash_table; +}; + +flxCache *flx_cache_new(flxServer *server, flxInterface *interface); +void flx_cache_free(flxCache *c); + +flxCacheEntry *flx_cache_lookup_key(flxCache *c, flxKey *k); +flxCacheEntry *flx_cache_lookup_record(flxCache *c, flxRecord *r); + +flxCacheEntry *flx_cache_update(flxCache *c, flxRecord *r, gboolean unique, const flxAddress *a); + +void flx_cache_drop_key(flxCache *c, flxKey *k); +void flx_cache_drop_record(flxCache *c, flxRecord *r); #endif