handleCache = function handleCache(directory, params, callback) {
  var source = params.source;
  var options = params.options || {};
  var transform = params.transform;
  var identifier = params.identifier;
  var shouldFallback = typeof params.directory !== "string" && directory !== os.tmpdir(); // Make sure the directory exists.

  mkdirp(directory, function (err) {
    // Fallback to tmpdir if node_modules folder not writable
    if (err) return shouldFallback ? handleCache(os.tmpdir(), params, callback) : callback(err);
    var file = path.join(directory, filename(source, identifier, options));
    return read(file, function (err, content) {
      var result = {}; // No errors mean that the file was previously cached
      // we just need to return it

      if (!err) return callback(null, content); // Otherwise just transform the file
      // return it to the user asap and write it in cache

      try {
        result = transform(source, options);
      } catch (error) {
        return callback(error);
      }

      return write(file, result, function (err) {
        // Fallback to tmpdir if node_modules folder not writable
        if (err) return shouldFallback ? handleCache(os.tmpdir(), params, callback) : callback(err);
        callback(null, result);
      });
    });
  });
}
Handle the cache

@params {String} directory
@params {Object} params
@params {Function} callback