| 375 | } |
| 376 | |
| 377 | folly::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 | |
| 395 | folly::coro::Task<Result<bool>> RAMCacheComponent::remove(Key key) { |
| 396 | // calls_, hits_, and misses_ are not tracked here; CacheAllocator already |