| 462 | } |
| 463 | |
| 464 | UnitResult RAMCacheComponent::shutdown() { |
| 465 | if (persist_) { |
| 466 | switch (cache_->shutDown()) { |
| 467 | case LruAllocator::ShutDownStatus::kSuccess: // fall-through |
| 468 | case LruAllocator::ShutDownStatus::kSavedOnlyDRAM: |
| 469 | break; |
| 470 | case LruAllocator::ShutDownStatus::kSavedOnlyNvmCache: // fall-through |
| 471 | case LruAllocator::ShutDownStatus::kFailed: // fall-through |
| 472 | default: |
| 473 | return makeError(Error::Code::SHUTDOWN_FAILED, |
| 474 | "failed to persist RAM cache state"); |
| 475 | } |
| 476 | } else { |
| 477 | // shutDown() internally calls stopWorkers() but doesn't check the return |
| 478 | // value so we won't either |
| 479 | cache_->stopWorkers(); |
| 480 | } |
| 481 | return folly::unit; |
| 482 | } |
| 483 | |
| 484 | CacheComponentStats RAMCacheComponent::getStats() const noexcept { |
| 485 | CacheComponentStats stats(*stats_); |