wheat-cache/pkg/structure/define.go

78 lines
1.8 KiB
Go
Raw Normal View History

package structure
2021-09-24 22:48:08 +08:00
const (
2021-09-25 16:21:28 +08:00
defaultLen = 8 // 默认创建的 value 大小
2021-09-24 22:48:08 +08:00
)
2021-09-19 11:53:17 +08:00
2021-09-24 22:48:08 +08:00
type DynamicType int8
type UpdateLength int64
2021-09-24 22:48:08 +08:00
const (
DynamicNull = DynamicType(iota)
DynamicInt
DynamicFloat
DynamicString
)
2021-10-22 15:56:44 +08:00
type KeyBaseInterface interface {
SizeByte() int64
// RollBack TODO 事务相关, V2 实现
RollBack() error
// Begin 事务相关, V2 实现
Begin() error
// Comment 事务相关, V2 实现
Comment() error
Encode() ([]byte, error)
}
type StringXInterface interface {
KeyBaseInterface
Set(string) (string, UpdateLength)
Get() string
Add(int32) (string, error)
Reduce(int32) (string, error)
Setbit(int32, bool) UpdateLength
Getbit(int32) (bool, error)
Getrange(start, end int32) (string, error)
GetLength() int
}
type ListXInterface interface {
KeyBaseInterface
LPush(...string) UpdateLength
RPush(...string) UpdateLength
LPop(int) ([]string, UpdateLength)
RPop(int) ([]string, UpdateLength)
Index(int) (string, error)
Insert(int, bool, ...string) (UpdateLength, error)
Length() int
Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度
2021-10-23 15:17:57 +08:00
Range(start, end int) ([]string, error)
Remove(value string, count int) (int, UpdateLength)
2021-10-22 15:56:44 +08:00
}
type HashXInterface interface {
KeyBaseInterface
Set(key string, val string) UpdateLength
Get(key string) (string, error)
Del(key string) (UpdateLength, error)
Key() []string
Value() []string
Item() map[string]string
Add(renewal int, key ...string) (int, []string, error) // 访问影响成功的结果
SetX(key string, val string) (bool, UpdateLength) // 不存在才插入
Length() int
2021-11-15 23:57:39 +08:00
Range(consur, count int, regex string) []string
}
2021-11-29 00:16:04 +08:00
type ChannelXInterface interface {
KeyBaseInterface
Push(value string) UpdateLength
Pop() (string, UpdateLength)
Length() int
2021-11-29 23:35:18 +08:00
Clean() UpdateLength
2021-11-29 00:16:04 +08:00
}