blob: 94eeee3d464967b46d6ac268aad663e50c8791ec (
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
|
#ifndef MBGL_STORAGE_DEFAULT_SQLITE_CACHE
#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/chrono.hpp>
#include <functional>
#include <memory>
#include <string>
namespace mbgl {
struct Resource;
class Response;
class WorkRequest;
namespace util {
template <typename T> class Thread;
} // namespace util
class SQLiteCache : private util::noncopyable {
public:
SQLiteCache(const std::string &path = ":memory:");
~SQLiteCache();
void setMaximumCacheSize(uint64_t size);
void setMaximumCacheEntrySize(uint64_t size);
using Callback = std::function<void(std::unique_ptr<Response>)>;
std::unique_ptr<WorkRequest> get(const Resource&, Callback);
void put(const Resource&, const Response&);
class Impl;
private:
const std::unique_ptr<util::Thread<Impl>> thread;
};
class SharedSQLiteCache : util::noncopyable {
public:
static std::shared_ptr<SQLiteCache> get(const std::string &path = ":memory:");
private:
SharedSQLiteCache() {}
static std::weak_ptr<SQLiteCache> masterPtr;
};
} // namespace mbgl
#endif
|