* @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 */
| 262 | * @return the inserted object |
| 263 | */ |
| 264 | cache_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 |
no outgoing calls
no test coverage detected