Commit Graph

8 Commits

Author SHA1 Message Date
John Firebaugh
db3620c58f [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".
2016-02-10 15:40:20 -08:00
John Firebaugh
5910124010 [core] Reset SQLite statements after use in order to release locks 2016-02-10 15:40:20 -08:00
John Firebaugh
96e0e5252e [core] Disable SQLite busy timeouts so that multiple readers can access the same database 2016-02-10 15:40:20 -08:00
John Firebaugh
4bde1b0c88 [core] Explicit operator bool 2016-02-10 15:40:20 -08:00
John Firebaugh
c3c4c7b9a6 [core] Interface and implementation for offline 2016-02-10 15:40:20 -08:00
John Firebaugh
dbfa932ed1 [core] Eliminate macros in sqlite3.cpp 2016-01-19 13:39:18 -08:00
Konstantin Käfer
c279fb1717 [core] throw values, catch references 2015-12-03 15:38:36 +01:00
Konstantin Käfer
272fa8935e make storage lib separate so we can build without storage libs 2015-02-04 10:49:07 +01:00