FileManager v1.7.0
Manage access to files with async model
Loading...
Searching...
No Matches
file_manager::Cache Class Reference

Files cache. More...

#include <Cache.h>

Public Types

enum class  CacheResultCodes { noError , fileDoesNotExist , notEnoughCacheSize }
 Result of adding cache. More...
 

Public Member Functions

CacheResultCodes addCache (const std::filesystem::path &filePath, std::ios_base::openmode mode)
 Add cache data.
 
CacheResultCodes appendCache (const std::filesystem::path &filePath, const std::vector< char > &data)
 Append specific cache.
 
CacheResultCodes appendCache (const std::filesystem::path &filePath, std::string_view data)
 Append specific cache.
 
bool contains (const std::filesystem::path &filePath) const
 Check if file data is cached.
 
void clear ()
 Clear all cache.
 
void clear (const std::filesystem::path &filePath)
 Clear cache of specific file.
 
void setCacheSize (uint64_t sizeInBytes)
 Set cache size.
 
const std::string & getCacheData (const std::filesystem::path &filePath) const
 Get cached data.
 
uint64_t getCacheSize () const
 Get global cache size.
 
uint64_t getCurrentCacheSize () const
 Used cache size.
 
const std::string & operator[] (const std::filesystem::path &filePath) const
 Get cached data.
 

Friends

class FileManager
 
void _utility::addCache (std::filesystem::path &&filePath, std::string &&data)
 
template<template< typename > typename OperationT>
requires _utility::Operation<OperationT<uint64_t>>
void _utility::changeCurrentCacheSize (uint64_t amount)
 

Detailed Description

Files cache.

Definition at line 18 of file Cache.h.

Member Enumeration Documentation

◆ CacheResultCodes

Result of adding cache.

Definition at line 22 of file Cache.h.

Member Function Documentation

◆ addCache()

Cache::CacheResultCodes file_manager::Cache::addCache ( const std::filesystem::path & filePath,
std::ios_base::openmode mode )

Add cache data.

Parameters
filePathPath to file
Returns
Error code from Cache::CacheErrorCodes

Definition at line 73 of file Cache.cpp.

◆ appendCache() [1/2]

CacheResultCodes file_manager::Cache::appendCache ( const std::filesystem::path & filePath,
const std::vector< char > & data )

Append specific cache.

Parameters
filePathPath to file
dataCache data
Returns
Error code from Cache::CacheErrorCodes

◆ appendCache() [2/2]

CacheResultCodes file_manager::Cache::appendCache ( const std::filesystem::path & filePath,
std::string_view data )

Append specific cache.

Parameters
filePathPath to file
dataCache data
Returns
Error code from Cache::CacheErrorCodes

◆ clear() [1/2]

void file_manager::Cache::clear ( )

Clear all cache.

Definition at line 135 of file Cache.cpp.

◆ clear() [2/2]

void file_manager::Cache::clear ( const std::filesystem::path & filePath)

Clear cache of specific file.

Parameters
filePathPath to file

◆ contains()

bool file_manager::Cache::contains ( const std::filesystem::path & filePath) const

Check if file data is cached.

Parameters
filePathPath to file
Returns
Returns true if file is already cached

Definition at line 128 of file Cache.cpp.

◆ getCacheData()

const string & file_manager::Cache::getCacheData ( const std::filesystem::path & filePath) const

Get cached data.

Returns
Cached data
Exceptions
FileDoesNotExistException

Definition at line 169 of file Cache.cpp.

◆ getCacheSize()

uint64_t file_manager::Cache::getCacheSize ( ) const

Get global cache size.

Returns
Cache size in bytes

Definition at line 182 of file Cache.cpp.

◆ getCurrentCacheSize()

uint64_t file_manager::Cache::getCurrentCacheSize ( ) const

Used cache size.

Returns
Cache size in bytes

Definition at line 187 of file Cache.cpp.

◆ operator[]()

const string & file_manager::Cache::operator[] ( const std::filesystem::path & filePath) const

Get cached data.

Returns
Cached data
Exceptions
FileDoesNotExistException

Definition at line 192 of file Cache.cpp.

◆ setCacheSize()

void file_manager::Cache::setCacheSize ( uint64_t sizeInBytes)

Set cache size.

Parameters
sizeInBytesSize in bytes

Definition at line 159 of file Cache.cpp.

Friends And Related Symbol Documentation

◆ FileManager

friend class FileManager
friend

Definition at line 108 of file Cache.h.


The documentation for this class was generated from the following files: