MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / cache_find_base

Function cache_find_base

libCacheSim/cache/cache.c:174–202  ·  view source on GitHub ↗

* @brief this function is called by eviction algorithms that use * the hash table to find whether an object is in the cache * * @param cache * @param req * @param update_cache whether to update the cache, * if true, the number of requests increases by 1, * the object size will be updated, * and if the object is expired, it is removed from the cache * @return the found cache_obj_t* or N

Source from the content-addressed store, hash-verified

172 * @return the found cache_obj_t* or NULL if not found
173 */
174cache_obj_t *cache_find_base(cache_t *cache, const request_t *req, const bool update_cache) {
175 cache_obj_t *cache_obj = hashtable_find(cache->hashtable, req);
176
177 // "update_cache = true" means that it is a real user request, use handle_find
178 // to update prefetcher's state
179 if (cache->prefetcher && cache->prefetcher->handle_find && update_cache) {
180 bool hit = (cache_obj != NULL);
181 cache->prefetcher->handle_find(cache, req, hit);
182 }
183
184 if (cache_obj != NULL) {
185#ifdef SUPPORT_TTL
186 if (cache_obj->exp_time != 0 && cache_obj->exp_time < req->clock_time) {
187 if (update_cache) {
188 cache->remove(cache, cache_obj->obj_id);
189 }
190
191 cache_obj = NULL;
192 }
193#endif
194
195 if (update_cache) {
196 cache_obj->misc.next_access_vtime = req->next_access_vtime;
197 cache_obj->misc.freq += 1;
198 }
199 }
200
201 return cache_obj;
202}
203
204/**
205 * @brief this function is called by all eviction algorithms

Callers 15

LRU_Prob_findFunction · 0.85
Clock_findFunction · 0.85
FIFO_findFunction · 0.85
RandomLRU_findFunction · 0.85
LFUDA_findFunction · 0.85
LFU_findFunction · 0.85
LRU_findFunction · 0.85
Size_findFunction · 0.85
ARC_findFunction · 0.85
MRU_findFunction · 0.85
CR_LFU_findFunction · 0.85
LeCaR_findFunction · 0.85

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected