项目作者: realglobe-Inc

项目描述 :
On-memory storage for SUGOS
高级语言: JavaScript
项目地址: git://github.com/realglobe-Inc/sg-storage.git
创建时间: 2016-05-27T04:59:51Z
项目社区:https://github.com/realglobe-Inc/sg-storage

开源协议:Apache License 2.0

下载


sg-storage

Build Status
npm Version
JS Standard

Simple storage for SUGOS

Installation

  1. $ npm install sg-storage --save

Usage

  1. 'use strict'
  2. const sgStorage = require('sg-storage')
  3. const co = require('co')
  4. // With file system (Handy, but slow)
  5. co(function * () {
  6. let storage = sgStorage('var/lib/simple-storage')
  7. // Set hash
  8. yield storage.hset('foo', 'bar', 'baz')
  9. // Get hash all
  10. let item = yield storage.hgetall('foo')
  11. console.log(item) // -> {bar: 'baz'}
  12. }).catch((err) => console.error(err))
  13. // Using redis server
  14. co(function * () {
  15. // See https://github.com/NodeRedis/node_redis#readme for redis options
  16. let storage = sgStorage.redis({
  17. host: '127.0.0.1',
  18. port: '6379',
  19. db: 1
  20. })
  21. // Set hash
  22. yield storage.hset('foo', 'bar', 'baz')
  23. // Get hash all
  24. let item = yield storage.hgetall('foo')
  25. console.log(item) // -> {bar: 'baz'}
  26. }).catch((err) => console.error(err))

License

This software is released under the Apache-2.0 License.