本文整理汇总了Golang中github.com/siddontang/ledisdb/client/go/ledis.Config类的典型用法代码示例。如果您正苦于以下问题:Golang Config类的具体用法?Golang Config怎么用?Golang Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Parse()
if *number <= 0 {
panic("invalid number")
return
}
if *clients <= 0 || *number < *clients {
panic("invalid client number")
return
}
loop = *number / *clients
addr := fmt.Sprintf("%s:%d", *ip, *port)
cfg := new(ledis.Config)
cfg.Addr = addr
client = ledis.NewClient(cfg)
rand.Seed(time.Now().Unix())
if *tp == "write" {
benchZAdd()
benchSet()
} else if *tp == "read" {
setRead()
benchZSetRead()
} else {
fmt.Println("Unsupport type ")
}
}
示例2: main
func main() {
flag.Parse()
if *number <= 0 {
panic("invalid number")
return
}
if *clients <= 0 || *number < *clients {
panic("invalid client number")
return
}
loop = *number / *clients
addr := fmt.Sprintf("%s:%d", *ip, *port)
cfg := new(ledis.Config)
cfg.Addr = addr
cfg.MaxIdleConns = *clients
client = ledis.NewClient(cfg)
if *round <= 0 {
*round = 1
}
for i := 0; i < *round; i++ {
benchSet()
benchGet()
benchRandGet()
benchDel()
benchPushList()
benchRangeList10()
benchRangeList50()
benchRangeList100()
benchPopList()
benchHset()
benchHGet()
benchHRandGet()
benchHDel()
benchZAdd()
benchZIncr()
benchZRangeByRank()
benchZRangeByScore()
//rev is too slow in leveldb, rocksdb or other
//maybe disable for huge data benchmark
if *reverse == true {
benchZRevRangeByRank()
benchZRevRangeByScore()
}
benchZDel()
println("")
}
}
示例3: TestScan
func TestScan(t *testing.T) {
cfg := new(config.Config)
cfg.DataDir = "/tmp/test_scan"
cfg.Addr = "127.0.0.1:11185"
os.RemoveAll(cfg.DataDir)
s, err := NewApp(cfg)
if err != nil {
t.Fatal(err)
}
go s.Run()
defer s.Close()
cc := new(ledis.Config)
cc.Addr = cfg.Addr
cc.MaxIdleConns = 1
c := ledis.NewClient(cc)
defer c.Close()
testKVScan(t, c)
testHashScan(t, c)
testListScan(t, c)
testZSetScan(t, c)
testSetScan(t, c)
testBitScan(t, c)
}
示例4: main
func main() {
flag.Parse()
cfg := new(ledis.Config)
if len(*socket) > 0 {
cfg.Addr = *socket
} else {
cfg.Addr = fmt.Sprintf("%s:%d", *ip, *port)
}
cfg.MaxIdleConns = 1
c := ledis.NewClient(cfg)
setHistoryCapacity(100)
reg, _ := regexp.Compile(`'.*?'|".*?"|\S+`)
for {
cmd, err := line(fmt.Sprintf("%s> ", cfg.Addr))
if err != nil {
fmt.Printf("%s\n", err.Error())
return
}
cmds := reg.FindAllString(cmd, -1)
if len(cmds) == 0 {
continue
} else {
addHistory(cmd)
args := make([]interface{}, len(cmds[1:]))
for i := range args {
args[i] = strings.Trim(string(cmds[1+i]), "\"'")
}
r, err := c.Do(cmds[0], args...)
if err != nil {
fmt.Printf("%s", err.Error())
} else {
printReply(cmd, r)
}
fmt.Printf("\n")
}
}
}
示例5: main
func main() {
flag.Parse()
if *number <= 0 {
panic("invalid number")
return
}
if *clients <= 0 || *number < *clients {
panic("invalid client number")
return
}
loop = *number / *clients
addr := fmt.Sprintf("%s:%d", *ip, *port)
cfg := new(ledis.Config)
cfg.Addr = addr
client = ledis.NewClient(cfg)
benchSet()
benchIncr()
benchGet()
benchPushList()
benchRangeList10()
benchRangeList50()
benchRangeList100()
benchPopList()
benchHset()
benchHGet()
benchHIncr()
benchHDel()
benchZAdd()
benchZIncr()
benchZRangeByRank()
benchZRangeByScore()
benchZRevRangeByRank()
benchZRevRangeByScore()
benchZDel()
}
示例6: newTestLedisClient
func newTestLedisClient() {
cfg := new(ledis.Config)
cfg.Addr = "127.0.0.1:16380"
cfg.MaxIdleConns = 4
testLedisClient = ledis.NewClient(cfg)
}