mirror of
https://github.com/FloatTech/zbpdata.git
synced 2026-02-15 11:49:35 +09:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7aa2cbd0f5 | ||
|
|
fb80a176f0 | ||
|
|
50b189ebad | ||
|
|
ab10aa8a6b |
35
main.go
35
main.go
@@ -10,9 +10,11 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"unicode"
|
||||
"unsafe"
|
||||
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/fumiama/go-registry"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
)
|
||||
@@ -44,12 +46,33 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for i, fn := range files {
|
||||
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
|
||||
err = r.Set("data/"+fn, md5s[i])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
defer r.Close()
|
||||
for i := 0; i < 1024; i++ {
|
||||
err = r.Set("__setlock__", "fill")
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
fmt.Println("accqiring set lock, retry times:", i)
|
||||
}
|
||||
r.Close()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(files))
|
||||
for i, fn := range files {
|
||||
go func(i int, fn string) {
|
||||
defer wg.Done()
|
||||
for c := 0; c < 5; c++ {
|
||||
err = r.Set("data/"+fn, md5s[i])
|
||||
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if c >= 4 {
|
||||
panic("ERROR:" + err.Error() + "max retry times exceeded")
|
||||
} else {
|
||||
fmt.Println("ERROR:", err, ", retry times:", c)
|
||||
}
|
||||
process.SleepAbout1sTo2s()
|
||||
}
|
||||
}(i, fn)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user