forked from p93542168/wheat-cache
feat(value): update value
This commit is contained in:
parent
3d7df7149a
commit
bcacc83df6
|
@ -1,7 +1,7 @@
|
||||||
package structure
|
package structure
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultLen = 32 // 默认创建的 value 大小
|
defaultLen = 8 // 默认创建的 value 大小
|
||||||
)
|
)
|
||||||
|
|
||||||
type DynamicType int8
|
type DynamicType int8
|
||||||
|
|
|
@ -3,10 +3,9 @@ package structure
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Value 提供一个基础的 动态类型
|
// Value 提供一个基础的 动态类型
|
||||||
|
@ -26,7 +25,7 @@ func NewValue() *Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Value) GetLength() int {
|
func (v *Value) GetLength() int {
|
||||||
return v.length
|
return len(v.val)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Value) GetDynamicType() DynamicType {
|
func (v *Value) GetDynamicType() DynamicType {
|
||||||
|
@ -113,3 +112,10 @@ func (v *Value) InferValue(str string) {
|
||||||
|
|
||||||
v.SetString(str)
|
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