async _forceRefresh(key, staleItem, updateFn, opts) {
    try {
      const value = await updateFn(key, staleItem && staleItem.value);
      const cacheItem = {
        value,
        expiry: Date.now() + getValue(opts, 'maxAge', this._maxAge)
      };
      const shouldCache = getValue(opts, 'shouldCache', this.shouldCache);
      if (typeof shouldCache !== 'function') {
        throw new TypeError('shouldCache has to be a function');
      }
      // Given that we are not ignoring this value, perform an out-of-band cache update
      if (shouldCache(cacheItem.value)) {
        // NB: an in-band update would `await` this Promise.all block
        Promise.all(this._caches.map(cache => cache.set(key, cacheItem))).catch(err => {
          throw new Error(`Error caching ${key}`, err);
        }).then(() => {
          delete this._pendingRefreshes[key];
        });
      } else {
        // just delete this right away because we're never caching the item
        delete this._pendingRefreshes[key];
      }
      return value;
    } catch (err) {
      delete this._pendingRefreshes[key];
      throw err;
    }
  }
/**
   * Refresh the cache for a given key value pair. Pending refreshes are ignored.
   *
   * @param {String} key cache key
   * @param {JSONSerializable} staleItem cache value
   * @param {UpdateFn} updateFn async function that defines how to get a new value
   * @param {Object} opts An options object
   * @param {ShouldCache} [opts.shouldCache] Function that determines whether or not we should cache the item
   * @param {Number} [opts.maxAge] The duration, in milliseconds, before a cached item expires
   *
   * @private
   * @async
   * @returns {Promise<any>} a promise that resolves once we have refreshed the correct key
   */
Refresh the cache for a given key value pair. Pending refreshes are ignored.

@private
@async
@returns {Promise} a promise that resolves once we have refreshed the correct key
Refresh the cache for a given key value pair . Pending refreshes are ignored . @private @async @returns { Promise } a promise that resolves once we have refreshed the correct key
async _forceRefresh(key, staleItem, updateFn, opts) {
    try {
      const value = await updateFn(key, staleItem && staleItem.value);
      const cacheItem = {
        value,
        expiry: Date.now() + getValue(opts, 'maxAge', this._maxAge)
      };
      const shouldCache = getValue(opts, 'shouldCache', this.shouldCache);
      if (typeof shouldCache !== 'function') {
        throw new TypeError('shouldCache has to be a function');
      }
      if (shouldCache(cacheItem.value)) {
        Promise.all(this._caches.map(cache => cache.set(key, cacheItem))).catch(err => {
          throw new Error(`Error caching ${key}`, err);
        }).then(() => {
          delete this._pendingRefreshes[key];
        });
      } else {
        delete this._pendingRefreshes[key];
      }
      return value;
    } catch (err) {
      delete this._pendingRefreshes[key];
      throw err;
    }
  }
async _forceRefresh ( key , staleItem , updateFn , opts ) { try { const value = await updateFn ( key , staleItem && staleItem . value ) ; const cacheItem = { value , expiry : Date . now ( ) + getValue ( opts , 'maxAge' , this . _maxAge ) } ; const shouldCache = getValue ( opts , 'shouldCache' , this . shouldCache ) ; if ( typeof shouldCache !== 'function' ) { throw new TypeError ( 'shouldCache has to be a function' ) ; } if ( shouldCache ( cacheItem . value ) ) { Promise . all ( this . _caches . map ( cache => cache . set ( key , cacheItem ) ) ) . catch ( err => { throw new Error ( ` ${ key } ` , err ) ; } ) . then ( ( ) => { delete this . _pendingRefreshes [ key ] ; } ) ; } else { delete this . _pendingRefreshes [ key ] ; } return value ; } catch ( err ) { delete this . _pendingRefreshes [ key ] ; throw err ; } }
Refresh the cache for a given key value pair.
Refresh the cache for a given key value pair .
// Given that we are not ignoring this value, perform an out-of-band cache update // NB: an in-band update would `await` this Promise.all block // just delete this right away because we're never caching the item