Get operations
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
Use the Aerospike Go client to read items from a list bin without fetching the whole list. Read by index, range, rank, or value, or get the list size. Each operation runs on the server through Operate(). Some operations let you choose the return type, such as the index or the value.
ListGetOp: get by index
Retrieves a value by its index position. Supports negative indexing (-1 = last item).
// Get first item (index 0)record, err := client.Operate(nil, key, as.ListGetOp("tasks", 0),)
firstTask := record.Bins["tasks"].(string)fmt.Println("firstTask: ", firstTask)
// Get last item (index -1)record, err = client.Operate(nil, key, as.ListGetOp("tasks", -1),)ListGetRangeOp: get range of items
Retrieves a range of items from the list.
// Get first 10 items (from index 0, count 10)record, err := client.Operate(nil, key, as.ListGetRangeOp("tasks", 0, 10),)
results := record.Bins["tasks"].([]any)firstTask := results[0].(string)ListGetByIndexOp: get by index with return type
Similar to ListGetOp but with explicit return type control.
// Get index of a valuerecord, err := client.Operate(nil, key, as.ListGetByIndexOp("items", 1, as.ListReturnTypeIndex))ListGetByRankOp: get by rank
Retrieves an item by its rank (sorted by value).
// Get item with lowest value (rank 0)record, err := client.Operate(nil, key, as.ListGetByRankOp("scores", 0, as.ListReturnTypeValue),)ListGetByValueOp: Get by Value
Finds the index of items with a specific value.
// Find index of value "target"record, err := client.Operate(nil, key, as.ListGetByValueOp("items", "target", as.ListReturnTypeIndex),)
indices := record.Bins["items"].([]any) // All indices where value appearsListSizeOp: get list size
Returns the number of items in the list.
// Get list sizerecord, err := client.Operate(nil, key, as.ListSizeOp("tasks"),)
size := record.Bins["queue"].(int)fmt.Printf("Queue has %d tasks\n", size)Next steps
- List creation and setup
- List modify operations
- List range operations
- Quick reference: return types for list operations