aerospike — Aerospike Client for Python

The Aerospike client enables you to build an application in Python with an Aerospike cluster as its database. The client manages the connections to the cluster and handles the transactions performed against it.

Data Model

At the top is the namespace, a container that has one set of policy rules for all its data, and is similar to the database concept in an RDBMS, only distributed across the cluster. A namespace is subdivided into sets, similar to tables.

Pairs of key-value data called bins make up records, similar to columns of a row in a standard RDBMS. Aerospike is schema-less, meaning that you do not need to define your bins in advance.

Records are uniquely identified by their key, and record metadata is contained in an in-memory primary index.

See also

Architecture Overview and Aerospike Data Model for more information about Aerospike.

Methods

aerospike.client(config)

Creates a new instance of the Client class. This client can Client.connect() to the cluster and perform operations against it, such as Client.put() and Client.get() records.

This is a wrapper function which calls the constructor for the Client class. The client may also be constructed by calling the constructor directly.

Parameters

config (dict) –

the client’s configuration.

  • hosts a required list of (address, port, [tls-name]) tuples identifying a node (or multiple nodes) in the cluster.
    The client will connect to the first available node in the list, the seed node, and will learn about the cluster and partition map from it. If tls-name is specified, it must match the tls-name specified in the node’s server configuration file and match the server’s CA certificate.

    Note

    TLS usage requires Aerospike Enterprise Edition

  • lua an optional dict containing the paths to two types of Lua modules
    • system_path
      The location of the system modules such as aerospike.lua
      Default: /usr/local/aerospike/lua
    • user_path
      The location of the user’s record and stream UDFs .
      Default: ./
  • policies a dict of policies
  • shm a dict with optional shared-memory cluster tending parameters
    Shared-memory cluster tending is on if the dict is provided. If multiple clients are instantiated talking to the same cluster the shm cluster-tending should be used.
    • max_nodes (int)
      Maximum number of nodes allowed. Pad so new nodes can be added without configuration changes
      Default: 16
    • max_namespaces (int)
      Similarly pad
      Default: 8
    • takeover_threshold_sec (int)
      Take over tending if the cluster hasn’t been checked for this many seconds
      Default: 30
    • shm_key
      Explicitly set the shm key for this client.
      If use_shared_connection is not set, or set to False, the user must provide a value for this field in order for shared memory to work correctly.
      If , and only if, use_shared_connection is set to True, the key will be implicitly evaluated per unique hostname, and can be inspected with Client.shm_key() .
      It is still possible to specify a key when using use_shared_connection = True.
      default: 0xA8000000
  • use_shared_connection (bool)
    Indicating whether this instance should share its connection to the Aerospike cluster with other client instances in the same process.
    Default: False
  • tls a dict of optional TLS configuration parameters.

    Note

    TLS usage requires Aerospike Enterprise Edition

    • enable (bool)
      Indicating whether tls should be enabled or not.
      Default: False
    • cafile (str)
      Path to a trusted CA certificate file. By default TLS will use system standard trusted CA certificates
    • capath (str)
      Path to a directory of trusted certificates. See the OpenSSL SSL_CTX_load_verify_locations manual page for more information about the format of the directory.
    • protocols (str)
      Specifies enabled protocols. This format is the same as Apache’s SSLProtocol documented at https://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol .
      If not specified the client will use “-all +TLSv1.2”.
    • cipher_suite (str)
      Specifies enabled cipher suites. The format is the same as OpenSSL’s Cipher List Format documented at https://www.openssl.org/docs/manmaster/apps/ciphers.html .
      If not specified the OpenSSL default cipher suite described in the ciphers documentation will be used. If you are not sure what cipher suite to select this option is best left unspecified
    • keyfile (str)
      Path to the client’s key for mutual authentication. By default mutual authentication is disabled.
    • keyfile_pw (str)
      Decryption password for the client’s key for mutual authentication. By default the key is assumed not to be encrypted.
    • cert_blacklist (str)
      Path to a certificate blacklist file. The file should contain one line for each blacklisted certificate. Each line starts with the certificate serial number expressed in hex. Each entry may optionally specify the issuer name of the certificate (serial numbers are only required to be unique per issuer). Example records: 867EC87482B2 /C=US/ST=CA/O=Acme/OU=Engineering/CN=Test Chain CA E2D4B0E570F9EF8E885C065899886461
    • certfile (str)
      Path to the client’s certificate chain file for mutual authentication. By default mutual authentication is disabled.
    • crl_check (bool)
      Enable CRL checking for the certificate chain leaf certificate. An error occurs if a suitable CRL cannot be found. By default CRL checking is disabled.
    • crl_check_all (bool)
      Enable CRL checking for the entire certificate chain. An error occurs if a suitable CRL cannot be found. By default CRL checking is disabled.
    • log_session_info (bool)
      Log session information for each connection.
    • for_login_only (bool)
      Log session information for each connection. Use TLS connections only for login authentication. All other communication with the server will be done with non-TLS connections.
      Default: False (Use TLS connections for all communication with server.)
  • send_bool_as an optional int that configures the client to write Python booleans as PY_BYTES_BLOB, integer, or the new server boolean type.
    One of the Send Bool Constants constant values.
    Example: {"send_bool_as", aerospike.aerospike.PY_BYTES}
    See Data_Mapping — Python Data Mappings for more information.
    Default: aerospike.PY_BYTES
  • serialization an optional instance-level tuple of (serializer, deserializer).
    Takes precedence over a class serializer registered with set_serializer().
  • thread_pool_size (int)
    Number of threads in the pool that is used in batch/scan/query commands.
    Default: 16
  • max_socket_idle (int)
    Maximum socket idle time in seconds. Connection pools will discard sockets that have been idle longer than the maximum. The value is limited to 24 hours (86400). It’s important to set this value to a few seconds less than the server’s proto-fd-idle-ms (default 60000 milliseconds, or 1 minute), so the client does not attempt to use a socket that has already been reaped by the server.
    Default: 0 seconds (disabled) for non-TLS connections, 55 seconds for TLS connections
  • max_conns_per_node (int)
    Maximum number of pipeline connections allowed for each node
  • tend_interval (int)
    Polling interval in milliseconds for tending the cluster
    Default: 1000
  • compression_threshold (int)
    Compress data for transmission if the object size is greater than a given number of bytes
    Default: 0, meaning ‘never compress’
    Deprecated, set this in the ‘write’ policy dictionary.
  • cluster_name (str)
    Only server nodes matching this name will be used when determining the cluster name.
  • rack_id (int)
    Rack id where this client instance resides.
    In order to enable this functionality, the rack_aware needs to be set to true, the Read Policies replica needs to be set to POLICY_REPLICA_PREFER_RACK. The server rack configuration must also be configured.

    Default: 0
  • rack_aware (bool)
    Track server rack data. This is useful when directing read operations to run on the same rack as the client.
    This is useful to lower cloud provider costs when nodes are distributed across different availability zones (represented as racks).
    In order to enable this functionality, the rack_id needs to be set to local rack, the read policy replica needs to be set to POLICY_REPLICA_PREFER_RACK. The server rack configuration must also be configured.

    Default: False
  • use_services_alternate (bool)
    Flag to signify if “services-alternate” should be used instead of “services”

    Default: False
  • connect_timeout (int)
    Initial host connection timeout in milliseconds. The timeout when opening a connection to the server host for the first time.
    Default: 1000.

