Skip to content

Instantly share code, notes, and snippets.

@abhi-bit
Created July 2, 2018 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhi-bit/c1ed794979650f851ee4829ea7f0ed37 to your computer and use it in GitHub Desktop.
Save abhi-bit/c1ed794979650f851ee4829ea7f0ed37 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/couchbase/gocb"
"sync"
)
func main() {
c, err := gocb.Connect("couchbase://localhost")
if err != nil {
fmt.Printf("connect err: %v\n", err)
return
}
err = c.Authenticate(gocb.PasswordAuthenticator{
Username: "Administrator",
Password: "password",
})
if err != nil {
fmt.Printf("Cluster auth, err: %v\n", err)
return
}
b, err := c.OpenBucket("bucket-1", "")
if err != nil {
fmt.Printf("bucket open err: %v\n", err)
return
}
var wg sync.WaitGroup
for r := 0; r < 32; r++ {
wg.Add(1)
go func(wg *sync.WaitGroup) {
defer wg.Done()
for i := 0; i < 1000*1000*100; i++ {
b.Upsert(fmt.Sprintf("%d", i), "", 0)
}
}(&wg)
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment