[core] Make it possible to limit the size of the SQLite cache
This commit is contained in:
@@ -18,23 +18,47 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user