I wanted to use a list as a bin value in aerospike. So, http://www.aerospike.com/docs/guide/cdt-list.html seems like a good option. But the client examples in golang https://github.com/aerospike/aerospike-client-go/blob/master/examples/list_map.go only shows a get and a put.
key, _ := as.NewKey(*shared.Namespace, *shared.Set, "listkey1")
client.Delete(shared.WritePolicy, key)
list := []string{"string1", "string2", "string3"}
bin := as.NewBin("listbin1", list)
client.PutBins(shared.WritePolicy, key, bin)
record, err := client.Get(shared.Policy, key, bin.Name)
shared.PanicOnError(err)
receivedList := record.Bins[bin.Name].([]interface{})
validateSize(3, len(receivedList))
validate("string1", receivedList[0])
validate("string2", receivedList[1])
validate("string3", receivedList[2])
What about all other APIs mentioned ? Such as how do I append to the list or get count of objects in the list etc. ? Any reference to any documentation would be appreciated.
Thanks in advance.
Don't expect examples to provide full documentation. Use the documentation for that.
Thanks to Flimzy for pointing the documentation. Maybe for future users who come accross this question, the following might help.
To perform a list operation, you need to use the following method and specify the operation:
https://godoc.org/github.com/aerospike/aerospike-client-go#Client.Operate
The Operate method takes an operation and to get an operation the List*Op methods are used (such as https://godoc.org/github.com/aerospike/aerospike-client-go#ListAppendOp)