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

Method insert

cachelib/common/ApproxSplitSet.h:189–202  ·  view source on GitHub ↗

Returns true if @key already existed in the set before insert

Source from the content-addressed store, hash-verified

187
188 // Returns true if @key already existed in the set before insert
189 bool insert(uint64_t key) {
190 std::lock_guard<std::mutex> l(mutex_);
191 DCHECK(!splits_.empty());
192 // Important to lookup first, because entry may be in another split, not the
193 // one we're currently inserting into.
194 auto exists = lookupLocked(key);
195 if (!exists) {
196 if (splits_.back().size() >= maxSplitSize_) {
197 addNewSplit();
198 }
199 splits_.back().insert(key);
200 }
201 return exists;
202 }
203
204 void reset() {
205 std::lock_guard<std::mutex> lock{mutex_};

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected