20 #ifndef BUILDCACHE_LOCAL_CACHE_HPP_
21 #define BUILDCACHE_LOCAL_CACHE_HPP_
23 #include <base/file_lock.hpp>
24 #include <base/file_utils.hpp>
25 #include <cache/cache_entry.hpp>
26 #include <cache/cache_stats.hpp>
27 #include <cache/direct_mode_manifest.hpp>
28 #include <cache/expected_file.hpp>
70 void add(
const std::string& hash,
72 const std::map<std::string, expected_file_t>& expected_files,
73 const bool allow_hard_links);
79 std::pair<cache_entry_t, file::file_lock_t>
lookup(
const std::string& hash);
87 void get_file(
const std::string& hash,
88 const std::string& source_id,
89 const std::string& target_path,
90 const bool is_compressed,
91 const bool allow_hard_links);
102 std::string hash_to_cache_entry_path(
const std::string& hash)
const;
103 std::string get_cache_files_folder()
const;
105 void perform_housekeeping();
110 #endif // BUILDCACHE_LOCAL_CACHE_HPP_
void show_stats()
Show cache statistics (print to standard out).
Definition: local_cache.cpp:244
void clear()
Clear all entries in the cache.
Definition: local_cache.cpp:213
std::pair< cache_entry_t, file::file_lock_t > lookup(const std::string &hash)
Check if an entry exists in the cache.
Definition: local_cache.cpp:427
The top level namespace.
Definition: compressor.cpp:34
direct_mode_manifest_t lookup_direct(const std::string &direct_hash)
Check if a direct mode entry exists in the cache.
Definition: local_cache.cpp:341
A direct mode cache manifest.
Definition: direct_mode_manifest.hpp:28
void get_file(const std::string &hash, const std::string &source_id, const std::string &target_path, const bool is_compressed, const bool allow_hard_links)
Copy a cached file to the local file system.
Definition: local_cache.cpp:489
local_cache_t()
Initialize the cache object.
Definition: local_cache.cpp:195
~local_cache_t()
De-initialzie the cache object.
Definition: local_cache.cpp:199
bool update_stats(const std::string &hash, const cache_stats_t &delta) const noexcept
Update statistics associated with the given entry.
Definition: local_cache.cpp:458
Definition: cache_stats.hpp:29
Definition: local_cache.hpp:36
void add(const std::string &hash, const cache_entry_t &entry, const std::map< std::string, expected_file_t > &expected_files, const bool allow_hard_links)
Add a set of files to the cache.
Definition: local_cache.cpp:381
void add_direct(const std::string &direct_hash, const direct_mode_manifest_t &manifest)
Add a new direct mode entry to the cache.
Definition: local_cache.cpp:308
Meta data for a single cache entry.
Definition: cache_entry.hpp:28
void zero_stats()
Clear the cache statistics.
Definition: local_cache.cpp:290