cachedog
v1.1.0
Published
cachedog is a little dog for cacheing your nodejs status. Its easy to memory your status to local file as json
Downloads
7
Maintainers
Readme
cachedog is a little dog for cacheing your nodejs status
npm install cachedog
Usage
const CacheDog = require('cachedog')
init your first dog
const dog = new CacheDog({
// this is a json file path for your custom
fileName: 'cache.json'
})
if you not want Save data in real time
const dog = new CacheDog({
// this is a json file path for your custom
fileName: 'cache.json',
realSave: false
})
then you will found a json file in your path
you can also init a dog with an Initial object
const dog = new CacheDog({
fileName: 'cache.json'
init: {
speed: 100,
num: 1
},
})
Use your dog
dog.set('name', 'kenny')
dog.set('info', {
name: 'kenny',
gender: 'boy'
})
dog.set('money', [1, 2, 3, 4])
get data from your dog
dog.get('speed') // 100
dog.get('name') // kenny
dog.get('info') // { name: 'kenny', gender: 'boy'}
dog.get('money') // [1, 2, 3, 4]
Has key
dog.has('speed') // true
dog.has('pig') // false
delete data from your dog
dog.delete('speed')
dog.delete('name')
destory your dog
dog.destory()
API
- .set(key, value)
- .get(key)
- .delete(key)
- .has(key)
- .destory()
License
MIT