aboutsummaryrefslogtreecommitdiff
path: root/src/cache.c
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2025-08-03 14:53:41 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2025-08-11 21:43:10 +0200
commit7dfbd6818b9f81df58fb10f3a56ed39338fdd002 (patch)
tree118df89bdec7c209c4b5b7268f77e2fac6fca053 /src/cache.c
parent23ffaf32cda0ced7a34c98f5720990ffe6d4b662 (diff)
Add hit counter in cache entries
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c3
1 files changed, 3 insertions, 0 deletions
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,