fix(lru): fix length byte

This commit is contained in:
bandl 2021-10-25 11:08:18 +08:00
parent 3f4607fb58
commit 9298b77c7c
2 changed files with 12 additions and 12 deletions

View File

@ -1,10 +1,11 @@
package lru package lru
import ( import (
"gitee.com/timedb/wheatCache/pkg/proto"
"gitee.com/timedb/wheatCache/pkg/structure"
"sync" "sync"
"time" "time"
"gitee.com/timedb/wheatCache/pkg/proto"
"gitee.com/timedb/wheatCache/pkg/structure"
) )
type SingleWorkFunc func() interface{} type SingleWorkFunc func() interface{}
@ -22,8 +23,8 @@ var (
) )
const ( const (
defaultLruMaxSize = 1 * 1024 * 1024 * 1024 * 8 defaultLruMaxSize = 1 * 1024 * 1024 * 1024
defaultLruClearSize = 0.5 * 1024 * 1024 * 1024 * 8 defaultLruClearSize = 0.5 * 1024 * 1024 * 1024
defaultLruEventDriver = 2000 defaultLruEventDriver = 2000
) )
const ( const (

View File

@ -1,10 +1,11 @@
package util package util
import ( import (
"gitee.com/timedb/wheatCache/pkg/errorx"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
"gitee.com/timedb/wheatCache/pkg/errorx"
) )
// ParseSizeToBit // ParseSizeToBit
@ -17,16 +18,14 @@ func ParseSizeToBit(size string) (int64, error) {
sizeType := strings.ToUpper(unit[1]) sizeType := strings.ToUpper(unit[1])
switch { switch {
case sizeType == "BIT" || sizeType == "B": case sizeType == "BIT" || sizeType == "B":
return Res * 8, nil return Res, nil
case sizeType == "KB": case sizeType == "KB":
return Res * 1024 * 8, nil return Res * 1024, nil
case sizeType =="MB": case sizeType == "MB":
return Res * 1024 * 1024 * 8, nil return Res * 1024 * 1024, nil
case sizeType == "GB": case sizeType == "GB":
return Res * 1024 *1024 * 1024 * 8, nil return Res * 1024 * 1024 * 1024, nil
default: default:
return 0, errorx.New("your size is wrong") return 0, errorx.New("your size is wrong")
} }
} }