2.0.1 • Published 7 years ago

akv v2.0.1

Weekly downloads
236
License
MIT
Repository
github
Last release
7 years ago

akv

Build Status npm Version JS Standard

A simple key value store using single json file

Installation

$ npm install akv --save

Usage

'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))

Methods

Available methods

SignatureDescription
.touch() -> PromiseTouch file
.set(key, value) -> PromiseSet a value
.keys() -> PromiseGet all keys
.get(key) -> PromiseGet a value
.all() -> PromiseGet all values
.del(key) -> PromiseDelete a value
.destroy() -> PromiseDelete all values

Tips

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

License

This software is released under the MIT License.

Links

2.0.1

7 years ago

2.0.0

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.21

9 years ago

1.0.20

9 years ago

1.0.19

9 years ago

1.0.18

9 years ago

1.0.17

9 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.0

10 years ago