コード例 #1
0
func BenchmarkMemcachedClient(b *testing.B) {
	var conf = &config.Config{
		Servers:   []string{"10.0.0.162:5000", "127.0.0.1:11211", "10.0.0.162:5006"},
		InitConns: 5,
	}

	var client, err = memcached.NewMemcachedClient4T(conf)
	if err != nil {
		fmt.Printf("%+v\n", err)
		return
	}

	for i := 0; i < b.N*1000000; i++ {
		e := &common.Element{
			Key:   fmt.Sprintf("%s_%d", "10.0.0.162", i),
			Value: []byte("memcached client test"),
		}
		client.Set(e)
	}
}
コード例 #2
0
//execute 'go test -v memcached_client_test.go'
package test

import (
	"github.com/ningjh/memcached"
	"github.com/ningjh/memcached/common"
	"github.com/ningjh/memcached/config"

	"testing"
)

var conf = &config.Config{
	Servers: []string{"127.0.0.1:11211"},
}

var clientT, _ = memcached.NewMemcachedClient4T(conf)

func TestSet(t *testing.T) {
	e := &common.Element{
		Key:   "test1",
		Value: []byte("memcached client test1"),
	}

	e2 := &common.Element{
		Key:   "test2",
		Value: []byte("10"),
	}

	if err := clientT.Set(e); err != nil {
		t.Errorf("%s", err)
	}