BuildCache
remote_cache.hpp
1 //--------------------------------------------------------------------------------------------------
2 // Copyright (c) 2019 Marcus Geelnard
3 //
4 // This software is provided 'as-is', without any express or implied warranty. In no event will the
5 // authors be held liable for any damages arising from the use of this software.
6 //
7 // Permission is granted to anyone to use this software for any purpose, including commercial
8 // applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 //
10 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote
11 // the original software. If you use this software in a product, an acknowledgment in the
12 // product documentation would be appreciated but is not required.
13 //
14 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
15 // being the original software.
16 //
17 // 3. This notice may not be removed or altered from any source distribution.
18 //--------------------------------------------------------------------------------------------------
19 
20 #ifndef BUILDCACHE_REMOTE_CACHE_HPP_
21 #define BUILDCACHE_REMOTE_CACHE_HPP_
22 
23 #include <cache/cache_entry.hpp>
24 #include <cache/expected_file.hpp>
25 #include <cache/remote_cache_provider.hpp>
26 
27 #include <string>
28 
29 namespace bcache {
30 
32 public:
35  }
36 
39 
42  bool connect();
43 
46  bool is_connected() const;
47 
51  cache_entry_t lookup(const std::string& hash);
52 
58  void add(const std::string& hash,
59  const cache_entry_t& entry,
60  const std::map<std::string, expected_file_t>& expected_files);
61 
67  void get_file(const std::string& hash,
68  const std::string& source_id,
69  const std::string& target_path,
70  const bool is_compressed);
71 
72 private:
73  remote_cache_provider_t* m_provider = nullptr;
74 };
75 
76 } // namespace bcache
77 
78 #endif // BUILDCACHE_REMOTE_CACHE_HPP_
bcache::remote_cache_provider_t
Definition: remote_cache_provider.hpp:31
bcache::remote_cache_t::remote_cache_t
remote_cache_t()
Initialize the remote cache object.
Definition: remote_cache.hpp:34
bcache
The top level namespace.
Definition: compressor.cpp:34
bcache::remote_cache_t::is_connected
bool is_connected() const
Check if we have a connection to the remote cache.
Definition: remote_cache.cpp:91
bcache::remote_cache_t::lookup
cache_entry_t lookup(const std::string &hash)
Check if an entry exists in the cache.
Definition: remote_cache.cpp:95
bcache::remote_cache_t::~remote_cache_t
~remote_cache_t()
De-initialzie the remote cache object.
Definition: remote_cache.cpp:55
bcache::remote_cache_t::add
void add(const std::string &hash, const cache_entry_t &entry, const std::map< std::string, expected_file_t > &expected_files)
Adds a set of files to the cache.
Definition: remote_cache.cpp:102
bcache::remote_cache_t::connect
bool connect()
Connect to the remote cache.
Definition: remote_cache.cpp:59
bcache::remote_cache_t::get_file
void get_file(const std::string &hash, const std::string &source_id, const std::string &target_path, const bool is_compressed)
Copy a cached file to the local file system.
Definition: remote_cache.cpp:114
bcache::remote_cache_t
Definition: remote_cache.hpp:31
bcache::cache_entry_t
Meta data for a single cache entry.
Definition: cache_entry.hpp:28