| 1276 | } |
| 1277 | |
| 1278 | folly::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, |
no test coverage detected