19 lines
423 B
Go
19 lines
423 B
Go
package cache
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type (
|
|
LoadFunc func(ctx context.Context) (any, error)
|
|
)
|
|
|
|
type Cache interface {
|
|
Set(ctx context.Context, key string, value any)
|
|
SetEx(ctx context.Context, key string, value any, expire time.Duration)
|
|
Get(ctx context.Context, key string) (value any, ok bool)
|
|
Try(ctx context.Context, key string, cb LoadFunc) (value any, err error)
|
|
Del(ctx context.Context, key string)
|
|
}
|