mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
rename Cache to SharedPromiseCache and make Cache interface
This commit is contained in:
15
js/v3.ts
15
js/v3.ts
@@ -370,11 +370,22 @@ function deserializeIndex(buffer: ArrayBuffer): Entry[] {
|
||||
|
||||
export class VersionMismatch extends Error {}
|
||||
|
||||
export interface Cache {
|
||||
getHeader: (source: Source) => Promise<Header>;
|
||||
getDirectory: (
|
||||
source: Source,
|
||||
offset: number,
|
||||
length: number,
|
||||
header: Header
|
||||
) => Promise<Entry[]>;
|
||||
invalidate: (source: Source) => void;
|
||||
}
|
||||
|
||||
// a "dumb" bag of bytes.
|
||||
// only caches headers and directories
|
||||
// deduplicates simultaneous responses
|
||||
// (estimates) the maximum size of the cache.
|
||||
export class Cache {
|
||||
export class SharedPromiseCache {
|
||||
cache: Map<string, CacheEntry>;
|
||||
sizeBytes: number;
|
||||
maxSizeBytes: number;
|
||||
@@ -526,7 +537,7 @@ export class PMTiles {
|
||||
if (cache) {
|
||||
this.cache = cache;
|
||||
} else {
|
||||
this.cache = new Cache();
|
||||
this.cache = new SharedPromiseCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user