Created
July 2, 2018 12:45
-
-
Save abhi-bit/c1ed794979650f851ee4829ea7f0ed37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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