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

Method insert

cachelib/interface/tests/InterfaceTest.cpp:92–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90 }
91
92 folly::coro::Task<UnitResult> insert(AllocatedHandle&& handle) override {
93 auto itemIt = findAllocatedItem(handle.get());
94 if (itemIt == allocatedItems_.end()) {
95 co_return makeError(Error::Code::INVALID_ARGUMENTS,
96 "item was not allocated");
97 }
98
99 auto [_, inserted] = cachedItems_.try_emplace(handle->getKey(), *itemIt);
100 if (!inserted) {
101 co_return makeError(Error::Code::ALREADY_INSERTED, "duplicate key");
102 }
103
104 allocatedItems_.erase(itemIt);
105 releaseHandle(std::move(handle));
106 co_return folly::unit;
107 }
108
109 folly::coro::Task<Result<std::optional<AllocatedHandle>>> insertOrReplace(
110 AllocatedHandle&& handle) override {

Callers 2

allocateAndInsertItemMethod · 0.45
CO_TEST_FFunction · 0.45

Calls 4

eraseMethod · 0.80
getMethod · 0.45
endMethod · 0.45
getKeyMethod · 0.45

Tested by

no test coverage detected