-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileCache.h
More file actions
46 lines (35 loc) · 777 Bytes
/
Copy pathFileCache.h
File metadata and controls
46 lines (35 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <string>
#include <unordered_map>
#include <mutex>
#include <ctime>
class FileCache
{
public:
struct CacheEntry
{
// Original file
std::string body;
// Pre-compressed version
std::string gzipBody;
// Metadata
std::string mimeType;
std::string etag;
std::string lastModified;
// File information
long long fileSize = 0;
std::time_t modifiedTime = 0;
};
// Returns the complete cached entry
static CacheEntry get(
const std::string& path
);
// Remove everything from cache
static void clear();
private:
static std::unordered_map<
std::string,
CacheEntry
> cache;
static std::mutex mutex;
};