How to use the flat-cache.clearCacheById function in flat-cache

To help you get started, we’ve selected a few flat-cache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github royriojas / persistify / index.js View on Github external
browserifyOpts = browserifyOpts || { };
  opts = opts || { };
  var hash = require( 'hash-string' );

  var xtend = require( 'xtend' );

  var id = 'persistify_' + hash( process.cwd() + trim( opts.cacheId ) );
  var depsCacheId = 'deps-cx-' + id;
  var cacheDir = opts.cacheDir;

  var flatCache = require( 'flat-cache' );
  var fileEntryCache = require( 'file-entry-cache' );

  if ( opts.recreate ) {
    flatCache.clearCacheById( id, cacheDir );
    flatCache.clearCacheById( depsCacheId, cacheDir );
  }
  // load the cache with id
  var cache = flatCache.load( id, cacheDir );

  // load the file entry cache with id, or create a new
  // one if the previous one doesn't exist
  var depsCacheFile = fileEntryCache.create( depsCacheId, cacheDir );

  var ignoreCache = false;

  // if the command was specified this can be used
  // as the cache buster
  if ( opts.command ) {
    var configHashPersisted = cache.getKey( 'configHash' );
    var hashOfConfig = hash( opts.command );
github royriojas / persistify / index.js View on Github external
module.exports = function ( browserifyOpts, opts, argv ) {
  browserifyOpts = browserifyOpts || { };
  opts = opts || { };
  var hash = require( 'hash-string' );

  var xtend = require( 'xtend' );

  var id = 'persistify_' + hash( process.cwd() + trim( opts.cacheId ) );
  var depsCacheId = 'deps-cx-' + id;
  var cacheDir = opts.cacheDir;

  var flatCache = require( 'flat-cache' );
  var fileEntryCache = require( 'file-entry-cache' );

  if ( opts.recreate ) {
    flatCache.clearCacheById( id, cacheDir );
    flatCache.clearCacheById( depsCacheId, cacheDir );
  }
  // load the cache with id
  var cache = flatCache.load( id, cacheDir );

  // load the file entry cache with id, or create a new
  // one if the previous one doesn't exist
  var depsCacheFile = fileEntryCache.create( depsCacheId, cacheDir );

  var ignoreCache = false;

  // if the command was specified this can be used
  // as the cache buster
  if ( opts.command ) {
    var configHashPersisted = cache.getKey( 'configHash' );
    var hashOfConfig = hash( opts.command );

flat-cache

A simple key/value storage using files to persist the data

MIT
Latest version published 11 days ago

Package Health Score

91 / 100
Full package analysis

Popular flat-cache functions