Skip to content

trenskow/donot-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Base abstract class for cache plugins - used for developing cache plugins for donot.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published