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

Method insert

cachelib/navy/block_cache/SparseMapIndex.cpp:142–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142Index::LookupResult SparseMapIndex::insert(uint64_t key,
143 uint32_t address,
144 uint16_t sizeHint) {
145 auto& map = getMap(key);
146 auto lock = std::lock_guard{getMutex(key)};
147 auto it = map.find(subkey(key));
148 if (it != map.end()) {
149 LookupResult lr{true, it->second};
150
151 trackRemove(it->second);
152 // tsl::sparse_map's `it->second` is immutable, while it.value() is
153 // mutable
154 it.value().address = address;
155 it.value().currentHits = 0;
156 it.value().extra = {0};
157 it.value().sizeHint = sizeHint;
158 return lr;
159 }
160 map.try_emplace(subkey(key), address, sizeHint);
161
162 return {};
163}
164
165Index::LookupResult SparseMapIndex::insertIfNotExists(uint64_t key,
166 uint32_t address,

Callers

nothing calls this directly

Calls 3

findMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected