The cache duo uses internally during builds.
location refers to the destination of the LevelDB database directory.
Reads the all the stored files from the database into memory.
Accepts the updated in-memory
mapping and saves all the files into cache.
Can be used to set/get a single file's data from the cache. If
excluded, it is assumed to be a getter. (otherwise, it will be a setter)
Cache#plugin(name, key, [data])
Can be used to set/get a plugin's cache data. If
data is excluded, it
is assumed to be a getter. (otherwise, it will be a setter)
name should be the same as the plugin's name, to make debugging easier.
key can be either a
String or an
Array. Below is a sample plugin
that is using caching.
// hash the source code as well as options to allow this// to work even if the user changes their config!var key = ;// see if it's already been cachedvar cached = cache; // getif cached return cached;// run the normal transformationvar results = ;// cache the results for next timecache; // setreturn results;
Closes the database and wipes it out from the disk.
Currently, this implementation only satisfies the bare-minimum based on duo's current cache implementation. (currently called the "mapping")
Now that there is a robust data-store in place, more features will be added, including:
- give plugins a way to get/set cache data (so they can reduce the amount of processing they do on repeated builds)
- store additional processing during the build process (such as the result of scanning a file for dependencies)
- expose this hook to other modules that cache results (eg: gh-resolve)