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.
 
 

37 lines
716 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
}