ClickHouse/src/Common/FileCacheFactory.h

30 lines
616 B
C++
Raw Normal View History

2022-01-13 11:57:56 +00:00
#pragma once
#include <Common/FileCache_fwd.h>
2022-01-13 11:57:56 +00:00
#include <boost/noncopyable.hpp>
#include <unordered_map>
#include <mutex>
2022-01-13 11:57:56 +00:00
namespace DB
{
/**
* Creates a FileCache object for cache_base_path.
*/
class FileCacheFactory final : private boost::noncopyable
{
public:
static FileCacheFactory & instance();
FileCachePtr getOrCreate(const std::string & cache_base_path, const FileCacheSettings & file_cache_settings);
2022-01-13 11:57:56 +00:00
private:
FileCachePtr getImpl(const std::string & cache_base_path, std::lock_guard<std::mutex> &);
std::mutex mutex;
std::unordered_map<std::string, FileCachePtr> caches;
};
}