diff --git a/cachelib/cachebench/cache/ItemRecords.h b/cachelib/cachebench/cache/ItemRecords.h index 651972722..cc1cfe100 100644 --- a/cachelib/cachebench/cache/ItemRecords.h +++ b/cachelib/cachebench/cache/ItemRecords.h @@ -22,6 +22,32 @@ #include "cachelib/allocator/Cache.h" #include "cachelib/cachebench/cache/CacheValue.h" +using DestructorContext = facebook::cachelib::DestructorContext; +/* From: https://fmt.dev/latest/api.html#udt */ +template <> +struct fmt::formatter : formatter { + // parse is inherited from formatter. + template + auto format(DestructorContext c, FormatContext& ctx) { + string_view name = "unknown"; + switch (c) { + case DestructorContext::kEvictedFromRAM: + name = "kEvictedFromRAM"; + break; + case DestructorContext::kEvictedFromNVM: + name = "kEvictedFromNVM"; + break; + case DestructorContext::kRemovedFromRAM: + name = "kRemovedFromRAM"; + break; + case DestructorContext::kRemovedFromNVM: + name = "kRemovedFromNVM"; + break; + } + return formatter::format(name, ctx); + } +}; + namespace facebook::cachelib::cachebench { /* * ItemRecord and ItemRecords are used for DestructorCheck in cachebench.