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

Method allocateForInsert

cachelib/navy/block_cache/BlockCache.cpp:1278–1303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1276}
1277
1278folly::Expected<BlockCache::AllocData, Status> BlockCache::allocateForInsert(
1279 const HashedKey& hk, const uint32_t valueSize, bool canWait) {
1280 if (serializedSize(hk.key().size(), valueSize) > kMaxItemSize) {
1281 allocErrorCount_.inc();
1282 insertCount_.inc();
1283 return folly::makeUnexpected(Status::Rejected);
1284 }
1285
1286 // All newly inserted items are assigned with the lowest priority
1287 auto retVal = allocateImpl(hk, valueSize, kDefaultItemPriority, canWait);
1288 switch (std::get<0>(retVal).status()) {
1289 case OpenStatus::Ready:
1290 insertCount_.inc();
1291 return retVal;
1292 case OpenStatus::Error:
1293 allocErrorCount_.inc();
1294 insertCount_.inc();
1295 return folly::makeUnexpected(Status::Rejected);
1296 case OpenStatus::Retry:
1297 allocRetryCount_.inc();
1298 return folly::makeUnexpected(Status::Retry);
1299 default:
1300 XLOG(DFATAL) << "Unexpected OpenStatus";
1301 return folly::makeUnexpected(Status::BadState);
1302 }
1303}
1304
1305/* static */ BlockCache::EntryDesc* BlockCache::writeEntryDescAndKey(
1306 MutableBufferView buffer,

Callers 1

allocateImplMethod · 0.80

Calls 4

statusMethod · 0.80
sizeMethod · 0.45
keyMethod · 0.45
incMethod · 0.45

Tested by

no test coverage detected