|
TINC
Toolkit for Interactive Computation
|
The CacheManager class is in charge of data caching and cache metadata. More...
#include <CacheManager.hpp>
Public Member Functions | |
| CacheManager (DistributedPath cachePath=DistributedPath("tinc_cache.json")) | |
| void | appendEntry (CacheEntry &entry) |
| append cache entry More... | |
| std::vector< CacheEntry > | entries (size_t count=0) |
| Get all in memory entries. More... | |
| std::vector< std::string > | findCache (const SourceInfo &sourceInfo, bool validateFile=true) |
| Find files for SourceInfo. More... | |
| void | clearCache () |
| Clear all cached files, and cache information. More... | |
| std::string | cacheDirectory () |
| Get full cache path. More... | |
| DistributedPath | getDistributedPath () |
| Get current DistributedPath. More... | |
| void | updateFromDisk () |
| Read and validate cache file from disk. More... | |
| void | writeToDisk () |
| Write the current in memory cache to disk. More... | |
| std::string | dump () |
| Read cache metadata. More... | |
Static Public Member Functions | |
| static int32_t | computeCrc32 (std::string filename) |
| compute CRC32 for file More... | |
Static Protected Member Functions | |
| static void | tincSchemaFormatChecker (const std::string &format, const std::string &value) |
Protected Attributes | |
| DistributedPath | mCachePath |
| std::mutex | mCacheLock |
| std::vector< CacheEntry > | mEntries |
| nlohmann::json_schema::json_validator | mValidator |
The CacheManager class is in charge of data caching and cache metadata.
This class copies and renames files into the cache directory, keeping a metadata json file tracking the source of the data including information on how it was produced. The metadata follows the json schema defined in tinc/doc/tinc_cache_schema.json
Definition at line 116 of file CacheManager.hpp.
| tinc::CacheManager::CacheManager | ( | DistributedPath | cachePath = DistributedPath("tinc_cache.json") | ) |
| void tinc::CacheManager::appendEntry | ( | CacheEntry & | entry | ) |
append cache entry
| the | CacheEntry entry |
| std::string tinc::CacheManager::cacheDirectory | ( | ) |
Get full cache path.
| void tinc::CacheManager::clearCache | ( | ) |
Clear all cached files, and cache information.
Although this function will only delete files listed in the cache file, it should be used with caution.
|
static |
compute CRC32 for file
| filename |
| std::string tinc::CacheManager::dump | ( | ) |
Read cache metadata.
| std::vector<CacheEntry> tinc::CacheManager::entries | ( | size_t | count = 0 | ) |
Get all in memory entries.
| count | Number of most recent entries to get |
If count is 0, or greater than the number of entries, all the entries are returned.
| std::vector<std::string> tinc::CacheManager::findCache | ( | const SourceInfo & | sourceInfo, |
| bool | validateFile = true |
||
| ) |
Find files for SourceInfo.
| sourceInfo | details for files to find |
| validateFile | validate file details against details in sourceInfo |
| DistributedPath tinc::CacheManager::getDistributedPath | ( | ) |
Get current DistributedPath.
|
staticprotected |
| void tinc::CacheManager::updateFromDisk | ( | ) |
Read and validate cache file from disk.
This replaces the current in memory cache, so make sure you call writeToDisk() first if you want to store in memory cache.
| void tinc::CacheManager::writeToDisk | ( | ) |
Write the current in memory cache to disk.
This will overwrite the cache metadata file on disk
|
protected |
Definition at line 195 of file CacheManager.hpp.
|
protected |
Definition at line 194 of file CacheManager.hpp.
|
protected |
Definition at line 198 of file CacheManager.hpp.
|
protected |
Definition at line 204 of file CacheManager.hpp.