Tabnine Logo For Javascript
flat-cache
Code IndexAdd Tabnine to your IDE (free)

How to use flat-cache

Best JavaScript code snippets using flat-cache(Showing top 2 results out of 315)

origin: KartulUdus/PoracleJS

async getAddress(locationObject) {
    const cacheKey = `${String(+locationObject.lat.toFixed(3))}-${String(+locationObject.lon.toFixed(3))}`
    const cachedResult = geoCache.getKey(cacheKey)
    if (cachedResult) return cachedResult

    try {
      const geocoder = this.getGeocoder()
      const [result] = await geocoder.reverse(locationObject)
      const flag = emojiFlags[result.countryCode]
      const addressDts = this.mustache.compile(this.config.locale.addressFormat)
      result.addr = addressDts(result)
      result.flag = flag ? flag.emoji : ''
      geoCache.setKey(cacheKey, result)
      geoCache.save(true)
      return result
    } catch (err) {
      throw new Error({ source: 'getAddress', error: err })
    }
  }
origin: Link-/starred_search

let cache = flatCache.load(`${cacheHash}`, path.resolve(options.cacheDir));
if (cache._persisted.data === undefined || Object.keys(cache._persisted).length == 0) {
 (options.verbose) ? console.log(chalk.bold.green('✅    INFO:: Cache is empty, fetching data from GitHub')) : null;
 return fetch_starred_repos(options, pages)
  .then((data) => {
   cache.setKey('data', data);
   cache.save();
   return data;
  });
} else {
 (options.verbose) ? console.log(chalk.bold.red('⚠️    INFO:: Serving search results from cache')) : null;
 return cache.getKey('data');
flat-cache(npm)

Most used flat-cache functions

  • Cache.getKey
  • Cache.save
  • Cache.setKey
  • Cache._persisted
  • load

Popular in JavaScript

  • minimist
    parse argument options
  • mocha
    simple, flexible, fun test framework
  • crypto
  • glob
    a little globber
  • js-yaml
    YAML 1.2 parser and serializer
  • fs
  • node-fetch
    A light-weight module that brings window.fetch to node.js
  • lodash
    Lodash modular utilities.
  • chalk
    Terminal string styling done right
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now