join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Cache Class Reference

File cache. More...

#include <cache.hpp>

Collaboration diagram for join::Cache:

Classes

struct  CacheEntry
 cache entry. More...
 

Public Member Functions

 Cache ()=default
 create instance.
 
 Cache (const Cache &other)=delete
 create instance by copy.
 
Cacheoperator= (const Cache &other)=delete
 assign instance by copy.
 
 Cache (Cache &&other)=delete
 create instance by move.
 
Cacheoperator= (Cache &&other)=delete
 assign instance by move.
 
 ~Cache ()
 destroy instance.
 
void * get (const std::string &fileName, struct stat &sbuf)
 get or create the cache entry for the given file.
 
void remove (const std::string &fileName)
 remove a cached entry identified by the given file name.
 
void clear ()
 clear all cached entries.
 
size_t size ()
 get number of cache entries.
 

Protected Attributes

std::map< std::string, std::unique_ptr< CacheEntry > > _entries
 cached entries map.
 
Mutex _mutex
 protection mutex for the cache map.
 

Detailed Description

File cache.

Constructor & Destructor Documentation

◆ Cache() [1/3]

join::Cache::Cache ( )
default

create instance.

◆ Cache() [2/3]

join::Cache::Cache ( const Cache & other)
delete

create instance by copy.

Parameters
otherobject to copy.

◆ Cache() [3/3]

join::Cache::Cache ( Cache && other)
delete

create instance by move.

Parameters
otherobject to move.

◆ ~Cache()

Cache::~Cache ( )

destroy instance.

Member Function Documentation

◆ clear()

void Cache::clear ( )

clear all cached entries.

◆ get()

void * Cache::get ( const std::string & fileName,
struct stat & sbuf )

get or create the cache entry for the given file.

Parameters
fileNamepath of the file that we want to get cache.
sbuffile stat.
Returns
a pointer to the buffer where the cached file is saved.

◆ operator=() [1/2]

Cache & join::Cache::operator= ( Cache && other)
delete

assign instance by move.

Parameters
otherobject to move.
Returns
a reference of the current object.

◆ operator=() [2/2]

Cache & join::Cache::operator= ( const Cache & other)
delete

assign instance by copy.

Parameters
otherobject to copy.
Returns
a reference of the current object.

◆ remove()

void Cache::remove ( const std::string & fileName)

remove a cached entry identified by the given file name.

Parameters
fileNamepath of the file that we want to remove cache entry.

◆ size()

size_t Cache::size ( )

get number of cache entries.

Member Data Documentation

◆ _entries

std::map<std::string, std::unique_ptr <CacheEntry> > join::Cache::_entries
protected

cached entries map.

◆ _mutex

Mutex join::Cache::_mutex
protected

protection mutex for the cache map.


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