Returns

an instance of the Client class.

import aerospike

# configure the client to first connect to a cluster node at 127.0.0.1
# the client will learn about the other nodes in the cluster from the
# seed node.
# in this configuration shared-memory cluster tending is turned on,
# which is appropriate for a multi-process context, such as a webserver
config = {
    'hosts':    [ ('127.0.0.1', 3000) ],
    'policies': {'read': {total_timeout': 1000}},
    'shm':      { }}
client = aerospike.client(config)

Changed in version 2.0.0.

import aerospike
import sys

# NOTE: Use of TLS Requires Aerospike Enterprise Server Version >= 3.11 and Python Client version 2.1.0 or greater
# To view Instructions for server configuration for TLS see https://www.aerospike.com/docs/guide/security/tls.html
tls_name = "some-server-tls-name"
tls_ip = "127.0.0.1"
tls_port = 4333

# If tls-name is specified, it must match the tls-name specified in the node’s server configuration file
# and match the server’s CA certificate.
tls_host_tuple = (tls_ip, tls_port, tls_name)
hosts = [tls_host_tuple]

# Example configuration which will use TLS with the specifed cafile
tls_config = {
    "cafile": "/path/to/cacert.pem",
    "enable": True
}

client = aerospike.client({
    "hosts": hosts,
    "tls": tls_config
})
try:
    client.connect()
except Exception as e:
    print(e)
    print("Failed to connect")
    sys.exit()

key = ('test', 'demo', 1)
client.put(key, {'aerospike': 'aerospike'})
print(client.get(key))
aerospike.null()

A type for distinguishing a server-side null from a Python None. Replaces the constant aerospike.null.

Returns

a type representing the server-side type as_null.

New in version 2.0.1.

aerospike.CDTWildcard()

A type representing a wildcard object. This type may only be used as a comparison value in operations. It may not be stored in the database.

Returns

a type representing a wildcard value.

import aerospike
from aerospike_helpers.operations import list_operations as list_ops

client = aerospike.client({'hosts': [('localhost', 3000)]}).connect()
key = 'test', 'demo', 1

#  get all values of the form [1, ...] from a list of lists.
#  For example if list is [[1, 2, 3], [2, 3, 4], [1, 'a']], this operation will match
#  [1, 2, 3] and [1, 'a']
operations = [list_ops.list_get_by_value('list_bin', [1, aerospike.CDTWildcard()], aerospike.LIST_RETURN_VALUE)]
_, _, bins = client.operate(key, operations)

New in version 3.5.0.

Note

This requires Aerospike Server 4.3.1.3 or greater

aerospike.CDTInfinite()

A type representing an infinte value. This type may only be used as a comparison value in operations. It may not be stored in the database.

Returns

a type representing an infinite value.

import aerospike
from aerospike_helpers.operations import list_operations as list_ops

client = aerospike.client({'hosts': [('localhost', 3000)]}).connect()
key = 'test', 'demo', 1

#  get all values of the form [1, ...] from a list of lists.
#  For example if list is [[1, 2, 3], [2, 3, 4], [1, 'a']], this operation will match
#  [1, 2, 3] and [1, 'a']
operations = [list_ops.list_get_by_value_range('list_bin', aerospike.LIST_RETURN_VALUE, [1],  [1, aerospike.CDTInfinite()])]
_, _, bins = client.operate(key, operations)

New in version 3.5.0.

Note

This requires Aerospike Server 4.3.1.3 or greater

aerospike.calc_digest(ns, set, key) bytearray

Calculate the digest of a particular key. See: Key Tuple.

Parameters
  • ns (str) – the namespace in the aerospike cluster.

  • set (str) – the set name.

  • key (str, int or bytearray) – the primary key identifier of the record within the set.

Returns

a RIPEMD-160 digest of the input tuple.

Return type

bytearray

import aerospike
import pprint

digest = aerospike.calc_digest("test", "demo", 1 )
pp.pprint(digest)

Serialization

Note

By default, the Client maps the supported types int, str, float, bytes, list, dict to matching aerospike server types (int, string, double, blob, list, map). When an unsupported type is encountered, the module uses cPickle to serialize and deserialize the data, storing it into as_bytes of type ‘Python’ (AS_BYTES_PYTHON).

The functions set_serializer() and set_deserializer() allow for user-defined functions to handle serialization, instead. The serialized data is stored as ‘Generic’ as_bytes of type (AS_BYTES_BLOB). The serialization config param of aerospike.client() registers an instance-level pair of functions that handle serialization.

aerospike.set_serializer(callback)

Register a user-defined serializer available to all Client instances.

Parameters

callback (callable) – the function to invoke for serialization.

See also

To use this function with Client.put() the argument to serializer should be aerospike.SERIALIZER_USER.

import aerospike
import json

def my_serializer(val):
    return json.dumps(val)

aerospike.set_serializer(my_serializer)

New in version 1.0.39.

aerospike.set_deserializer(callback)

Register a user-defined deserializer available to all Client instances. Once registered, all read methods (such as Client.get()) will run bins containing ‘Generic’ as_bytes of type (AS_BYTES_BLOB) through this deserializer.

Parameters

callback (callable) – the function to invoke for deserialization.

aerospike.unset_serializers()

Deregister the user-defined de/serializer available from Client instances.

New in version 1.0.53.

Note

Serialization Examples

The following example shows the three modes of serialization - built-in, class-level user functions, instance-level user functions:

import aerospike
import marshal
import json

def go_marshal(val):
    return marshal.dumps(val)

def demarshal(val):
    return marshal.loads(val)

def jsonize(val):
    return json.dumps(val)

def dejsonize(val):
    return json.loads(val)

aerospike.set_serializer(go_marshal)
aerospike.set_deserializer(demarshal)
config = {'hosts':[('127.0.0.1', 3000)]}
client = aerospike.client(config).connect()
config['serialization'] = (jsonize,dejsonize)
client2 = aerospike.client(config).connect()

for i in xrange(1, 4):
    try:
        client.remove(('test', 'demo', 'foo' + i))
    except:
        pass

bin_ = {'t': (1, 2, 3)} # tuple is an unsupported type
print("Use the built-in serialization (cPickle)")
client.put(('test','demo','foo1'), bin_)
(key, meta, bins) = client.get(('test','demo','foo1'))
print(bins)

print("Use the class-level user-defined serialization (marshal)")
client.put(('test','demo','foo2'), bin_, serializer=aerospike.SERIALIZER_USER)
(key, meta, bins) = client.get(('test','demo','foo2'))
print(bins)

print("Use the instance-level user-defined serialization (json)")
client2.put(('test','demo','foo3'), bin_, serializer=aerospike.SERIALIZER_USER)
# notice that json-encoding a tuple produces a list
(key, meta, bins) = client2.get(('test','demo','foo3'))
print(bins)
client.close()

The expected output is:

Use the built-in serialization (cPickle)
{'i': 321, 't': (1, 2, 3)}
Use the class-level user-defined serialization (marshal)
{'i': 321, 't': (1, 2, 3)}
Use the instance-level user-defined serialization (json)
{'i': 321, 't': [1, 2, 3]}

While AQL shows the records as having the following structure:

aql> select i,t from test.demo where PK='foo1'
+-----+----------------------------------------------+
| i   | t                                            |
+-----+----------------------------------------------+
| 321 | 28 49 31 0A 49 32 0A 49 33 0A 74 70 31 0A 2E |
+-----+----------------------------------------------+
1 row in set (0.000 secs)

aql> select i,t from test.demo where PK='foo2'
+-----+-------------------------------------------------------------+
| i   | t                                                           |
+-----+-------------------------------------------------------------+
| 321 | 28 03 00 00 00 69 01 00 00 00 69 02 00 00 00 69 03 00 00 00 |
+-----+-------------------------------------------------------------+
1 row in set (0.000 secs)

aql> select i,t from test.demo where PK='foo3'
+-----+----------------------------+
| i   | t                          |
+-----+----------------------------+
| 321 | 5B 31 2C 20 32 2C 20 33 5D |
+-----+----------------------------+
1 row in set (0.000 secs)

Logging

aerospike.set_log_handler(callback)

Enables aerospike log handler

Parameters

callback (optional callable) – the function used as the logging handler.

Note

The callback function must have the five parameters (level, func, path, line, msg)

import aerospike

from __future__ import print_function import aerospike

aerospike.set_log_level(aerospike.LOG_LEVEL_DEBUG) aerospike.set_log_handler(callback)

aerospike.set_log_level(log_level)

Declare the logging level threshold for the log handler.

Parameters

log_level (int) – one of the Log Level constant values.

Geospatial

aerospike.geodata([geo_data])

Helper for creating an instance of the GeoJSON class. Used to wrap a geospatial object, such as a point, polygon or circle.

Parameters

geo_data (dict) – a dict representing the geospatial data.

Returns

an instance of the aerospike.GeoJSON class.

import aerospike

# Create GeoJSON point using WGS84 coordinates.
latitude = 45.920278
longitude = 63.342222
loc = aerospike.geodata({'type': 'Point',
                         'coordinates': [longitude, latitude]})

New in version 1.0.54.

aerospike.geojson([geojson_str])

Helper for creating an instance of the GeoJSON class from a raw GeoJSON str.

Parameters

geojson_str (dict) – a str of raw GeoJSON.

Returns

an instance of the aerospike.GeoJSON class.

import aerospike

# Create GeoJSON point using WGS84 coordinates.
loc = aerospike.geojson('{"type": "Point", "coordinates": [-80.604333, 28.608389]}')

New in version 1.0.54.

Operators

Operators for the single-record, multi-operation transaction method Client.operate().

Note

Starting version 3.4.0, it is highly recommended to use the aerospike_helpers.operations package to create the arguments for Client.operate() and Client.operate_ordered() Old style operatiors are deprecated. The docs for old style operators were removed in client 6.0.0.

Policy Options

Commit Level Policy Options

Specifies the number of replicas required to be successfully committed before returning success in a write operation to provide the desired consistency guarantee.

aerospike.POLICY_COMMIT_LEVEL_ALL

Return succcess only after successfully committing all replicas

aerospike.POLICY_COMMIT_LEVEL_MASTER

Return succcess after successfully committing the master replica

AP Read Mode Policy Options

Read policy for AP (availability) namespaces.

aerospike.POLICY_READ_MODE_AP_ONE

Involve single node in the read operation.

aerospike.POLICY_READ_MODE_AP_ALL

Involve all duplicates in the read operation.

New in version 3.7.0.

SC Read Mode Policy Options

Read policy for SC (strong consistency) namespaces.

aerospike.POLICY_READ_MODE_SC_SESSION

Ensures this client will only see an increasing sequence of record versions. Server only reads from master. This is the default.

aerospike.POLICY_READ_MODE_SC_LINEARIZE

Ensures ALL clients will only see an increasing sequence of record versions. Server only reads from master.

aerospike.POLICY_READ_MODE_SC_ALLOW_REPLICA

Server may read from master or any full (non-migrating) replica. Increasing sequence of record versions is not guaranteed.

aerospike.POLICY_READ_MODE_SC_ALLOW_UNAVAILABLE

Server may read from master or any full (non-migrating) replica or from unavailable partitions. Increasing sequence of record versions is not guaranteed.

New in version 3.7.0.

Existence Policy Options

Specifies the behavior for writing the record depending whether or not it exists.

aerospike.POLICY_EXISTS_CREATE

Create a record, ONLY if it doesn’t exist

aerospike.POLICY_EXISTS_CREATE_OR_REPLACE

Completely replace a record if it exists, otherwise create it

aerospike.POLICY_EXISTS_IGNORE

Write the record, regardless of existence. (i.e. create or update)

aerospike.POLICY_EXISTS_REPLACE

Completely replace a record, ONLY if it exists

aerospike.POLICY_EXISTS_UPDATE

Update a record, ONLY if it exists

Generation Policy Options

Specifies the behavior of record modifications with regard to the generation value.

aerospike.POLICY_GEN_IGNORE

Write a record, regardless of generation

aerospike.POLICY_GEN_EQ

Write a record, ONLY if generations are equal

aerospike.POLICY_GEN_GT

Write a record, ONLY if local generation is greater-than remote generation

Key Policy Options

Specifies the behavior for whether keys or digests should be sent to the cluster.

aerospike.POLICY_KEY_DIGEST

Calculate the digest on the client-side and send it to the server

aerospike.POLICY_KEY_SEND

Send the key in addition to the digest. This policy causes a write operation to store the key on the server

Replica Options

Specifies which partition replica to read from.

aerospike.POLICY_REPLICA_SEQUENCE

Always try node containing master partition first. If connection fails and retry_on_timeout is true, try node containing prole partition. Currently restricted to master and one prole.

aerospike.POLICY_REPLICA_MASTER

Read from the partition master replica node

aerospike.POLICY_REPLICA_ANY

Distribute reads across nodes containing key’s master and replicated partition in round-robin fashion. Currently restricted to master and one prole.

aerospike.POLICY_REPLICA_PREFER_RACK

Try node on the same rack as the client first. If there are no nodes on the same rack, use POLICY_REPLICA_SEQUENCE instead.

rack_aware and rack_id must be set in the config argument of the client constructor in order to enable this functionality

Retry Policy Options

Specifies the behavior of failed operations.

aerospike.POLICY_RETRY_NONE

Only attempt an operation once

aerospike.POLICY_RETRY_ONCE

If an operation fails, attempt the operation one more time

Constants

TTL Constants

Specifies the TTL constants.

aerospike.TTL_NAMESPACE_DEFAULT

Use the namespace default TTL.

aerospike.TTL_NEVER_EXPIRE

Set TTL to never expire.

aerospike.TTL_DONT_UPDATE

Do not change the current TTL of the record.

Auth Mode Constants

Specifies the type of authentication to be used when communicating with the server.

aerospike.AUTH_INTERNAL

Use internal authentication only. Hashed password is stored on the server. Do not send clear password. This is the default.

aerospike.AUTH_EXTERNAL

Use external authentication (like LDAP). Specific external authentication is configured on server. If TLS defined, send clear password on node login via TLS. Throw exception if TLS is not defined.

aerospike.AUTH_EXTERNAL_INSECURE

Use external authentication (like LDAP). Specific external authentication is configured on server. Send clear password on node login whether or not TLS is defined. This mode should only be used for testing purposes because it is not secure authentication.

Scan Constants

aerospike.SCAN_PRIORITY

Deprecated since version 3.10.0: Scan priority has been replaced by the records_per_second policy see Scan Policies. Scan priority will be removed in a coming release.

aerospike.SCAN_STATUS_ABORTED

Deprecated since version 1.0.50: used by Client.scan_info()

aerospike.SCAN_STATUS_COMPLETED

Deprecated since version 1.0.50: used by Client.scan_info()

aerospike.SCAN_STATUS_INPROGRESS

Deprecated since version 1.0.50: used by Client.scan_info()

aerospike.SCAN_STATUS_UNDEF

Deprecated since version 1.0.50: used by Client.scan_info()

New in version 1.0.39.

Job Constants

aerospike.JOB_SCAN

Scan job type argument for the module parameter of Client.job_info()

aerospike.JOB_QUERY

Query job type argument for the module parameter of Client.job_info()

Job Statuses

aerospike.JOB_STATUS_UNDEF
aerospike.JOB_STATUS_INPROGRESS
aerospike.JOB_STATUS_COMPLETED

New in version 1.0.50.

Serialization Constants

aerospike.SERIALIZER_PYTHON

Use the cPickle serializer to handle unsupported types (default)

aerospike.SERIALIZER_USER

Use a user-defined serializer to handle unsupported types. Must have been registered for the aerospike class or configured for the Client object

aerospike.SERIALIZER_NONE

Do not serialize bins whose data type is unsupported

New in version 1.0.47.

Send Bool Constants

Specifies how the Python client will write Python booleans.

aerospike.PY_BYTES

Write Python Booleans as PY_BYTES_BLOBs.

aerospike.INTEGER

Write Python Booleans as integers.

aerospike.AS_BOOL

Write Python Booleans as as_bools.

List Write Flags

Flags used by list write flag.

aerospike.LIST_WRITE_DEFAULT

Default. Allow duplicate values and insertions at any index.

aerospike.LIST_WRITE_ADD_UNIQUE

Only add unique values.

aerospike.LIST_WRITE_INSERT_BOUNDED

Enforce list boundaries when inserting. Do not allow values to be inserted at index outside current list boundaries.

Note

Requires server version >= 4.3.0

aerospike.LIST_WRITE_NO_FAIL

Do not raise error if a list item fails due to write flag constraints (always succeed).

Note

Requires server version >= 4.3.0

aerospike.LIST_WRITE_PARTIAL

Allow other valid list items to be committed if a list item fails due to write flag constraints.

List Return Types

Return types used by various list operations.

aerospike.LIST_RETURN_NONE

Do not return any value.

aerospike.LIST_RETURN_INDEX

Return key index order.

aerospike.LIST_RETURN_REVERSE_INDEX

Return reverse key order.

aerospike.LIST_RETURN_RANK

Return value order.

aerospike.LIST_RETURN_REVERSE_RANK

Return reverse value order.

aerospike.LIST_RETURN_COUNT

Return count of items selected.

aerospike.LIST_RETURN_VALUE

Return value for single key read and value list for range read.

List Order

Flags used by list order.

aerospike.LIST_UNORDERED

List is not ordered. This is the default.

aerospike.LIST_ORDERED

Ordered list.

List Sort Flags

Flags used by list sort.

aerospike.LIST_SORT_DEFAULT

Default. Preserve duplicates when sorting the list.

aerospike.LIST_SORT_DROP_DUPLICATES

Drop duplicate values when sorting the list.

Map Write Flag

Flags used by map write flag.

Note

Requires server version >= 4.3.0

aerospike.MAP_WRITE_FLAGS_DEFAULT

Default. Allow create or update.

aerospike.MAP_WRITE_FLAGS_CREATE_ONLY

If the key already exists, the item will be denied. If the key does not exist, a new item will be created.

aerospike.MAP_WRITE_FLAGS_UPDATE_ONLY

If the key already exists, the item will be overwritten. If the key does not exist, the item will be denied.

aerospike.MAP_WRITE_FLAGS_NO_FAIL

Do not raise error if a map item is denied due to write flag constraints (always succeed).

aerospike.MAP_WRITE_FLAGS_PARTIAL

Allow other valid map items to be committed if a map item is denied due to write flag constraints.

Map Write Mode

Flags used by map write mode.

Note

This should only be used for Server version < 4.3.0

aerospike.MAP_UPDATE

Default. Allow create or update.

aerospike.MAP_CREATE_ONLY

If the key already exists, the item will be denied. If the key does not exist, a new item will be created.

aerospike.MAP_UPDATE_ONLY

If the key already exists, the item will be overwritten. If the key does not exist, the item will be denied.

Map Order

Flags used by map order.

aerospike.MAP_UNORDERED

Map is not ordered. This is the default.

aerospike.MAP_KEY_ORDERED

Order map by key.

aerospike.MAP_KEY_VALUE_ORDERED

Order map by key, then value.

Map Return Types

Return types used by various map operations.

aerospike.MAP_RETURN_NONE

Do not return any value.

aerospike.MAP_RETURN_INDEX

Return key index order.

aerospike.MAP_RETURN_REVERSE_INDEX

Return reverse key order.

aerospike.MAP_RETURN_RANK

Return value order.

aerospike.MAP_RETURN_REVERSE_RANK

Return reserve value order.

aerospike.MAP_RETURN_COUNT

Return count of items selected.

aerospike.MAP_RETURN_KEY

Return key for single key read and key list for range read.

aerospike.MAP_RETURN_VALUE

Return value for single key read and value list for range read.

aerospike.MAP_RETURN_KEY_VALUE

Return key/value items. Note that key/value pairs will be returned as a list of tuples (i.e. [(key1, value1), (key2, value2)])

Bitwise Write Flags

aerospike.BIT_WRITE_DEFAULT

Allow create or update (default).

aerospike.BIT_WRITE_CREATE_ONLY

If bin already exists the operation is denied. Otherwise the bin is created.

aerospike.BIT_WRITE_UPDATE_ONLY

If bin does not exist the operation is denied. Otherwise the bin is updated.

aerospike.BIT_WRITE_NO_FAIL

Do not raise error if operation failed.

aerospike.BIT_WRITE_PARTIAL

Allow other valid operations to be committed if this operation is denied due to flag constraints. i.e. If the number of bytes from the offset to the end of the existing Bytes bin is less than the specified number of bytes, then only apply operations from the offset to the end.

New in version 3.9.0.

Bitwise Resize Flags

aerospike.BIT_RESIZE_DEFAULT

Add/remove bytes from the end (default).

aerospike.BIT_RESIZE_FROM_FRONT

Add/remove bytes from the front.

aerospike.BIT_RESIZE_GROW_ONLY

Only allow the bitmap size to increase.

aerospike.BIT_RESIZE_SHRINK_ONLY

Only allow the bitmap size to decrease.

New in version 3.9.0.

Bitwise Overflow

aerospike.BIT_OVERFLOW_FAIL

Operation will fail on overflow/underflow.

aerospike.BIT_OVERFLOW_SATURATE

If add or subtract ops overflow/underflow, set to max/min value. Example: MAXINT + 1 = MAXINT.

aerospike.BIT_OVERFLOW_WRAP

If add or subtract ops overflow/underflow, wrap the value. Example: MAXINT + 1 = MININT.

New in version 3.9.0.

HyperLogLog Write Flags

aerospike.HLL_WRITE_DEFAULT

Default. Allow create or update.

aerospike.HLL_WRITE_CREATE_ONLY

If the bin already exists, the operation will be denied. If the bin does not exist, a new bin will be created.

aerospike.HLL_WRITE_UPDATE_ONLY

If the bin already exists, the bin will be overwritten. If the bin does not exist, the operation will be denied.

aerospike.HLL_WRITE_NO_FAIL

Do not raise error if operation is denied.

aerospike.HLL_WRITE_ALLOW_FOLD

Allow the resulting set to be the minimum of provided index bits. For intersect_counts and similarity, allow the usage of less precise HLL algorithms when minhash bits of all participating sets do not match.

New in version 3.11.0.

Write Expression Flags

Flags used by expression_write.

aerospike.EXP_WRITE_DEFAULT

Default. Allow create or update.

aerospike.EXP_WRITE_CREATE_ONLY

If bin does not exist, a new bin will be created. If bin exists, the operation will be denied. If bin exists, fail with BinExistsError when EXP_WRITE_POLICY_NO_FAIL is not set.

aerospike.EXP_WRITE_UPDATE_ONLY

If bin exists, the bin will be overwritten. If bin does not exist, the operation will be denied. If bin does not exist, fail with BinNotFound when EXP_WRITE_POLICY_NO_FAIL is not set.

aerospike.EXP_WRITE_ALLOW_DELETE

If expression results in nil value, then delete the bin. Otherwise, return OpNotApplicable when EXP_WRITE_POLICY_NO_FAIL is not set.

aerospike.EXP_WRITE_POLICY_NO_FAIL

Do not raise error if operation is denied.

aerospike.EXP_WRITE_EVAL_NO_FAIL

Ignore failures caused by the expression resolving to unknown or a non-bin type.

Read Expression Flags

Flags used by expression_read.

aerospike.EXP_READ_DEFAULT

Default.

aerospike.EXP_READ_EVAL_NO_FAIL

Ignore failures caused by the expression resolving to unknown or a non-bin type.

Bin Types

aerospike.AS_BYTES_UNDEF

(int): 0

aerospike.AS_BYTES_INTEGER

(int): 1

aerospike.AS_BYTES_DOUBLE

(int): 2

aerospike.AS_BYTES_STRING

(int): 3

aerospike.AS_BYTES_BLOB

(int): 4

aerospike.AS_BYTES_JAVA

(int): 7

aerospike.AS_BYTES_CSHARP

(int): 8

aerospike.AS_BYTES_PYTHON

(int): 9

aerospike.AS_BYTES_RUBY

(int): 10

aerospike.AS_BYTES_PHP

(int): 11

aerospike.AS_BYTES_ERLANG

(int): 12

aerospike.AS_BYTES_HLL

(int): 18

aerospike.AS_BYTES_MAP

(int): 19

aerospike.AS_BYTES_LIST

(int): 20

aerospike.AS_BYTES_GEOJSON

(int): 23

aerospike.AS_BYTES_TYPE_MAX

(int): 24

Miscellaneous

aerospike.__version__

A str containing the module’s version.

New in version 1.0.54.

aerospike.UDF_TYPE_LUA

UDF type is LUA (which is the only UDF type).

aerospike.INDEX_STRING

An index whose values are of the aerospike string data type.

aerospike.INDEX_NUMERIC

An index whose values are of the aerospike integer data type.

aerospike.INDEX_GEO2DSPHERE

An index whose values are of the aerospike GetJSON data type.

See also

Data Types.

aerospike.INDEX_TYPE_LIST

Index a bin whose contents is an aerospike list.

aerospike.INDEX_TYPE_MAPKEYS

Index the keys of a bin whose contents is an aerospike map.

aerospike.INDEX_TYPE_MAPVALUES

Index the values of a bin whose contents is an aerospike map.

Log Level

aerospike.LOG_LEVEL_TRACE
aerospike.LOG_LEVEL_DEBUG
aerospike.LOG_LEVEL_INFO
aerospike.LOG_LEVEL_WARN
aerospike.LOG_LEVEL_ERROR
aerospike.LOG_LEVEL_OFF

Privileges

Permission codes define the type of permission granted for a user’s role.

aerospike.PRIV_READ

The user is granted read access.

aerospike.PRIV_WRITE

The user is granted write access.

aerospike.PRIV_READ_WRITE

The user is granted read and write access.

aerospike.PRIV_READ_WRITE_UDF

The user is granted read and write access, and the ability to invoke UDFs.

aerospike.PRIV_SYS_ADMIN

The user is granted the ability to perform system administration operations. Global scope only.

aerospike.PRIV_USER_ADMIN

The user is granted the ability to perform user administration operations. Global scope only.

aerospike.PRIV_DATA_ADMIN

User can perform systems administration functions on a database that do not involve user administration. Examples include setting dynamic server configuration. Global scope only.

aerospike.PRIV_TRUNCATE

User can truncate data only. Requires server 6.0+

aerospike.PRIV_UDF_ADMIN

User can perform user defined function(UDF) administration actions. Examples include create/drop UDF. Global scope only. Global scope only. Requires server version 6.0+

aerospike.PRIV_SINDEX_ADMIN

User can perform secondary index administration actions. Examples include create/drop index. Global scope only. Requires server version 6.0+

Regex Flag Values

Flags used by the aerospike_operation_helpers.expressions.base.CmpRegex Aerospike expression. See aerospike_helpers.expressions package for more information.

aerospike.REGEX_NONE

Use default behavior.

aerospike.REGEX_ICASE

Do not differentiate case.

aerospike.REGEX_EXTENDED

Use POSIX Extended Regular Expression syntax when interpreting regex.

aerospike.REGEX_NOSUB

Do not report position of matches.

aerospike.REGEX_NEWLINE

Match-any-character operators don’t match a newline.