Best practices and tips
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
These best practices help you use Collection Data Type (CDT) operations in the Aerospike Go client efficiently and read their results correctly. They cover performance choices, such as server-side operations and batching, and the type assertions that CDT results need.
Performance considerations
- Use server-side operations: Prefer CDT operations over read-modify-write patterns.
- Batch operations: Combine multiple operations in a single
Operate()call. - Choose appropriate policies: Use UNORDERED when order doesn’t matter for better performance.
- Limit nested depth: Deep nesting can impact performance.
Type assertions for results
Results from CDT operations may need type assertions:
results := record.Bins["profile"].(as.OpResults)
// String valuesname := results[0].(string)
// Integer values (server returns as int)age := results[0].(int)
// Float valuesprice := results[0].(float64)
// Boolean valuesactive := results[0].(bool)
// Map valuesprofile := results[0].(map[any]any)
// List valuesitems := results[0].([]any)
// MapPair for KEY_VALUE return typepair := results[0].(as.MapPair)Next steps
- CDT operations overview: what CDT operations are and how
Operate()returns results - Quick reference: operations, return types, and context helpers
- Nested CDT operations
- Bin operations: combining several operations in one
Operate()call