let fs_readFile = util.promisify(fs.readFile)
let fs_writeFile = util.promisify(fs.writeFile)
-let JSONCache = function() {
+let JSONCache = function(diag) {
if (!this instanceof JSONCache)
throw Error('JSONCache is a constructor')
this.map = new Map()
- this.diag = false
+ this.diag = diag || false
}
let load = (diag, key, default_value) => {
return result
}
-JSONCache.prototype.get = async function(key, default_value) {
+JSONCache.prototype.open = async function(key, default_value) {
let result = this.map.get(key)
if (result === undefined) {
result = load(this.diag, key, default_value)
}
}
-JSONCache.prototype.set = async function(key, value, timeout) {
+JSONCache.prototype.flush = async function(key, value, timeout) {
let result = this.map.get(key)
if (result === undefined) {
assert(value !== undefined)
{
- "name": "json_cache",
+ "name": "JSONCache",
"version": "1.0.0",
"description": "Simple caching scheme with atomic modification and delayed write",
- "main": "json_cache.js",
+ "main": "JSONCache.js",
"directories": {},
"dependencies": {
"fs": "^0.0.1-security"