|
KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
|


Go to the source code of this file.
Data Structures | |
| struct | KlResolverCacheConfig |
Macros | |
| #define | KL_RESCACHE_DEFAULT_TTL_MS 60000 |
| #define | KL_RESCACHE_DEFAULT_CAPACITY 64 |
Functions | |
| KlResolver * | kl_resolver_cache_create (KlResolver *inner, const KlResolverCacheConfig *cfg, KlAllocator *alloc) |
| Create a caching resolver that wraps an inner resolver. | |
| void | kl_resolver_cache_clear (KlResolver *resolver) |
| Evict all cached entries. | |
| int | kl_resolver_cache_count (const KlResolver *resolver) |
| Return the number of occupied cache entries. | |
| #define KL_RESCACHE_DEFAULT_TTL_MS 60000 |
resolver_cache.h — Caching DNS resolver decorator
Wraps any KlResolver and caches successful results with configurable TTL. Returns a KlResolver * that plugs directly into KlClientConfig.resolver.
Cache miss → delegates to inner resolver, stores result on completion. Cache hit → calls done_fn synchronously, returns immediately. Errors are never cached — the next resolve retries via the inner resolver.
| #define KL_RESCACHE_DEFAULT_CAPACITY 64 |
| KlResolver * kl_resolver_cache_create | ( | KlResolver * | inner, |
| const KlResolverCacheConfig * | cfg, | ||
| KlAllocator * | alloc | ||
| ) |
Create a caching resolver that wraps an inner resolver.
The returned KlResolver * is the cache; destroy it via the vtable's destroy function. The inner resolver is borrowed (not owned) — the caller must destroy it separately after destroying the cache.
| inner | Inner resolver to delegate cache misses to (borrowed). |
| cfg | Config (NULL = defaults: 64 entries, 60 s TTL). |
| alloc | Allocator (borrowed). |
| void kl_resolver_cache_clear | ( | KlResolver * | resolver | ) |
Evict all cached entries.
| int kl_resolver_cache_count | ( | const KlResolver * | resolver | ) |
Return the number of occupied cache entries.