!76 修复 内存计算错误问题

Merge pull request !76 from bandl/fix-length
This commit is contained in:
bandl 2021-10-25 03:21:05 +00:00 committed by Gitee
commit 5d7df024e4
2 changed files with 12 additions and 12 deletions

View File

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

View File

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