#pragma once #include #include #include #include #include namespace DB { /** * Creates a FileCache object for cache_base_path. */ class FileCacheFactory final : private boost::noncopyable { struct CacheData { FileCachePtr cache; FileCacheSettings settings; CacheData(FileCachePtr cache_, const FileCacheSettings & settings_) : cache(cache_), settings(settings_) {} }; using CacheByBasePath = std::unordered_map; public: static FileCacheFactory & instance(); FileCachePtr getOrCreate(const std::string & cache_base_path, const FileCacheSettings & file_cache_settings); FileCachePtr get(const std::string & cache_base_path); CacheByBasePath getAll(); const FileCacheSettings & getSettings(const std::string & cache_base_path); private: CacheData * getImpl(const std::string & cache_base_path, std::lock_guard &); std::mutex mutex; CacheByBasePath caches; }; }