Skip to content

Instantly share code, notes, and snippets.

@oshiro-kazuma
Created May 25, 2018 05:01
Show Gist options
  • Save oshiro-kazuma/b8a216e69548791598c7cd61d279d91f to your computer and use it in GitHub Desktop.
Save oshiro-kazuma/b8a216e69548791598c7cd61d279d91f to your computer and use it in GitHub Desktop.
aerospikeでincrement処理
package main
import (
"github.com/aerospike/aerospike-client-go"
"github.com/k0kubun/pp"
)
const NeverExpire = 0xFFFFFFFF
func main() {
client, err := aerospike.NewClientWithPolicyAndHost(nil, aerospike.NewHost("localhost", 3000))
if err != nil {
panic(err)
}
writePolicy := aerospike.NewWritePolicy(0, NeverExpire)
writePolicy.SendKey = true
client.DefaultWritePolicy = writePolicy
defer client.Close()
key, err := aerospike.NewKey("test", "TEST_INDEX", "test_float")
if err != nil {
panic(err)
}
value := 1.1
client.AddBins(writePolicy, key, aerospike.NewBin("payload", value))
record, err := client.Get(nil, key, "payload")
if err != nil {
panic(err)
}
pp.Println("record: ", record.Bins)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment