#include <thread>
#include <unordered_map>
+#include "cache/fast_lru_cache.h"
#include "db/db_impl/db_impl.h"
#include "db/malloc_stats.h"
#include "db/version_set.h"
"If > 0.0, we also enable "
"cache_index_and_filter_blocks_with_high_priority.");
-DEFINE_bool(use_clock_cache, false,
- "Replace default LRU block cache with clock cache.");
+DEFINE_string(cache_type, "lru_cache", "Type of block cache.");
DEFINE_bool(use_compressed_secondary_cache, false,
"Use the CompressedSecondaryCache as the secondary cache.");
if (capacity <= 0) {
return nullptr;
}
- if (FLAGS_use_clock_cache) {
+ if (FLAGS_cache_type == "clock_cache") {
auto cache = NewClockCache(static_cast<size_t>(capacity),
FLAGS_cache_numshardbits);
if (!cache) {
exit(1);
}
return cache;
- } else {
+ } else if (FLAGS_cache_type == "fast_lru_cache") {
+ return NewFastLRUCache(static_cast<size_t>(capacity),
+ FLAGS_cache_numshardbits);
+ } else if (FLAGS_cache_type == "lru_cache") {
LRUCacheOptions opts(
static_cast<size_t>(capacity), FLAGS_cache_numshardbits,
false /*strict_capacity_limit*/, FLAGS_cache_high_pri_pool_ratio,
}
return NewLRUCache(opts);
+ } else {
+ fprintf(stderr, "Cache type not supported.");
+ exit(1);
}
}