* @brief check whether an object is in the cache * * @param cache * @param req * @param update_cache whether to update the cache, * if true, the object is promoted * and if the object is expired, it is removed from the cache * @return true on hit, false on miss */
| 136 | * @return true on hit, false on miss |
| 137 | */ |
| 138 | static cache_obj_t *Clock_find(cache_t *cache, const request_t *req, const bool update_cache) { |
| 139 | Clock_params_t *params = (Clock_params_t *)cache->eviction_params; |
| 140 | cache_obj_t *obj = cache_find_base(cache, req, update_cache); |
| 141 | if (obj != NULL && update_cache) { |
| 142 | if (obj->clock.freq < params->max_freq) { |
| 143 | obj->clock.freq += 1; |
| 144 | } |
| 145 | #ifdef USE_BELADY |
| 146 | obj->next_access_vtime = req->next_access_vtime; |
| 147 | #endif |
| 148 | } |
| 149 | |
| 150 | return obj; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @brief insert an object into the cache, |
nothing calls this directly
no test coverage detected