Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
})
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)
}
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)
}
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)
})
}
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)
}
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),
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)
}
}
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))
}
}
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)
}
}
AerospikeStore.prototype._key = function (sid) {
return new Aerospike.Key(this.as_namespace, this.as_set, sid)
}