| 140 | } |
| 141 | |
| 142 | Cache::Handle* GetEntryFromCache(Cache* block_cache, const Slice& key, |
| 143 | Tickers block_cache_miss_ticker, |
| 144 | Tickers block_cache_hit_ticker, |
| 145 | uint64_t* block_cache_miss_stats, |
| 146 | uint64_t* block_cache_hit_stats, |
| 147 | Statistics* statistics, |
| 148 | GetContext* get_context) { |
| 149 | auto cache_handle = block_cache->Lookup(key, statistics); |
| 150 | if (cache_handle != nullptr) { |
| 151 | PERF_COUNTER_ADD(block_cache_hit_count, 1); |
| 152 | if (get_context != nullptr) { |
| 153 | // overall cache hit |
| 154 | get_context->get_context_stats_.num_cache_hit++; |
| 155 | // total bytes read from cache |
| 156 | get_context->get_context_stats_.num_cache_bytes_read += |
| 157 | block_cache->GetUsage(cache_handle); |
| 158 | // block-type specific cache hit |
| 159 | (*block_cache_hit_stats)++; |
| 160 | } else { |
| 161 | // overall cache hit |
| 162 | RecordTick(statistics, BLOCK_CACHE_HIT); |
| 163 | // total bytes read from cache |
| 164 | RecordTick(statistics, BLOCK_CACHE_BYTES_READ, |
| 165 | block_cache->GetUsage(cache_handle)); |
| 166 | RecordTick(statistics, block_cache_hit_ticker); |
| 167 | } |
| 168 | } else { |
| 169 | if (get_context != nullptr) { |
| 170 | // overall cache miss |
| 171 | get_context->get_context_stats_.num_cache_miss++; |
| 172 | // block-type specific cache miss |
| 173 | (*block_cache_miss_stats)++; |
| 174 | } else { |
| 175 | RecordTick(statistics, BLOCK_CACHE_MISS); |
| 176 | RecordTick(statistics, block_cache_miss_ticker); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | return cache_handle; |
| 181 | } |
| 182 | |
| 183 | // For hash based index, return true if prefix_extractor and |
| 184 | // prefix_extractor_block mismatch, false otherwise. This flag will be used |
no test coverage detected