コード例 #1
0
ファイル: cmd_handlers.go プロジェクト: alexyer/ghost
// get command
func getValue(c *client.GhostClient, args []string) (string, error) {
	if len(args) != 1 {
		return "", errors.New(fmt.Sprintf("wrong number of arguments to GET: need 1, get %d", len(args)))
	}

	return c.Get(args[0])
}
コード例 #2
0
ファイル: cmd_handlers.go プロジェクト: alexyer/ghost
// del command
func delValue(c *client.GhostClient, args []string) error {
	if len(args) != 1 {
		return errors.New(fmt.Sprintf("wrong number of arguments to DEL: need 1, get %d", len(args)))
	}

	c.Del(args[0])
	return nil
}
コード例 #3
0
ファイル: cmd_handlers.go プロジェクト: alexyer/ghost
// set command
func setValue(c *client.GhostClient, args []string) error {
	if len(args) != 2 {
		return errors.New(fmt.Sprintf("wrong number of arguments to SET: need 2, get %d", len(args)))
	}

	c.Set(args[0], args[1])
	return nil
}
コード例 #4
0
ファイル: cmd_handlers.go プロジェクト: alexyer/ghost
// ping command
func pingServer(c *client.GhostClient, args []string) (string, error) {
	if len(args) != 0 {
		return "", errors.New(fmt.Sprintf("wrong number of arguments to PING: need 0, get %d", len(args)))
	}

	reply, err := c.Ping()
	return reply.Values[0], err
}
コード例 #5
0
ファイル: cmd_handlers.go プロジェクト: alexyer/ghost
// get collection command
func getColl(c *client.GhostClient, args []string) error {
	if len(args) != 1 {
		return errors.New(fmt.Sprintf("wrong number of arguments to CGET: need 1, get %d", len(args)))
	}

	if _, err := c.CGet(args[0]); err != nil {
		return err
	}
	return nil
}
コード例 #6
0
ファイル: benchmark_server.go プロジェクト: alexyer/ghost
func populateTestDataServer(c *client.GhostClient, keys, vals []string) {
	var wg sync.WaitGroup
	for i := 0; i < requests; i++ {
		wg.Add(1)
		go func(i int) {
			c.Set(keys[i], vals[i])
			wg.Done()
		}(i)
	}
	wg.Wait()
	return
}
コード例 #7
0
ファイル: benchmark_server.go プロジェクト: alexyer/ghost
func benchmarkServerDel(c *client.GhostClient) result {
	var wg sync.WaitGroup
	keys, vals := initTestData("get", requests, size, keyrange)
	populateTestDataServer(c, keys, vals)

	start := time.Now()
	for i := 0; i < requests; i++ {
		wg.Add(1)
		go func(i int) {
			c.Del(keys[i])
			wg.Done()
		}(i)
	}
	wg.Wait()

	latency := time.Since(start)

	return result{
		totTime: latency,
		reqSec:  float64(requests) / latency.Seconds(),
	}
}