join
1.0
lightweight network framework library
Loading...
Searching...
No Matches
services
include
join
cache.hpp
Go to the documentation of this file.
1
25
#ifndef __JOIN_CACHE_HPP__
26
#define __JOIN_CACHE_HPP__
27
28
// libjoin.
29
#include <
join/mutex.hpp
>
30
31
// C++.
32
#include <string>
33
#include <memory>
34
#include <map>
35
36
// C.
37
#include <sys/stat.h>
38
39
namespace
join
40
{
44
class
Cache
45
{
46
public
:
50
Cache
() =
default
;
51
56
Cache
(
const
Cache
& other) =
delete
;
57
63
Cache
&
operator=
(
const
Cache
& other) =
delete
;
64
69
Cache
(
Cache
&& other) =
delete
;
70
76
Cache
&
operator=
(
Cache
&& other) =
delete
;
77
81
~Cache
();
82
89
void
*
get
(
const
std::string &fileName,
struct
stat &sbuf);
90
95
void
remove
(
const
std::string &fileName);
96
100
void
clear
();
101
105
size_t
size
();
106
107
protected
:
111
struct
CacheEntry
112
{
113
off_t
size
;
114
struct
timespec
modifTime
;
115
void
*
addr
;
116
};
117
119
std::map <std::string, std::unique_ptr <CacheEntry>>
_entries
;
120
122
Mutex
_mutex
;
123
};
124
}
125
126
#endif
join::Cache
File cache.
Definition
cache.hpp:45
join::Cache::Cache
Cache(Cache &&other)=delete
create instance by move.
join::Cache::_mutex
Mutex _mutex
protection mutex for the cache map.
Definition
cache.hpp:122
join::Cache::remove
void remove(const std::string &fileName)
remove a cached entry identified by the given file name.
Definition
cache.cpp:101
join::Cache::operator=
Cache & operator=(const Cache &other)=delete
assign instance by copy.
join::Cache::get
void * get(const std::string &fileName, struct stat &sbuf)
get or create the cache entry for the given file.
Definition
cache.cpp:52
join::Cache::clear
void clear()
clear all cached entries.
Definition
cache.cpp:117
join::Cache::Cache
Cache()=default
create instance.
join::Cache::size
size_t size()
get number of cache entries.
Definition
cache.cpp:133
join::Cache::Cache
Cache(const Cache &other)=delete
create instance by copy.
join::Cache::_entries
std::map< std::string, std::unique_ptr< CacheEntry > > _entries
cached entries map.
Definition
cache.hpp:119
join::Cache::~Cache
~Cache()
destroy instance.
Definition
cache.cpp:43
join::Mutex
class used to protect shared data from being simultaneously accessed by multiple threads.
Definition
mutex.hpp:37
mutex.hpp
join
Definition
acceptor.hpp:32
join::Cache::CacheEntry
cache entry.
Definition
cache.hpp:112
join::Cache::CacheEntry::size
off_t size
Definition
cache.hpp:113
join::Cache::CacheEntry::modifTime
struct timespec modifTime
Definition
cache.hpp:114
join::Cache::CacheEntry::addr
void * addr
Definition
cache.hpp:115
Generated by
1.12.0