aerospike
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -10,3 +10,3 @@ /*********************************************************************** | ||
var cluster = require('cluster'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
var os = require('os'); | ||
@@ -25,3 +25,3 @@ var path = require('path'); | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -28,0 +28,0 @@ .options({ |
@@ -9,3 +9,3 @@ /*********************************************************************** | ||
var cluster = require('cluster'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
var os = require('os'); | ||
@@ -44,3 +44,3 @@ var path = require('path'); | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -47,0 +47,0 @@ .options({ |
var Table = require('cli-table'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -50,3 +50,3 @@ var MEM_MATCH = /(\d+(\.\d+)?) MB/ | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -53,0 +53,0 @@ .options({ |
@@ -19,3 +19,3 @@ { | ||
"colors": "0.6.2", | ||
"optimist": ">=0.6.0", | ||
"yargs":"1.2.1", | ||
"winston": "0.7.2" | ||
@@ -22,0 +22,0 @@ }, |
@@ -9,3 +9,3 @@ /*********************************************************************** | ||
var cluster = require('cluster'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
var path = require('path'); | ||
@@ -22,3 +22,3 @@ var util = require('util'); | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -25,0 +25,0 @@ .options({ |
@@ -1,2 +0,1 @@ | ||
# Data Model | ||
@@ -13,11 +12,16 @@ | ||
A record is how the data is represented and stored in the database. A record represented as an object. The keys of the object are the names of the fields (bins) of a record. The values for each field can either be Integer, String or Buffer. | ||
A record is how the data is represented and stored in the database. A record represented as an object. The keys of the object are the names of the fields (bins) of a record. The values for each field can either be Integer, String, Array, Buffer or an Object itself. | ||
Example of a record with 3 fields: | ||
Note: Array can contain an array or an object as a value in it. Similarly the object can contain an array or an object as a value in it. Essentially nesting of arrays in an object, and nesting of objects in an array is allowed. | ||
Example of a record with 5 fields: | ||
```js | ||
var record = { | ||
a: 123, | ||
b: "xyz", | ||
c: new Buffer("hello world!") | ||
int_bin : 123, | ||
str_bin : "xyz", | ||
buff_bin : new Buffer("hello world!"), | ||
arr_bin : [1, 2, 3], | ||
obj_bin : { num: 123, str : "abc", buff: new Buffer([0xa, 0xb, 0xc])} | ||
} | ||
@@ -24,0 +28,0 @@ ``` |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key [key ...]") | ||
@@ -24,0 +24,0 @@ .options({ |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key [key ...]") | ||
@@ -24,0 +24,0 @@ .options({ |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var fs = require('fs'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key") | ||
@@ -24,0 +24,0 @@ .options({ |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key") | ||
@@ -96,13 +96,10 @@ .options({ | ||
} | ||
}).connect(function (err, client ) { | ||
if ( err.code != status.AEROSPIKE_OK ) { | ||
console.log("Aerospike server connection Error: %j", err) | ||
return; | ||
}); | ||
function as_connect_callback( err, as_client ) { | ||
if (err.code != status.AEROSPIKE_OK) { | ||
console.log("Aerospike server connection Error: %j", err); | ||
setTimeout( function() { client.connect(as_connect_callback)} , 1000); | ||
} | ||
if ( client === null ) { | ||
console.error("Error: Client not initialized."); | ||
return; | ||
} | ||
}); | ||
} | ||
client.connect(as_connect_callback) | ||
/******************************************************************************* | ||
@@ -120,5 +117,5 @@ * | ||
var get_fn = client.get; | ||
console.time("get"); | ||
client.get(key, function(err, record, metadata, key) { | ||
function get_cb( err, record, metadata, key) { | ||
switch ( err.code ) { | ||
@@ -134,7 +131,6 @@ case status.AEROSPIKE_OK: | ||
} | ||
console.timeEnd("get"); | ||
console.log(); | ||
client.close(); | ||
}); | ||
} | ||
client.get(key, get_cb) |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key") | ||
@@ -24,0 +24,0 @@ .options({ |
@@ -25,3 +25,3 @@ /***************************************************************************** | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -37,3 +37,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] logfile") | ||
@@ -40,0 +40,0 @@ .options({ |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -22,3 +22,3 @@ var op = aerospike.operator; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key") | ||
@@ -25,0 +25,0 @@ .options({ |
@@ -17,4 +17,4 @@ { | ||
"aerospike": ">0", | ||
"optimist": ">=0.6.0" | ||
"yargs": ">=1.2.1" | ||
} | ||
} |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key") | ||
@@ -121,4 +121,6 @@ .options({ | ||
var record = { | ||
i: 123, | ||
s: "abc", | ||
i: 123, | ||
arr: [1, 2, 3], | ||
map: { str: "g3", num: 3, buff: new Buffer( [0xa, 0xb, 0xc])}, | ||
b: new Buffer([0xa, 0xb, 0xc]), | ||
@@ -125,0 +127,0 @@ b2: new Uint8Array([0xa, 0xb, 0xc]) |
@@ -25,3 +25,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -37,3 +37,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -40,0 +40,0 @@ .options({ |
@@ -25,3 +25,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -37,3 +37,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -40,0 +40,0 @@ .options({ |
@@ -25,3 +25,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -37,3 +37,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -40,0 +40,0 @@ .options({ |
@@ -25,3 +25,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -37,3 +37,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -40,0 +40,0 @@ .options({ |
@@ -25,3 +25,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -37,3 +37,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options]") | ||
@@ -40,0 +40,0 @@ .options({ |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key") | ||
@@ -24,0 +24,0 @@ .options({ |
@@ -9,3 +9,3 @@ /******************************************************************************* | ||
var aerospike = require('aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -21,3 +21,3 @@ var policy = aerospike.policy; | ||
var argp = optimist | ||
var argp = yargs | ||
.usage("$0 [options] key bin [bin ...]") | ||
@@ -24,0 +24,0 @@ .options({ |
{ | ||
"name" : "aerospike", | ||
"version" : "1.0.3", | ||
"version" : "1.0.4", | ||
"description" : "Aerospike Client Library", | ||
@@ -22,6 +22,6 @@ "tags" : [ "aerospike", "database", "nosql" ], | ||
"mocha": ">0", | ||
"optimist": ">=0.6.0", | ||
"expect.js": "0.2.x", | ||
"superagent": "0.15.x" | ||
"superagent": "0.15.x", | ||
"yargs":"1.2.1" | ||
} | ||
} |
@@ -29,7 +29,16 @@ # Aerospike Client for Node.js | ||
// Connect to the cluster. | ||
var client = aerospike.client({ | ||
hosts: [ { addr: '127.0.0.1', port: 3000 } ] | ||
}).connect(); | ||
}); | ||
function connect_cb( err, client) { | ||
if (err.code == AEROSPIKE_OK) { | ||
console.log("Aerospike Connection Success") | ||
} | ||
} | ||
client.connect(connect_cb) | ||
// The key of the record we are reading. | ||
@@ -66,2 +75,6 @@ var key = aerospike.key('test','demo','foo'); | ||
Aerospike Node.js has a dependency on Aerospike C client, which is | ||
downloaded during the installation. | ||
To Download Aerospike C client, curl is required. | ||
Supported operating systems: | ||
@@ -68,0 +81,0 @@ |
@@ -27,2 +27,2 @@ | ||
record: record | ||
}; | ||
}; |
@@ -98,2 +98,39 @@ | ||
function array() { | ||
return function() { | ||
var itype = integer(); | ||
var stype = string(); | ||
var btype = bytes(); | ||
var arr = [itype(), stype(), btype()]; | ||
return arr; | ||
} | ||
} | ||
function map() { | ||
return function() { | ||
var num = integer(); | ||
var str = string(); | ||
var uint = bytes(); | ||
var map = { itype: num(), stype: str(), btyte: uint()} ; | ||
return map; | ||
} | ||
} | ||
function array_of_array(){ | ||
return function(){ | ||
var arr = array(); | ||
var obj = map(); | ||
var list = [ arr(), obj() ]; | ||
return list; | ||
} | ||
} | ||
function map_of_map() { | ||
return function() { | ||
var arr = array(); | ||
var obj = map(); | ||
var map_of_list = {inner_list: arr(), inner_map: obj() }; | ||
return map_of_list; | ||
} | ||
} | ||
integer.defaults = { | ||
@@ -110,3 +147,7 @@ random: true, | ||
integer: integer, | ||
string: string | ||
string: string, | ||
array: array, | ||
map: map, | ||
array_of_array: array_of_array, | ||
map_of_map: map_of_map | ||
}; |
@@ -162,21 +162,41 @@ // we want to test the built aerospike module | ||
// TEST LOGIC | ||
// 1.Write a record to an aerospike server. | ||
// 2.Read the record, to get the ttl and calculate | ||
// the difference in the ttl written and the ttl returned by server. | ||
// 3.Touch the record with a definite ttl. | ||
// 4.Read the record and calculate the difference in the ttl between the | ||
// touch ttl value and read ttl value. | ||
// 5.Compare the difference with the earlier difference calculated. | ||
// 6.This is to account for the clock asynchronicity between | ||
// the client and the server machines. | ||
// 7.Server returns a number, at which the record expires according the server clock. | ||
// 8.The client calculates the time in seconds, and gives back ttl. In the case , where | ||
// clocks are not synchronous between server and client, the ttl client calculates may not | ||
// be accurate to the user. Nevertheless server expires the record in the correct time. | ||
// write the record then check | ||
client.put(key, record, meta, function(err, key) { | ||
var ops = [ | ||
op.touch(1000) | ||
op.touch(500) | ||
]; | ||
client.operate(key, ops, function(err, record1, metadata1, key1) { | ||
client.get(key, function(err, record3, metadata3, key3){ | ||
expect(err).to.be.ok(); | ||
expect(err.code).to.equal(status.AEROSPIKE_OK); | ||
ttl_diff = metadata3.ttl - meta.ttl; | ||
client.get(key, function(err, record2, metadata2, key2) { | ||
client.operate(key, ops, function(err, record1, metadata1, key1) { | ||
expect(err).to.be.ok(); | ||
expect(err.code).to.equal(status.AEROSPIKE_OK); | ||
expect(record['i']).to.equal(record2['i']); | ||
expect(record['s']).to.equal(record2['s']); | ||
expect(meta.ttl).to.equal(metadata2.ttl); | ||
done(); | ||
client.get(key, function(err, record2, metadata2, key2) { | ||
expect(err).to.be.ok(); | ||
expect(err.code).to.equal(status.AEROSPIKE_OK); | ||
expect(record['i']).to.equal(record2['i']); | ||
expect(record['s']).to.equal(record2['s']); | ||
expect(500 + ttl_diff+10).to.be.above(metadata2.ttl); | ||
expect(500 + ttl_diff-10).to.be.below(metadata2.ttl); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -183,0 +203,0 @@ }); |
@@ -133,3 +133,2 @@ // we want to test the built aerospike module | ||
var rgen = recgen.record({i: valgen.integer(), s: valgen.string()}); | ||
// values | ||
@@ -139,3 +138,2 @@ var key = kgen(); | ||
var record = rgen(key, meta); | ||
// write the record then check | ||
@@ -152,2 +150,48 @@ client.put(key, record, meta, function(err, key) { | ||
it('shoule write an array, map type of bin and read', function(done) { | ||
// generators | ||
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"}); | ||
var mgen = metagen.constant({ttl: 1000}); | ||
var rgen = recgen.record({list: valgen.array(), map: valgen.map()}); | ||
//values | ||
var key = kgen(); | ||
var meta = mgen(key); | ||
var record = rgen(key, meta); | ||
//write the record and then check | ||
client.put(key, record, meta, function(err, key) { | ||
client.get(key, function(err, record1, metadata, key){ | ||
expect(err).to.be.ok(); | ||
expect(err.code).to.equal(status.AEROSPIKE_OK); | ||
expect(record1).to.eql(record); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should write an array of map and array, map of array and map, then read', function(done){ | ||
//generators | ||
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"}); | ||
var mgen = metagen.constant({ttl:1000}); | ||
var rgen = recgen.record({list_of_list: valgen.array_of_array(), map_of_list: valgen.map_of_map()}); | ||
//values | ||
var key = kgen(); | ||
var meta = mgen(key); | ||
var record = rgen(key, meta); | ||
//write the record and then check | ||
client.put(key, record, meta, function(err, key) { | ||
client.get(key, function(err, record1, metadata, key){ | ||
expect(err).to.be.ok(); | ||
expect(err.code).to.equal(status.AEROSPIKE_OK); | ||
expect(record1).to.eql(record); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should write, read, write, and check gen', function(done) { | ||
@@ -154,0 +198,0 @@ |
var aerospike = require('../../build/Release/aerospike'); | ||
var optimist = require('optimist'); | ||
var yargs = require('yargs'); | ||
@@ -11,3 +11,3 @@ /******************************************************************************* | ||
var parser = optimist | ||
var parser = yargs | ||
.usage("$0 [options]") | ||
@@ -14,0 +14,0 @@ .options({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85
5132
268
412890