sg-storage
v3.0.1
Published
Simple storage for SUGOS
Downloads
27
Readme
sg-storage
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.