<commit_before>var stringify = require('json-stable-stringify');
var getRaw = require('./get-raw-config');
var loaders = {};
var rawcache = {};

module.exports = getRawCached;

function getRawCached(options) {
  var rawkey = `${options.account}/${options.accountKey}/${options.accountTable}/${options.namespace}`;
  if (rawcache[rawkey]) return Promise.resolve(rawcache[rawkey]);
  if (loaders[rawkey]) return loaders[rawkey];

  return getRaw(options)
    .then((rawdata)=>{
      rawcache[rawkey] = rawdata;
      delete loaders[rawkey];
      
      //remove cached raw data after 4 minutes
      //don't prevent app exit via this timer
      setTimeout(function(){
        delete rawcache[key];
      }, 240000).unref();
      
      return rawdata;
    })
    .catch((err)=>{
      delete loaders[rawkey];
      return Promise.reject(err); //raise error
    });
}<commit_msg>fix typo<commit_after>var stringify = require('json-stable-stringify');
var getRaw = require('./get-raw-config');
var loaders = {};
var rawcache = {};

module.exports = getRawCached;

function getRawCached(options) {
  var rawkey = `${options.account}/${options.accountKey}/${options.accountTable}/${options.namespace}`;
  if (rawcache[rawkey]) return Promise.resolve(rawcache[rawkey]);
  if (loaders[rawkey]) return loaders[rawkey];

  return getRaw(options)
    .then((rawdata)=>{
      rawcache[rawkey] = rawdata;
      delete loaders[rawkey];
      
      //remove cached raw data after 4 minutes
      //don't prevent app exit via this timer
      setTimeout(function(){
        delete rawcache[rawkey];
      }, 240000).unref();
      
      return rawdata;
    })
    .catch((err)=>{
      delete loaders[rawkey];
      return Promise.reject(err); //raise error
    });
}
{'fraction_non_alphanumeric': 0.15130830489192265, 'fraction_numerical': 0.007963594994311717, 'mean_word_length': 3.3756218905472637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1740138', 'n_tokens_mistral': 550, 'n_tokens_neox': 534, 'n_words': 119}