| 46 | } |
| 47 | |
| 48 | void |
| 49 | ObjectSizeCache::set(const std::string_view url, uint64_t object_size) |
| 50 | { |
| 51 | std::lock_guard lock{_mutex}; |
| 52 | cache_size_type i; |
| 53 | if (auto it = _index.find(url); it != _index.end()) { |
| 54 | // Already exists in cache. Overwrite. |
| 55 | i = it->second; |
| 56 | } else { |
| 57 | // Doesn't exist in cache. Evict something else. |
| 58 | find_eviction_slot(); |
| 59 | i = _hand; |
| 60 | _urls[i] = url; |
| 61 | _index[_urls[i]] = _hand; |
| 62 | _hand++; |
| 63 | if (_hand >= _cache_capacity) { |
| 64 | _hand = 0; |
| 65 | } |
| 66 | } |
| 67 | _object_sizes[i] = object_size; |
| 68 | } |
| 69 | |
| 70 | void |
| 71 | ObjectSizeCache::remove(const std::string_view url) |
no test coverage detected