本文整理汇总了Golang中github.com/alexyer/ghost/client.GhostClient类的典型用法代码示例。如果您正苦于以下问题:Golang GhostClient类的具体用法?Golang GhostClient怎么用?Golang GhostClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GhostClient类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getValue
// 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: delValue
// 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: setValue
// 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: pingServer
// 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: getColl
// 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: populateTestDataServer
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: benchmarkServerDel
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(),
}
}