summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/sqlite_cache.hpp
blob: 4b51d94920c8d77aff472aaa8c3900d8a34ecca9 (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
#ifndef MBGL_STORAGE_DEFAULT_SQLITE_CACHE
#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE

#include <mbgl/storage/file_cache.hpp>

#include <string>

namespace mbgl {

namespace util {
template <typename T> class Thread;
} // namespace util

class SQLiteCache : public FileCache {
public:
    SQLiteCache(const std::string &path = ":memory:");
    ~SQLiteCache() override;

    // FileCache API
    std::unique_ptr<WorkRequest> get(const Resource &resource, Callback callback) override;
    void put(const Resource &resource, std::shared_ptr<const Response> response, Hint hint) override;

    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