node.js - How to set ttl for aerospike record ttl through NodeJS Client -
i using nodejs client aerospike, , trying set ttl record, below code same.
insert(key, value) { return new promise(function (resolve, reject) { aerospike.put(key, value, function (err) { if (err.code !== aerospikestatus.aerospike_ok) { reject("failed insert in secondary storage"); } else { resolve(true); } }); }); }
i following official documentation, unable find way set ttl through nodejs client. happen know how same?
(http://www.aerospike.com/docs/client/nodejs/usage/kvs/write.html)
actually, there 4 parameters of put function, (key, record, metadata, policy).
can see example here. following simple code show how set ttl:
var key = new aerospike.key(ns, set, "ask") var rec = { as_bin: 'bin-content' } var meta = { ttl: 1000 } var policy = { key: aerospike.policy.key.send } client.put(key, rec, meta, policy, function (error) { if (error) { console.log('error: %s', error.message) } else { console.log('record written database successfully.') } })
Comments
Post a Comment