replaceCache(options) {
            const victimKey = options.victimKey,
                consumerKey = options.consumerKey,
                victim = this._cachesLoaded[victimKey],
                tile = options.tile;
            if (!victim || (!options.tileAllowNotLoaded && !tile.loaded && !tile.loading)) {
                $.console.warn("Attempt to consume cache on tile in invalid state: this is probably a bug!");
                return;
            }
            const consumer = this._cachesLoaded[consumerKey];
            if (consumer) {
                // We need to avoid async execution here: replace consumer instead of overwriting the data.
                const iterateTiles = [...consumer._tiles];  // unloadCacheForTile() will modify the array, use a copy
                for (let tile of iterateTiles) {
                    this.unloadCacheForTile(tile, consumerKey, true, false);
                }
            }
            if (this._cachesLoaded[consumerKey]) {
                $.console.error("The consume routine should've freed cache!");
            }
            // Just swap victim to become new consumer
            const resultCache = this.renameCache({
                oldCacheKey: victimKey,
                newCacheKey: consumerKey
            });

            if (resultCache) {
                // Only one cache got working item, other caches were idle: update cache: add the new cache
                // we must add since we removed above with unloadCacheForTile()
                for (let t of tile.getCache(tile.originalCacheKey)._tiles) {  // grab all cache-equal tiles
                    t.setCache(consumerKey, resultCache, options.setAsMainCache, false);
                }
            }
        }
Replace cache (and update tile references) by another cache
@param {Object} options
@param {OpenSeadragon.Tile} options.tile - The tile to own ot add record for the cache.
@param {String} options.victimKey - Cache that will be erased. In fact, the victim _replaces_ consumer,
  inheriting its tiles and key.
@param {String} options.consumerKey - The cache that consumes the victim. In fact, it gets destroyed and
  replaced by victim, which inherits all its metadata.
@param {Boolean} options.setAsMainCache - If true, tiles main cache gets updated to consumerKey.
  Otherwise, if consumerKey==tile.cacheKey the cache is set as main too.
@param {Boolean} options.tileAllowNotLoaded - if true, tile that is not loaded is also processed,
  this is internal parameter used in tile-loaded completion routine, as we need to prepare tile but
  it is not yet loaded and cannot be marked as so (otherwise the system would think it is ready)
@private