You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
893 B

package cache
import (
"context"
"encoding"
)
const NotExists = CacheError("cache: not exists")
type CacheError string
func (e CacheError) Error() string { return string(e) }
type TextSerializable interface {
encoding.TextMarshaler
encoding.TextUnmarshaler
}
type BinarySerializable interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}
// Cache TODO random Lock(key, timeout), Unlock(key, random)
type Cache interface {
Set(ctx context.Context, key string, value any) error
Load(ctx context.Context, key string, target any) error
Del(ctx context.Context, keys ...string) error
}
type MultiLevelCache interface {
Cache
ForceLoad(ctx context.Context, key string, target any) error
}
// TODO CAS set value, atomic increment/decrement, 修改字段log复现
// CasSet 对比当前版本
func CasSet[V any](version int, value any) {
}
type Reply interface {
}