packages/data-point-service/lib/revalidation-store.js
function clear (store) {
  const forDeletion = []
  const now = Date.now()

  for (const [key, entry] of store) {
    // mark for deletion entries that have timed out
    if (now - entry.created > entry.ttl) {
      forDeletion.push(key)
    }
  }

  const forDeletionLength = forDeletion.length
  // if nothing to clean then exit
  if (forDeletionLength === 0) {
    return 0
  }

  debug(`local revalidation flags that timed out: ${forDeletion}`)
  forDeletion.forEach(key => store.delete(key))
  return forDeletionLength
}
function clear (store) {
  const forDeletion = []
  const now = Date.now()

  for (const [key, entry] of store) {
    // mark for deletion entries that have timed out
    if (now - entry.created > entry.ttl) {
      forDeletion.push(key)
    }
  }

  const forDeletionLength = forDeletion.length
  // if nothing to clean then exit
  if (forDeletionLength === 0) {
    return 0
  }

  debug(`local revalidation flags that timed out: ${forDeletion}`)
  forDeletion.forEach(key => store.delete(key))
  return forDeletionLength
}
function clear ( store ) { const forDeletion = [ ] const now = Date . now ( ) for ( const [ key , entry ] of store ) { // mark for deletion entries that have timed out if ( now - entry . created > entry . ttl ) { forDeletion . push ( key ) } } const forDeletionLength = forDeletion . length // if nothing to clean then exit if ( forDeletionLength === 0 ) { return 0 } debug ( ` ${ forDeletion } ` ) forDeletion . forEach ( key => store . delete ( key ) ) return forDeletionLength }
It marks and deletes all the keys that have their ttl expired
@param {Map} store Map Object that stores all the cached keys
@returns {Number} ammount of entries deleted
It marks and deletes all the keys that have their ttl expired