blob: be2db5df432fdb29262d02fe8e6ea14bec5a0e7b (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#ifndef MBGL_STORAGE_DEFAULT_SQLITE_CACHE_IMPL
#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE_IMPL
#include <mbgl/storage/sqlite_cache.hpp>
#include <mbgl/util/chrono.hpp>
namespace mapbox {
namespace sqlite {
class Database;
class Statement;
}
}
namespace mbgl {
class SQLiteCache::Impl {
public:
explicit Impl(const std::string &path = ":memory:");
~Impl();
void setMaximumCacheSize(uint64_t size);
void setMaximumCacheEntrySize(uint64_t size);
void get(const Resource&, Callback);
void put(const Resource& resource, std::shared_ptr<const Response> response);
void refresh(const Resource& resource, Seconds expires);
private:
void initializeDatabase();
int cachePageSize();
uint64_t cacheHardSize();
uint64_t cacheSoftSize();
uint64_t softSize = 0;
bool softSizeDirty = true;
bool needsPruning();
void pruneEntries();
void createDatabase();
void createSchema();
int pageSize = 0;
uint64_t maximumCacheSize;
uint64_t maximumCacheEntrySize;
const std::string path;
std::unique_ptr<::mapbox::sqlite::Database> db;
std::unique_ptr<::mapbox::sqlite::Statement> getStmt;
std::unique_ptr<::mapbox::sqlite::Statement> putStmt;
std::unique_ptr<::mapbox::sqlite::Statement> refreshStmt;
std::unique_ptr<::mapbox::sqlite::Statement> countStmt;
std::unique_ptr<::mapbox::sqlite::Statement> freeStmt;
std::unique_ptr<::mapbox::sqlite::Statement> pruneStmt;
std::unique_ptr<::mapbox::sqlite::Statement> accessedStmt;
bool schema = false;
};
} // namespace mbgl
#endif
|