@nexssp/cache
- Just EASY basic caching..
Check how old cache is with: 2 days
, 1d
, 5m
, 2y
, 3.5 hrs
, 1s
. See below for examples.
const cache = require('@nexssp/cache')
const os = require('os')
const cache1 = cache({
bucket: 'languages',
cachePath: os.tmpdir(),
recreateCache: process.argv.includes('--nocache'),
auto: true,
})
const cache2 = cache({
recreateCache: process.argv.includes('--nocache'),
})
module.exports = { cache1, cache2 }
const cache = require('@nexssp/cache')
const cache1 = cache({ auto: true })
const cachePath = cache1.start()
cache.writeJSON('mycache.json', { a: 1, b: 2, c3: 3 })
let cacheContent
if ((cacheContent = cache.exists(cacheTestFile, '1d', true))) {
}
if (cache.exists(cacheTestFile, '1d')) {
const cacheContent = cache.read(cacheTestFile)
const test = cache.readJSON(cacheTestFile)
}
cache.write('my new cache standard file', 'Just standard file.. no JSON')
cache.writeJSON('my new cache standard file', { x: 1, y: 2 })