core: ambient cache for pmtile sources (#4290)

This commit is contained in:
twopastmidnight
2026-06-06 21:10:10 +02:00
committed by GitHub
parent 1b6ed35426
commit a2eb4409aa
7 changed files with 126 additions and 14 deletions

View File

@@ -396,6 +396,22 @@ TEST(OfflineDatabase, PutTile) {
EXPECT_EQ(0u, log.uncheckedCount());
}
// Cache-key encoding for byte-range sources (eg. PMTiles). The range is appended
// to the URL so distinct ranges occupy distinct cache rows under the resources
// table's UNIQUE(url) constraint.
TEST(OfflineDatabase, CacheKey) {
Resource bare{Resource::Kind::Source, "https://example.com/x.pmtiles"};
EXPECT_EQ("https://example.com/x.pmtiles", OfflineDatabase::cacheKey(bare));
Resource ranged{Resource::Kind::Source, "https://example.com/x.pmtiles"};
ranged.dataRange = std::make_pair<uint64_t, uint64_t>(0, 126);
EXPECT_EQ("https://example.com/x.pmtiles?_mlnRange=0-126", OfflineDatabase::cacheKey(ranged));
Resource rangedWithQuery{Resource::Kind::Source, "https://example.com/x.pmtiles?token=abc"};
rangedWithQuery.dataRange = std::make_pair<uint64_t, uint64_t>(200, 399);
EXPECT_EQ("https://example.com/x.pmtiles?token=abc&_mlnRange=200-399", OfflineDatabase::cacheKey(rangedWithQuery));
}
TEST(OfflineDatabase, PutResourceNoContent) {
FixtureLog log;
OfflineDatabase db(":memory:", fixture::tileServerOptions);