mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
refactor project structure
This commit is contained in:
33
db/util_test.go
Normal file
33
db/util_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/hdt3213/godis/datastruct/dict"
|
||||
"github.com/hdt3213/godis/datastruct/lock"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func makeTestDB() *DB {
|
||||
return &DB{
|
||||
data: dict.MakeConcurrent(1),
|
||||
ttlMap: dict.MakeConcurrent(ttlDictSize),
|
||||
locker: lock.Make(lockerSize),
|
||||
}
|
||||
}
|
||||
|
||||
func toArgs(cmd ...string) [][]byte {
|
||||
args := make([][]byte, len(cmd))
|
||||
for i, s := range cmd {
|
||||
args[i] = []byte(s)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||
|
||||
func RandString(n int) string {
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
Reference in New Issue
Block a user