1.0.2 • Published 8 years ago

@donotjs/donot-cache v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

donot-cache

This only contains an abstract class that all cache plugins inherit from. It cannot be used as a cache directly with donot.

Implementing a cache plugin

Implement your cache plugins as the example below.

const Cache = require('donor-cache');

class MyCache extends Cache {
    construct() {
        // Do your constructor work.
    }
    // Gets a cached file
    get(filename) {
    	return new Promise((resolved, rejected) => {
    		// Get file content from filename and call `resolved` with its data
    		// or `rejected` with an error.
    	});
    }
    // Caches a file.
    set(filename, data) {
    	return new Promise((resolved, rejected) => {
    		// Save data to the cache.
    	});
    }
    // Invalidates a file (optional).
    invalidate(filename) {
    	return new Promise((resolved, rejected) => {
    		// Invalidate cache for filename.
    	});
    }
}

module.exports = exports = MyCache;

License

MIT