3.0.1 • Published 7 years ago

sg-storage v3.0.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
7 years ago

sg-storage

Build Status npm Version JS Standard

Simple storage for SUGOS

Installation

$ npm install sg-storage --save

Usage

'use strict'

const sgStorage = require('sg-storage')
const co = require('co')

// With file system (Handy, but slow)
co(function * () {
  let storage = sgStorage('var/lib/simple-storage')

  // Set hash
  yield storage.hset('foo', 'bar', 'baz')

  // Get hash all
  let item = yield storage.hgetall('foo')
  console.log(item) // -> {bar: 'baz'}
}).catch((err) => console.error(err))

// Using redis server
co(function * () {
  // See https://github.com/NodeRedis/node_redis#readme for redis options
  let storage = sgStorage.redis({
    host: '127.0.0.1',
    port: '6379',
    db: 1
  })
  // Set hash
  yield storage.hset('foo', 'bar', 'baz')

  // Get hash all
  let item = yield storage.hgetall('foo')
  console.log(item) // -> {bar: 'baz'}
}).catch((err) => console.error(err))

License

This software is released under the Apache-2.0 License.

Links

3.0.1

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago