| 552 | } |
| 553 | |
| 554 | bool SLRU_get_debug(cache_t *cache, const request_t *req) { |
| 555 | // SLRU_params_t *params = (SLRU_params_t *)(cache->eviction_params); |
| 556 | cache->n_req += 1; |
| 557 | |
| 558 | DEBUG_PRINT_CACHE_STATE(cache, params, req); |
| 559 | |
| 560 | bool cache_hit = cache->find(cache, req, true) != NULL; |
| 561 | |
| 562 | if (cache_hit) { |
| 563 | DEBUG_PRINT_CACHE(cache, params); |
| 564 | return cache_hit; |
| 565 | } |
| 566 | |
| 567 | if (cache->can_insert(cache, req) == false) { |
| 568 | DEBUG_PRINT_CACHE(cache, params); |
| 569 | return cache_hit; |
| 570 | } |
| 571 | |
| 572 | if (!cache_hit) { |
| 573 | while (cache->occupied_byte + req->obj_size + cache->obj_md_size > |
| 574 | cache->cache_size) { |
| 575 | cache->evict(cache, req); |
| 576 | } |
| 577 | |
| 578 | cache->insert(cache, req); |
| 579 | } |
| 580 | |
| 581 | DEBUG_PRINT_CACHE(cache, params); |
| 582 | |
| 583 | return cache_hit; |
| 584 | } |
| 585 | |
| 586 | #ifdef __cplusplus |
| 587 | extern "C" |