Skip to content

Commit

Permalink
Allow 0s for maxCacheSize and maxCacheByteSize
Browse files Browse the repository at this point in the history
By allowing 0s for maxCacheSize and maxCacheByteSize, the cache of TileLayer can be disabled.
  • Loading branch information
sraimund authored Sep 13, 2024
1 parent c20af82 commit 6501da8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/geo-layers/src/tileset-2d/tileset-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class Tileset2D {

this.onTileLoad = tile => {
this.opts.onTileLoad?.(tile);
if (this.opts.maxCacheByteSize) {
if (this.opts.maxCacheByteSize != null) {
this._cacheByteSize += tile.byteLength;
this._resizeCache();
}
Expand Down Expand Up @@ -469,10 +469,10 @@ export class Tileset2D {
const {_cache, opts} = this;

const maxCacheSize =
opts.maxCacheSize ||
opts.maxCacheSize ??
// @ts-expect-error called only when selectedTiles is initialized
(opts.maxCacheByteSize ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
const maxCacheByteSize = opts.maxCacheByteSize || Infinity;
const maxCacheByteSize = opts.maxCacheByteSize ?? Infinity;

const overflown = _cache.size > maxCacheSize || this._cacheByteSize > maxCacheByteSize;

Expand Down

0 comments on commit 6501da8

Please sign in to comment.