6 #ifndef TURI_FILEIO_BLOCK_CACHE_HPP 7 #define TURI_FILEIO_BLOCK_CACHE_HPP 9 #include <core/util/lru.hpp> 10 #include <core/parallel/mutex.hpp> 11 #include <core/storage/fileio/fixed_size_cache_manager.hpp> 14 class general_ifstream;
82 void init(
const std::string& storage_prefix,
83 size_t max_file_handle_cache=16);
96 bool write(
const std::string& key,
const std::string& value);
135 int64_t
read(
const std::string& key,
138 size_t end = (
size_t)(-1)) ;
143 int64_t
read(
const std::string& key,
146 size_t end = (
size_t)(-1)) ;
176 m_cache_provider = instance;
192 static void release_instance();
195 static constexpr
size_t KEY_LOCK_SIZE = 256;
198 bool m_initialized =
false;
202 std::shared_ptr<const fileio::fixed_size_cache_manager> m_cache_provider;
206 std::string m_storage_prefix;
212 std::set<std::string> m_created_files;
215 size_t m_max_capacity = 0;
221 mutex key_lock[KEY_LOCK_SIZE];
int64_t read(const std::string &key, char *output, size_t start=0, size_t end=(size_t)(-1))
int64_t value_length(const std::string &key)
bool write(const std::string &key, const std::string &value)
bool evict_key(const std::string &key)
void init(const std::string &storage_prefix, size_t max_file_handle_cache=16)
static block_cache & get_instance()
~block_cache()
Default destructor. Deletes all associated files.
void set_max_capacity(size_t)
size_t get_max_capacity()
size_t file_handle_cache_misses() const
size_t file_handle_cache_hits() const
void hold_cache_provider(std::shared_ptr< const fileio::fixed_size_cache_manager > instance)