MCPcopy Create free account
hub / github.com/facebook/CacheLib / insert

Method insert

cachelib/navy/block_cache/BlockCache.cpp:282–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282Status BlockCache::insert(HashedKey hk,
283 BufferView value,
284 uint8_t /* poolId */,
285 uint32_t /* expiryTime */,
286 uint32_t lastAccessTimeSecs) {
287 auto start = getSteadyClock();
288 SCOPE_EXIT {
289 insertLatency_.trackValue(toMicros(getSteadyClock() - start).count());
290 };
291 INJECT_PAUSE(pause_blockcache_insert_entry);
292
293 auto allocateRes = allocateForInsert(hk, value.size());
294 if (allocateRes.hasError()) {
295 return allocateRes.error();
296 }
297 auto& [desc, slotSize, addr, bufferView] = allocateRes.value();
298
299 // After allocation a region is opened for writing. Until we close it, the
300 // region would not be reclaimed and index never gets an invalid entry.
301 writeEntry(bufferView, hk, value, false, lastAccessTimeSecs);
302 updateIndex(hk.keyHash(), slotSize, addr, /* allowReplace */ true);
303 allocator_.close(std::move(desc));
304 INJECT_PAUSE(pause_blockcache_insert_done);
305 return Status::Ok;
306}
307
308bool BlockCache::updateIndex(uint64_t keyHash,
309 uint32_t size,

Callers 9

updateIndexMethod · 0.45
RegionManagerMethod · 0.45
addIndexEntryMethod · 0.45
CollisionCreatorMethod · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TEST_FFunction · 0.45

Calls 8

getSteadyClockFunction · 0.85
toMicrosFunction · 0.85
trackValueMethod · 0.80
countMethod · 0.80
sizeMethod · 0.45
valueMethod · 0.45
keyHashMethod · 0.45
closeMethod · 0.45

Tested by 6

CollisionCreatorMethod · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TEST_FFunction · 0.36