feat(value): update value
This commit is contained in:
parent
3d7df7149a
commit
bcacc83df6
|
@ -1,7 +1,7 @@
|
|||
package structure
|
||||
|
||||
const (
|
||||
defaultLen = 32 // 默认创建的 value 大小
|
||||
defaultLen = 8 // 默认创建的 value 大小
|
||||
)
|
||||
|
||||
type DynamicType int8
|
||||
|
|
|
@ -3,10 +3,9 @@ package structure
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||
)
|
||||
|
||||
// Value 提供一个基础的 动态类型
|
||||
|
@ -26,7 +25,7 @@ func NewValue() *Value {
|
|||
}
|
||||
|
||||
func (v *Value) GetLength() int {
|
||||
return v.length
|
||||
return len(v.val)
|
||||
}
|
||||
|
||||
func (v *Value) GetDynamicType() DynamicType {
|
||||
|
@ -113,3 +112,10 @@ func (v *Value) InferValue(str string) {
|
|||
|
||||
v.SetString(str)
|
||||
}
|
||||
|
||||
// ChangeValueLength 根据类型推断 change 的大小
|
||||
func (v *Value) ChangeValueLength(f func()) int64 {
|
||||
startLen := v.GetLength()
|
||||
f()
|
||||
return int64(v.GetLength() - startLen)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue