diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-09-15 17:26:44 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-09-24 16:14:09 +0200 |
commit | d9fc7708a2dfb6e2506a5d10d896a813557c056d (patch) | |
tree | 50b2dba9e0a8766c88f7c276a8f71742a06a1d67 /include/mbgl/storage/sqlite_store.hpp | |
parent | 062e911c6d570a794431023f9f0cb0b02cd85667 (diff) | |
download | qtlocation-mapboxgl-d9fc7708a2dfb6e2506a5d10d896a813557c056d.tar.gz |
do 304 requests and cache them in sqlite
Diffstat (limited to 'include/mbgl/storage/sqlite_store.hpp')
-rw-r--r-- | include/mbgl/storage/sqlite_store.hpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/mbgl/storage/sqlite_store.hpp b/include/mbgl/storage/sqlite_store.hpp new file mode 100644 index 0000000000..e03e6cf2bc --- /dev/null +++ b/include/mbgl/storage/sqlite_store.hpp @@ -0,0 +1,47 @@ +#ifndef MBGL_STORAGE_SQLITE_STORE +#define MBGL_STORAGE_SQLITE_STORE + +#include <mbgl/storage/file_source.hpp> +#include <mbgl/storage/response.hpp> + +#include <uv.h> + +#include <string> + +typedef struct uv_worker_s uv_worker_t; + +namespace mapbox { +namespace sqlite { +class Database; +} +} + +namespace mbgl { + +class SQLiteStore { +public: + SQLiteStore(uv_loop_t *loop, const std::string &path); + ~SQLiteStore(); + + typedef void (*GetCallback)(std::unique_ptr<Response> &&entry, void *ptr); + + void get(const std::string &path, GetCallback cb, void *ptr); + void put(const std::string &path, ResourceType type, const Response &entry); + void updateExpiration(const std::string &path, int64_t expires); + +private: + void createSchema(); + void closeDatabase(); + static void runGet(uv_work_t *req); + static void runPut(uv_work_t *req); + static void deliverResult(uv_work_t *req, int status); + +private: + const unsigned long thread_id; + std::shared_ptr<mapbox::sqlite::Database> db; + uv_worker_t *worker = nullptr; +}; + +} + +#endif |