lambee
Version:
A tool to help developer work with AWS Lambda.
35 lines (24 loc) • 725 B
JavaScript
/**
* This simple cache is just used to make development easier. It removes the lag of
* waiting for the AWS API call. Commented out for production.
*/
const fs = require('fs')
const os = require('os')
const cacheDir = os.homedir() + '/.centbee-cli'
function get(key) {
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir)
}
if (!fs.existsSync(cacheDir + '/' + key)) {
return
} else {
return JSON.parse(fs.readFileSync(cacheDir + '/' + key, 'utf-8'))
}
}
function put(key, data) {
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir)
}
fs.writeFileSync(cacheDir + '/' + key, JSON.stringify(data, undefined, 4))
}
module.exports = { get, put }