sg-storage

3.0.1 • Public • Published

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

/sg-storage/

    Package Sidebar

    Install

    npm i sg-storage

    Weekly Downloads

    3

    Version

    3.0.1

    License

    Apache-2.0

    Last publish

    Collaborators

    • realglobe