* @brief insert an object into the cache, * update the hash table and cache metadata * this function assumes the cache has enough space * eviction should be * performed before calling this function * * @param cache * @param req * @return the inserted object */
| 349 | * @return the inserted object |
| 350 | */ |
| 351 | static cache_obj_t *S3FIFOd_insert(cache_t *cache, const request_t *req) { |
| 352 | S3FIFOd_params_t *params = (S3FIFOd_params_t *)cache->eviction_params; |
| 353 | cache_obj_t *obj = NULL; |
| 354 | |
| 355 | if (params->hit_on_ghost) { |
| 356 | /* insert into the ARC */ |
| 357 | params->hit_on_ghost = false; |
| 358 | params->main_cache->get(params->main_cache, req); |
| 359 | obj = params->main_cache->find(params->main_cache, req, false); |
| 360 | } else { |
| 361 | /* insert into the fifo */ |
| 362 | obj = params->fifo->insert(params->fifo, req); |
| 363 | } |
| 364 | |
| 365 | assert(obj->misc.freq == 0); |
| 366 | |
| 367 | #if defined(TRACK_EVICTION_V_AGE) |
| 368 | obj->create_time = CURR_TIME(cache, req); |
| 369 | #endif |
| 370 | |
| 371 | return obj; |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * @brief find the object to be evicted |