Namespace policy

The policy module defines policies and policy values that define the behavior of database commands. Most Client methods, including scans and queries, accept a policy object, that affects how the database command is executed, by specifying timeouts, transactional behavior, etc. Global defaults for specific types of database commands can also be set through the client config, when a new Client instance is created.

Different policies apply to different types of database commands:

Base policy BasePolicy class which defines common policy values that apply to all database commands (except InfoPolicy, AdminPolicy, MapPolicy and ListPolicy).

This module also defines global values for the following policy settings:

  • commitLevel - Specifies the number of replicas required to be successfully committed before returning success in a write operation to provide the desired consistency guarantee.
  • exists - Specifies the behavior for writing the record depending whether or not it exists.
  • gen - Specifies the behavior of record modifications with regard to the generation value.
  • key - Specifies the behavior for whether keys or digests should be sent to the cluster.
  • readModeAP - How duplicates should be consulted in a read operation.
  • readModeSC - Determines SC read consistency options.
  • replica - Specifies which partition replica to read from.
const Aerospike = require('aerospike')

const config = {
hosts: '192.168.33.10:3000'
}

const key = new Aerospike.Key('test', 'demo', 'k1')

Aerospike.connect(config)
.then(client => {
let record = {i: 1234}

// Override policy for put command
let policy = new Aerospike.policy.WritePolicy({
exists: Aerospike.policy.exists.CREATE,
key: Aerospike.policy.key.SEND,
socketTimeout: 0,
totalTimeout: 0
})

return client.put(key, record, {}, policy)
.then(() => client.close())
.catch(error => {
client.close()
if (error.code === Aerospike.status.ERR_RECORD_EXISTS) {
console.info('record already exists')
} else {
return Promise.reject(error)
}
})
})
.catch(error => console.error('Error:', error))

Index

Enumerations

Classes

Type Aliases

Functions

MMNEPVFCICPMFPCPTTAAATR