X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=cache.h;h=3b4eef656a11129b82a25c88b8f39dab9444400e;hb=cfc653d0fd2f58ef3f4b5ecb285d5beb5bfaacfb;hp=f51e18e6069eeda0fe3f7bf95e3d4bafc2ffa185;hpb=ad1f9d3725a300f10eca071c6fe2f2c583f51436;p=catta diff --git a/cache.h b/cache.h index f51e18e..3b4eef6 100644 --- a/cache.h +++ b/cache.h @@ -32,8 +32,8 @@ struct flxCacheEntry { flxCacheEntryState state; flxTimeEvent *time_event; - FLX_LLIST_FIELDS(flxCacheEntry, by_name); - + FLX_LLIST_FIELDS(flxCacheEntry, by_key); + FLX_LLIST_FIELDS(flxCacheEntry, entry); }; struct _flxCache { @@ -42,6 +42,8 @@ struct _flxCache { flxInterface *interface; GHashTable *hash_table; + + FLX_LLIST_HEAD(flxCacheEntry, entries); }; flxCache *flx_cache_new(flxServer *server, flxInterface *interface); @@ -50,11 +52,15 @@ 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_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); void flx_cache_dump(flxCache *c, FILE *f); +typedef gpointer flxCacheWalkCallback(flxCache *c, flxKey *pattern, flxCacheEntry *e, gpointer userdata); +gpointer flx_cache_walk(flxCache *c, flxKey *pattern, flxCacheWalkCallback cb, gpointer userdata); + +gboolean flx_cache_entry_half_ttl(flxCache *c, flxCacheEntry *e); + #endif