Class: RecoverablePromiseCache

bemap.RecoverablePromiseCache(maxCacheEntriesopt, prefetchopt)

new RecoverablePromiseCache(maxCacheEntriesopt, prefetchopt)

BeNomad BeMap JavaScript API — RecoverablePromiseCache (v2.0) A drop-in replacement for pmtiles' `SharedPromiseCache` that FIXES the permanent-hole bug: the stock cache stores the header/directory *promise* and, when that promise REJECTS (a timeout / network blip / aborted read), leaves the rejected promise cached forever. Every dependent tile then awaits that cached rejection → a blank region until a full page reload. (`invalidate()` only runs on an `EtagMismatch`, never on a timeout/error.) This wrapper evicts a cache entry as soon as its promise rejects, so the NEXT read re-fetches instead of replaying the failure — self-healing without a reload. It is **transparent**: success, in-flight de-duplication, LRU pruning and `invalidate()` are all inherited unchanged (it delegates to a real `SharedPromiseCache`); the ONLY behavioural change is on a *failed* read. Composition (not subclassing) is deliberate: the bundled `pmtiles` is an ES6 UMD build whose `SharedPromiseCache` is an ES6 `class`, which cannot be `Function.apply`-ed for the ES5 subclass pattern this codebase uses. Composing a Cache-shaped object that delegates to an internal `SharedPromiseCache` (and deletes its internal entry on reject) is the portable, spec-matching form. Wire it via `new pmtiles.PMTiles(archiveUrl, new bemap.RecoverablePromiseCache())` + `protocol.add(...)` (see `bemap.MapLibreMap` — gated on `opts.recoverableCache`, default on). `bemap.MapLibreMap` does this automatically for the tiles archive.
Parameters:
Name Type Attributes Default Description
maxCacheEntries Number <optional>
Forwarded to `SharedPromiseCache` (default its own default, currently 100). Optional — omit for stock sizing.
prefetch Boolean <optional>
true Forwarded to `SharedPromiseCache`.
Since:
  • 2.0.0
Source:

Members

(static) enabled :Boolean

Page-level default for whether `bemap.MapLibreMap` wires this recoverable cache into the pmtiles archive. `true` (self-healing) by default; `bemap.MapLibreMap`'s `opts.recoverableCache: false` sets it to `false`, in which case pmtiles uses its stock (poisoning) `SharedPromiseCache`. Mirrors `bemap.RangeFetchPolicy.defaultMode`.
Type:
  • Boolean
Since:
  • 2.0.0
Source:

Methods

getDirectory() → {Promise}

Source:
Returns:
the directory promise; evicted from cache if it rejects.
Type
Promise

getHeader(source) → {Promise}

Parameters:
Name Type Description
source Object pmtiles `Source` (has `getKey()` + `getBytes()`).
Source:
Returns:
the header promise; evicted from cache if it rejects.
Type
Promise

invalidate()

Delegate: invalidate an entry on `EtagMismatch` (inherited behaviour). @public
Source:

prune()

Delegate: LRU prune (inherited behaviour). @public
Source: