Skip to content

Latest commit

 

History

History
83 lines (75 loc) · 2.33 KB

README.md

File metadata and controls

83 lines (75 loc) · 2.33 KB

ots.js

npm version Build Status

Engines

node >=6.0.0 for es6 support

Usage

install

npm install ots.js

init

const OTS = require('ots.js');

let ots = new OTS({
    endPoint: process.env.otsEndPoint,
    accessId: process.env.otsAccessId,
    accessKey: process.env.otsAccessKey,
    instanceName: process.env.otsInstanceName,
    // optional options
    {
        // default 10,connection poolSize
        // use http.Agent, set keepAlie: true
        poolSize: 20
    }
});

// callback style
ots.CreateTable(...args, callback);
// without the callback parameter, it will return a promise object
ots.CreateTable(...args)
  .then(...);

...

Feature

  • Base on 2015-12-31 API (latest API so far)
  • PlainBuffer Support
  • AutoIncrement PrimaryKey Support
  • Promise Support
  • Connetion Pool Support (Base on http1.1 keep-alive)

Test

Before run test, please export following configuration to your env

export \
    otsEndPoint='like http://pl-msgc.cn-hangzhou.ots.aliyuncs.com' \
    otsAccessId='' \
    otsAccessKey='' \
    otsInstanceName='';

then

npm test

Performance

PlainBuffer Test Result

====== Encode bench START ======
EncodeString#PlainBuffer x 30,025 ops/sec ±0.97% (85 runs sampled)
  - memory: { rss: 70176768, heapTotal: 47271936, heapUsed: 29746856 }
EncodeString#Json x 1,175,011 ops/sec ±0.96% (84 runs sampled)
  - memory: { rss: 82063360, heapTotal: 57757696, heapUsed: 21108072 }
EncodeString#protobuf.js x 1,092,644 ops/sec ±1.47% (82 runs sampled)
  - memory: { rss: 81297408, heapTotal: 56709120, heapUsed: 27769104 }
Fastest is EncodeString#Json
====== Decode bench START ======
DecodeString#PlainBuffer x 70,891 ops/sec ±1.28% (85 runs sampled)
  - memory: { rss: 84955136, heapTotal: 58806272, heapUsed: 14220824 }
DecodeString#Json x 656,429 ops/sec ±1.06% (88 runs sampled)
  - memory: { rss: 86065152, heapTotal: 60903424, heapUsed: 14851056 }
DecodeString#protobuf.js x 1,642,783 ops/sec ±1.22% (85 runs sampled)
  - memory: { rss: 86183936, heapTotal: 60923904, heapUsed: 20393256 }
Fastest is DecodeString#protobuf.js

You can also run the benchmark

npm run bench