diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-09 17:19:27 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-10 15:40:20 -0800 |
commit | db3620c58f0c3351e26b0e3bcfd23ff414f829a1 (patch) | |
tree | e8def564e12307a997270b66a4ed46b68f5e13a4 /platform/linux | |
parent | 591012401072e63b89071787d90bf5ae4362dca1 (diff) | |
download | qtlocation-mapboxgl-db3620c58f0c3351e26b0e3bcfd23ff414f829a1.tar.gz |
[core] Implement an eviction policy for OfflineDatabase
When inserting an cached resource, or removing a region, remove least-recently used resources and tiles, not used by offline regions, until the used database size, as calculated by multiplying the number of in-use pages by the page size, is less than the maximum cache size minus 5 times the page size.
In addition, OfflineDatabase may be configured to ignore cache puts of individual resources larger than a certain size.
This policy is similar but not identical to the former SQLiteCache policy:
* It accounts for offline, by exempting resources required by offline regions from eviction.
* It must delete from two tables (resources and tiles), rather than one. Currently the strategy is naive: evict 50 rows at a time from each table.
* It makes maximumCacheSize and maximumCacheEntrySize completely independent. The SQLiteCache implementation evicted when `usedSize > maximumCacheSize - 2 * maximumCacheEntrySize`. This evicts when `usedSize > maximumCacheSize - 5 * pageSize`.
* It uses a non-unlimited default value for maximumCacheSize: 50 MB. We should have always had a limit in place; "a cache without an eviction policy is a resource leak".
Diffstat (limited to 'platform/linux')
-rw-r--r-- | platform/linux/main.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/platform/linux/main.cpp b/platform/linux/main.cpp index f90b5de849..98fb32075e 100644 --- a/platform/linux/main.cpp +++ b/platform/linux/main.cpp @@ -106,8 +106,6 @@ int main(int argc, char *argv[]) { view = std::make_unique<GLFWView>(fullscreen, benchmark); mbgl::DefaultFileSource fileSource("/tmp/mbgl-cache.db", "."); - fileSource.setMaximumCacheEntrySize(1 * 1024 * 1024); // 1 MB - fileSource.setMaximumCacheSize(50 * 1024 * 1024); // 50 MB // Set access token if present const char *token = getenv("MAPBOX_ACCESS_TOKEN"); |