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

Function cache_insert_base

libCacheSim/cache/cache.c:264–283  ·  view source on GitHub ↗

* @brief this function is called by all caches to * insert an object into the cache, update the hash table and cache metadata * this function assumes the cache has enough space * and eviction is not part of this function * * @param cache * @param req * @return the inserted object */

Source from the content-addressed store, hash-verified

262 * @return the inserted object
263 */
264cache_obj_t *cache_insert_base(cache_t *cache, const request_t *req) {
265 cache_obj_t *cache_obj = hashtable_insert(cache->hashtable, req);
266 cache->occupied_byte += (int64_t)cache_obj->obj_size + (int64_t)cache->obj_md_size;
267 cache->n_obj += 1;
268
269#ifdef SUPPORT_TTL
270 if (cache->default_ttl != 0 && req->ttl == 0) {
271 cache_obj->exp_time = (int32_t)cache->default_ttl + req->clock_time;
272 }
273#endif
274
275#if defined(TRACK_EVICTION_V_AGE) || defined(TRACK_DEMOTION) || defined(TRACK_CREATE_TIME)
276 cache_obj->create_time = CURR_TIME(cache, req);
277#endif
278
279 cache_obj->misc.next_access_vtime = req->next_access_vtime;
280 cache_obj->misc.freq = 0;
281
282 return cache_obj;
283}
284
285/**
286 * @brief this function is called by all eviction algorithms in the eviction

Callers 15

LRU_Prob_insertFunction · 0.85
Clock_insertFunction · 0.85
FIFO_insertFunction · 0.85
RandomLRU_insertFunction · 0.85
LFUDA_insertFunction · 0.85
LFU_insertFunction · 0.85
LRU_insertFunction · 0.85
Size_insertFunction · 0.85
ARC_insertFunction · 0.85
MRU_insertFunction · 0.85
CR_LFU_insertFunction · 0.85
LeCaR_insertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected