0.3.0 • Published 7 years ago

cache-swap v0.3.0

Weekly downloads
28,465
License
MIT
Repository
github
Last release
7 years ago

cache-swap

NPM version Build status Dependency Status devDependency Status

A lightweight file swap cache backed by temp files.

Example

var swap = new CacheSwap({
    cacheDirName: "HoganizeSwap"
  }),
  processTemplate = function(template, done) {
    var templateStr = template.content,
      templatePath = template.path,
      templateHash = files.shaIt(templateStr);

    swap.getCached("hoganize", templateHash, function(err, cached) {
      if(err) {
        return done(err);
      }

      var yeahbrotha,
        stringed;

      if(cached) {
        yeahbrotha = cached.contents;
        try {
          addToHoganized(yeahbrotha, templatePath);
        } catch(e){
          return done(e);
        }

        done();
      } else {
        yeahbrotha = self._compileTemplate(templateStr, templatePath);
        // Add the compiled template to the cache swap for next time.
        swap.addCached("hoganize", templateHash, yeahbrotha, function(err) {
          if(err) {
            return done(err);
          }

          try {
            addToHoganized(yeahbrotha, templatePath);
          } catch(e) {
            return done(e);
          }

          done();
        });
      }

    });
  };

License

Licensed under the MIT License, Copyright 2013-2015 Jacob Gable

0.3.0

7 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago