
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
ssdb nodejs client library, ssdb is a fast nosql database, an alternative to redis.
ssdb nodejs/iojs client library, ssdb is a fast nosql database, an alternative to redis.
v0.3.0 (and higher versions) are not backward-compactiable with old versions(0.2.x).
Please dont send me emails for any questions about node-ssdb, open an issue on GitHub instead, thanks!
$ npm install ssdb
The traditional Node.js way:
var ssdb = require('ssdb');
var pool = ssdb.createPool();
var conn = pool.acquire();
conn.set('key', 'val', function(err, data) {
if (err) {
throw err;
}
// data => '1'
});
Work with tj/co, make it thunkify or promisify:
var co = require('co');
var pool = ssdb.createPool({promisify: true});
var conn = pool.acquire();
co(function *(){
var key = 'key';
var a = yield conn.set(key, 'val');
var b = yield conn.get(key);
console.log(a, b); // 1 'val'
}).catch(function(err) {
console.error(err)
});
node-ssdb uses v8 native Promise to implement promisify
, which requires nodejs v0.11.13+
To use bluebird as promise implementation (which is much faster than v8 native promise):
// use bluebird promise
global.Promise = require('bluebird').Promise;
Callback functions have two parameters: error, data
;
status_ok
: only error
is undefined
;status_not_found
: error
and data
are both undefined
status_error
, status_fail
, status_client_error
: only data
is undefined
.var ssdb = require('ssdb');
var pool = ssdb.createPool();
pool.acquire().set('key', 'val', function(err, data) {
if (err && err instanceof ssdb.SSDBError)
throw err; // ssdb error
});
There are 2 poolling policies avaliable: 'least_conn' and 'round_robin' (the default), e.g.
var pool = ssdb.createPool({policy: ssdb.Pool.policies.least_conn});
To make a ssdb client:
var ssdb = require('ssdb');
var pool = ssdb.createPool();
options (with default values):
{
host: '0.0.0.0',
port: 8888,
auth: undefined, // ssdb server auth password
authCallback: function(err, data) {if (err) throw err;}, // callback function on auth
size: 1, // connection pool size
timeout: 0,
promisify: false, // make api methods promisify.
thunkify: false, // make api methods thunkify.
policy: Pool.policies.round_robin,
}
Note: auth
requires ssdb v1.7.0.0+
Acquire a connection from pool.
Close all connections in the pool. (note that if a connection is closed, it will reconnect to ssdb server automatically if you reuse this conn to send commands, and the same with pool.)
Create a new connection and add it to the pool.
ssdb.commands
Detail docs for ssdb interfaces can be found at: https://github.com/hit9/ssdb.api.docs
Pipeline?
Node-ssdb pipelines automatically because node.js has async IO, this is different with other clients in sync IO languages (i.e. Python), node-ssdb always pipelines.
Commands & Callbacks ordering ?
On a single connection, the callbacks are run the same order as the commands are sent, TCP guarantees this: the stream will arrive in the same order as it was sent.
Connection Pool?
ssdb is a multiple-threading server, so the connection pool is required. Here are some examples to use the connection pool:
// async io and executed in order on the remote end.
var conn = pool.acquire();
yield conn.set('key', 'val');
yield conn.get('key');
// async io and executed parallely on the remote end.
yield [
pool.acquire().set('key1', 'val1');
pool.acquire().set('key2', 'val2');
];
Copyright (c) 2014 Eleme, Inc. detail see LICENSE-MIT
FAQs
ssdb nodejs client library, ssdb is a fast nosql database, an alternative to redis.
We found that ssdb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.