summaryrefslogtreecommitdiff
path: root/platform/default/sqlite_cache_impl.hpp
blob: f557666e3f18e73dd40b5d1639fec9ebf6a35788 (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
#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 get(const Resource&, Callback);
    void put(const Resource& resource, std::shared_ptr<const Response> response);
    void refresh(const Resource& resource, Seconds expires);

private:
    void createDatabase();
    void createSchema();

    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;
    bool schema = false;
};


}

#endif