From 7dfbd6818b9f81df58fb10f3a56ed39338fdd002 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Sun, 3 Aug 2025 14:53:41 +0200 Subject: Add hit counter in cache entries --- src/cache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cache.c b/src/cache.c index 862d199a..d05565c9 100644 --- a/src/cache.c +++ b/src/cache.c @@ -65,6 +65,7 @@ typedef struct { int ExpectedSize; /**< Goal size of the HTTP transfer (0 if unknown)*/ int TransferSize; /**< Actual length of the HTTP transfer */ uint_t Flags; /**< See Flag Defines in cache.h */ + int Hits; /**< Counter of hits for the entry */ } CacheEntry_t; @@ -210,6 +211,7 @@ static void Cache_entry_init(CacheEntry_t *NewEntry, const DilloUrl *Url) NewEntry->ExpectedSize = 0; NewEntry->TransferSize = 0; NewEntry->Flags = CA_IsEmpty | CA_InProgress | CA_KeepAlive; + NewEntry->Hits = 0; } /** @@ -391,6 +393,7 @@ int a_Cache_open_url(void *web, CA_Callback_t Call, void *CbData) /* URL is cached: feed our client with cached data */ ClientKey = Cache_client_enqueue(entry->Url, Web, Call, CbData); Cache_delayed_process_queue(entry); + entry->Hits++; } else { /* URL not cached: create an entry, send our client to the queue, -- cgit v1.2.3