A simple key value store using single json file
Last updated a year ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install akv 
SYNC missed versions from official npm registry.


Build Status npm Version JS Standard

A simple key value store using single json file


$ npm install akv --save


'use strict'

const akv = require('akv')
const co = require('co')

co(function * () {
  let storage = akv('tmp/my-storage.json')
  // Set key value
  yield storage.set('foo', 'bar')

  // Get key value
  let foo = yield storage.get('foo')
  console.log(foo) // => bar
  // Delete by key
  yield storage.del('foo')
}).catch((err) => console.error(err))


Available methods

Signature Description
.touch() -> Promise Touch file
.set(key, value) -> Promise Set a value
.keys() -> Promise Get all keys
.get(key) -> Promise Get a value
.all() -> Promise Get all values
.del(key) -> Promise Delete a value
.destroy() -> Promise Delete all values


Commit to files

Normally, akv flushes data into files with some interval. But somethings you need to explicitly call commit changes.

let storage = akv('tmp/my-storage.json')
/* ... */
storage.commit() // Force to flush files


This software is released under the MIT License.


Maintainers (1)
Today 0
This Week 0
This Month 49
Last Day 0
Last Week 1
Last Month 148
Dependencies (2)
Dev Dependencies (10)

Copyright 2014 - 2016 © taobao.org |