Skip to main content
Version: 0.0.3

Getting Started

Installation

pip install aerospike-py

Requirements: Python 3.10+ (CPython)

Quick Start

import aerospike_py as aerospike
from aerospike_py import Record

with aerospike.client({
"hosts": [("127.0.0.1", 3000)],
}).connect() as client:
key: tuple[str, str, str] = ("test", "demo", "user1")

# Write
client.put(key, {"name": "Alice", "age": 30})

# Read
record: Record = client.get(key)
print(record.bins) # {"name": "Alice", "age": 30}
print(record.meta.gen) # 1

# Update
client.increment(key, "age", 1)

# Delete
client.remove(key)

Policies & Metadata

import aerospike_py as aerospike

key = ("test", "demo", "user1")

# TTL (seconds)
client.put(key, {"val": 1}, meta={"ttl": 300})

# Create only (fail if exists)
client.put(key, {"val": 1}, policy={"exists": aerospike.POLICY_EXISTS_CREATE_ONLY})

# Optimistic locking
record = client.get(key)
client.put(
key,
{"val": record.bins["val"] + 1},
meta={"gen": record.meta.gen},
policy={"gen": aerospike.POLICY_GEN_EQ},
)

Next Steps

TopicDescription
Read OperationsGet, select, exists, batch read
Write OperationsPut, update, delete, operate, batch operate
CDT OperationsAtomic list & map operations
NumPy BatchZero-copy columnar batch reads
QuerySecondary index queries
Expression FiltersServer-side filtering
ConfigurationConnection, pool, timeouts
API ReferenceFull method signatures
TypesNamedTuple / TypedDict definitions