The Cachier class.
More...
#include <cachier.h>
◆ Cachier()
Cachier::Cachier |
( |
const std::string & |
cache_store_path, |
|
|
bool |
ensure_cache_store_path = true |
|
) |
| |
|
inline |
Cachier.
Instantiate Cachier object using provided cache store path.
- Parameters
-
cache_store_path | The directory path where cache will be stored. |
ensure_cache_store_path | Try to create cache store path during cachier object instantiation, default true. |
◆ addCache()
HashResult Cachier::addCache |
( |
const std::string & |
filename, |
|
|
const std::string & |
content = "" , |
|
|
const CacheOverwriteOption & |
cache_overwrite_option = DONT_OVERWRITE_CACHE |
|
) |
| |
|
inline |
addCache
Compute HashResult
for file and create a cache entry with given content in cache_store_path.
- Parameters
-
- Returns
- The computed
HashResult
object.
◆ cacheExists() [1/2]
bool Cachier::cacheExists |
( |
const std::size_t & |
key | ) |
|
|
inline |
cacheExists
Return whether cache exists for the given hash key.
- Parameters
-
The | hash key for cache entry. |
- Returns
- True if cache exists for provided key, false otherwise.
◆ cacheExists() [2/2]
bool Cachier::cacheExists |
( |
const std::string & |
filename | ) |
|
|
inline |
cacheExists
Retunrs whether cache exists for the given filename. Computes hash using file data and look for a file entry in cache_store_path, return true if cache entry found indicating file is cached, otherwise false.
- Parameters
-
filename | The filename for which cache presense is being checked. |
- Returns
- True if file exists in cache store path.
◆ computeHash()
HashResult Cachier::computeHash |
( |
const std::string & |
filename | ) |
|
|
inline |
computeHash
Return a HashResult
object containing computed hash from file data and error if any, The hash is computed using these file stats:
- File name
- File size
- Last modification time
- First 8 bytes of file aka. file header info.
- Parameters
-
filename | The File path for which the hash to be computed. |
- Returns
- The computed
HashResult
object.
◆ getContent()
std::string Cachier::getContent |
( |
const std::string & |
key | ) |
|
|
inline |
getContent
Returns data stored in cache for provided key.
- Parameters
-
key | The hash key to use to get content. |
- Returns
- The content string stored with key.
◆ isInitialized()
bool Cachier::isInitialized |
( |
| ) |
|
|
inline |
isInitialized
Returns the state of library initialization.
- Returns
- True if initialized, false otherwise.
The documentation for this class was generated from the following file: