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

Method iterator

cachelib/interface/components/RAMCacheComponent.cpp:377–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377folly::coro::AsyncGenerator<ReadHandle> RAMCacheComponent::iterator() {
378 for (auto it = cache_->begin(); it != cache_->end(); ++it) {
379 // Create a new handle (bump the refcount) rather than adopting the handle &
380 // pulling it out from underneath the iterator
381 auto result = tryCreateHandle<ReadHandle>(
382 *this, getRAMCacheItem(const_cast<LruCacheItem*>(&*it)));
383 if (result.hasValue()) {
384 auto& handle = result.value();
385 if (!util::isExpired(handle->getExpiryTime())) {
386 co_yield std::move(handle);
387 }
388 } else {
389 XLOG_EVERY_MS(WARN, 250) << "Failed to get handle for RAM cache item "
390 << it->getKey() << ": " << result.error();
391 }
392 }
393}
394
395folly::coro::Task<Result<bool>> RAMCacheComponent::remove(Key key) {
396 // calls_, hits_, and misses_ are not tracked here; CacheAllocator already

Callers 2

CO_TEST_FFunction · 0.45
CO_TYPED_TESTFunction · 0.45

Calls 7

isExpiredFunction · 0.85
hasValueMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
valueMethod · 0.45
getExpiryTimeMethod · 0.45
getKeyMethod · 0.45

Tested by 2

CO_TEST_FFunction · 0.36
CO_TYPED_TESTFunction · 0.36