How to use the aerospike.Key function in aerospike

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 / llist.js View on Github external
Aerospike.connect(config, function (err, client) {
  if (err) throw err

  // Get a largelist object from client.
  var listkey = new Aerospike.Key(argv.namespace, argv.set, 'ldt_list_key')
  var policy = { timeout: 1000 }
  var list = client.LargeList(listkey, 'ldt_list_bin', policy)

  // perform all the largelist operations.

  // add single value to the list.
  var val = 'listvalsingle'
  list.add(val, function (err, val) {
    checkError(err, 'Added a single value')
  })

  // update single value added to the list.
  var updateVal = 'listvalupdated'
  list.update(updateVal, function (err, val) {
    checkError(err, 'Updated a single value')
  })
github aerospike / aerospike-client-nodejs / examples / apply.js View on Github external
async function apply (client, argv) {
  const key = new Aerospike.Key(argv.namespace, argv.set, argv.key)

  const udfCall = {
    module: argv.module,
    funcname: argv.function,
    args: argv.args.map(arg => {
      try {
        return JSON.parse(arg)
      } catch (error) {
        return '' + arg
      }
    })
  }

  const result = await client.apply(key, udfCall)
  console.info(result)
}
github aerospike / aerospike-client-nodejs / examples / get.js View on Github external
async function get (client, argv) {
  const key = new Aerospike.Key(argv.namespace, argv.set, argv.key)
  let record
  if (argv.bins) {
    record = await client.select(key, argv.bins)
  } else {
    record = await client.get(key)
  }
  console.info(record)
}
github aerospike / aerospike-client-nodejs / examples / select.js View on Github external
function run (client, done) {
  var key = new Aerospike.Key(argv.namespace, argv.set, keyv + iteration.current())

  client.select(key, bins, function (err, record) {
    if (!err) {
      !argv.quiet && console.log('Found key ' + key.key + '.')
      !argv.quiet && console.log(JSON.stringify(record, null, '    '))
    } else if (err.code === Aerospike.status.ERR_RECORD_NOT_FOUND) {
      !argv.quiet && console.log('Key ' + key.key + ' does not exist.')
    } else {
      throw err
    }
    iteration.next(run, client, done)
  })
}
github aerospike / aerospike-client-nodejs / examples / append.js View on Github external
async function append (client, argv) {
  const key = new Aerospike.Key(argv.namespace, argv.set, argv.key)
  const bins = shared.cli.parseBins(argv.bins)
  await client.append(key, bins)
  console.info('Record updated successfully:', key)
}
github aerospike / aerospike-client-nodejs / examples / logging.js View on Github external
fd = parseInt(file, 10)
      } else {
        fd = fs.openSync(file, 'a')
      }
    }

    console.log('*** log level=%d file=%s', level, file)
    client.updateLogging({
      level: level,
      file: fd
    })
    callback()
  }
}

var key = new Aerospike.Key(argv.namespace, argv.set, 'abc')

var operations = [
  header('Log: default settings'),
  put(key, { a: 1 }),
  get(key),

  header('Log: level=4(TRACE)'),
  log(5, null),
  put(key, { a: 2 }),
  get(key),

  header('Log: file=' + logfile),
  log(null, logfile),
  put(key, { a: 3 }),
  get(key),
github aerospike / aerospike-client-nodejs / examples / range_get.js View on Github external
function getStart (client, start, end, skip) {
    var done = getDone(client, start, end, skip)
    var i = start
    var s = 0

    for (; i <= end; i++) {
      var key = new Aerospike.Key(argv.namespace, argv.set, i)

      if (skip !== 0 && ++s >= skip) {
        s = 0
        done(null, {key: key}, true)
        continue
      }

      inFlight++
      deasync.loopWhile(function () { return inFlight > maxConcurrent })
      client.get(key, done)
    }
  }
github aerospike / aerospike-client-nodejs / examples / range_exists.js View on Github external
function existsStart (client, start, end, skip) {
    var done = existsDone(client, start, end, skip)
    var i = start
    var s = 0

    for (; i <= end; i++) {
      var key = new Aerospike.Key(argv.namespace, argv.set, i)

      if (skip !== 0 && ++s >= skip) {
        s = 0
        done(null, null, key, true)
        continue
      }

      inFlight++
      deasync.loopWhile(function () { return inFlight > maxConcurrent })
      client.exists(key, (err, result) => done(err, result, key))
    }
  }
github aerospike / aerospike-client-nodejs / examples / range_validate.js View on Github external
function getStart (client, start, end) {
    var done = getDone(client, start, end)
    var i = 0

    for (i = start; i <= end; i++) {
      var key = new Aerospike.Key(argv.namespace, argv.set, i)
      inFlight++
      deasync.loopWhile(function () { return inFlight > maxConcurrent })
      client.get(key, done)
    }
  }
github aerospike-community / aerospike-session-store-expressjs / lib / aerospike_store.js View on Github external
AerospikeStore.prototype._key = function (sid) {
    return new Aerospike.Key(this.as_namespace, this.as_set, sid)
  }