Skip to content

Instantly share code, notes, and snippets.

@alicebob
Created March 28, 2016 15:45
Show Gist options
  • Save alicebob/ed1ac1c1f192481cb819 to your computer and use it in GitHub Desktop.
Save alicebob/ed1ac1c1f192481cb819 to your computer and use it in GitHub Desktop.
basic Aerospike client
package main
import (
"fmt"
"sync"
as "github.com/aerospike/aerospike-client-go"
)
func main() {
client, err := as.NewClient("192.168.2.95", 3000)
if err != nil {
panic(err)
}
var (
namespace = "test"
setName = "bm"
)
writePolicy := as.NewWritePolicy(0, 0)
wg := sync.WaitGroup{}
for c := 0; c < 1; c++ {
key, err := as.NewKey(namespace, setName, fmt.Sprintf("key%d", c))
if err != nil {
panic(err)
}
wg.Add(1)
go func() {
for i := 0; ; i++ {
if i%1000 == 0 {
fmt.Printf("i: %d\n", i)
}
if err = client.Put(writePolicy, key, as.BinMap{"mybin": i}); err != nil {
fmt.Printf("client.Put: %v\n", err)
// panic(err)
}
}
wg.Done()
}()
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment