You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rdrew
1440706ce3
|
6 years ago | |
---|---|---|
.. | ||
node_modules/object-assign | 6 years ago | |
LICENSE | 6 years ago | |
README.md | 6 years ago | |
index.js | 6 years ago | |
package.json | 6 years ago |
README.md
cache-swap
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