How to use aerospike - 10 common examples

To help you get started, we’ve selected a few aerospike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerospike / aerospike-client-nodejs / examples / range_remove.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) {
    console.error('Error: Aerospike server connection error. ', err.message)
    process.exit(1)
  }

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function removeDone (client, start, end, skip) {
    var total = end - start + 1
    var done = 0
    var success = 0
github aerospike / aerospike-client-nodejs / examples / range_get.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) {
    console.error('Error: Aerospike server connection error. ', err.message)
    process.exit(1)
  }

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function getDone (client, start, end, skip) {
    var total = end - start + 1
    var done = 0
    var success = 0
github aerospike / aerospike-client-nodejs / examples / range_validate.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) {
    console.error('Error: Aerospike server connection error. ', err.message)
    process.exit(1)
  }

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function putDone (client, start, end) {
    var total = end - start + 1
    var done = 0
    var timeLabel = 'range_put @ ' + total
github aerospike-edu / student-workbook / AS101 / NodeJS / solution / app.js View on Github external
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster

//Exercise K1, Exercise R2, Exercise Q3 & Exercise A2
var hostaddr = '127.0.0.1';
//Override with your AWS IP Address
hostaddr = "54.xx.yy.zz" ;

// Note: Node.js client does not implement default modlua config for client node.
// This is needed when using stream udfs.

// Exercise A2
var client = aerospike.client({
    hosts: [ { addr: hostaddr, port: 3000 }],
    modlua:{systemPath:'/usr/local/aerospike/lua',
            userPath:'/usr/local/aerospike/usr-lua'
           }
}).connect( function(response) {
    // Check for errors
    // Exercise K1
    if ( response == null ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
github aerospike-edu / student-workbook / deprecated / answers / Complete / Node / app.js View on Github external
//  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  * IN THE SOFTWARE. 

'use strict';

var aerospike = require('aerospike');
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster
var client = aerospike.client({
    hosts: [ { addr: '172.16.159.172', port: 3000 } ]
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});

// Setup tear down
process.on('exit', function() {
github aerospike / aerospike-client-nodejs / examples / simple_get.js View on Github external
if(argv.password !== null)
{
	config.password = argv.password;
}
/*******************************************************************************
 *
 * Establish a connection and execute the opetation.
 * 
 ******************************************************************************/

function format(o) {
    return JSON.stringify(o, null, '    ');
}

aerospike.client(config).connect(function (err, client) {

    if ( err.code != Status.AEROSPIKE_OK ) {
        console.error("Error: Aerospike server connection error. ", err.message);
        process.exit(1);
    }

    //
    // Perform the operation
    //

    var key = {
        ns:  argv.namespace,
        set: argv.set,
        key: keyv
    };
github aerospike-edu / student-workbook / deprecated / answers / Aggregations / Node / app.js View on Github external
//  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  * IN THE SOFTWARE. 

'use strict';

var aerospike = require('aerospike');
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster
var client = aerospike.client({
    hosts: [ { addr: '172.16.159.170', port: 3000 } ]
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});

// Setup tear down
process.on('exit', function() {
github aerospike-edu / student-workbook / deprecated / exercises / RecordUDF / Node / app.js View on Github external
//  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  * IN THE SOFTWARE. 

'use strict';

var aerospike = require('aerospike');
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster
var client = aerospike.client({
    hosts: [ { addr: 'YOUR_IP_ADDRESS', port: 3000 } ]
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});

// Setup tear down
process.on('exit', function() {
github aerospike-edu / student-workbook / deprecated / answers / Key-valueOperations / Node / app.js View on Github external
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});
github aerospike-edu / student-workbook / deprecated / answers / Complete / Node / app.js View on Github external
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});