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

Method writeEntry

cachelib/navy/block_cache/BlockCache.cpp:1320–1350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1318}
1319
1320void BlockCache::writeEntry(MutableBufferView buffer,
1321 std::optional<HashedKey> hk,
1322 BufferView value,
1323 bool combinedEntry,
1324 uint32_t lastAccessTimeSecs) {
1325 XDCHECK((combinedEntry && !hk.has_value()) ||
1326 (!combinedEntry && hk.has_value()));
1327
1328 auto keySize = (combinedEntry) ? 0 : hk->key().size();
1329 auto keyHash = (combinedEntry) ? kCombinedEntrySignatureValue : hk->keyHash();
1330 size_t logicalWriteSize = 0;
1331
1332 // Copy descriptor and the key to the end
1333 uint8_t* dest = buffer.data() + buffer.size() - sizeof(EntryDesc);
1334 auto desc = new (dest) EntryDesc(static_cast<uint32_t>(keySize),
1335 static_cast<uint32_t>(value.size()), keyHash,
1336 lastAccessTimeSecs);
1337
1338 if (checksumData_) {
1339 desc->cs = checksum(value);
1340 }
1341
1342 if (!combinedEntry) {
1343 // Key info will be inside the value itself for combined entry block
1344 std::memcpy(dest - keySize, hk->key().data(), keySize);
1345 logicalWriteSize = keySize + value.size();
1346 }
1347 std::memcpy(buffer.data(), value.data(), value.size());
1348
1349 logicalWrittenCount_.add(logicalWriteSize);
1350}
1351
1352void BlockCache::readEntry(RegionDescriptor& regionDesc,
1353 LookupData& ld,

Callers

nothing calls this directly

Calls 6

checksumFunction · 0.85
sizeMethod · 0.45
keyMethod · 0.45
keyHashMethod · 0.45
dataMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected