2023-02-02 11:16:18 +00:00
|
|
|
package cache
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Cache[K comparable, V any] interface {
|
|
|
|
Get(ctx context.Context, key K) (V, bool)
|
2023-10-27 12:51:46 +00:00
|
|
|
Set(ctx context.Context, key K, val V)
|
|
|
|
GetExpireTime(ctx context.Context) time.Duration
|
|
|
|
Ttl(ctx context.Context, key K) time.Duration
|
2023-02-02 11:16:18 +00:00
|
|
|
Ver(ctx context.Context, key K) int
|
|
|
|
Flush(ctx context.Context)
|
2023-10-27 12:51:46 +00:00
|
|
|
Del(ctx context.Context, key ...K)
|
|
|
|
ClearExpired(ctx context.Context)
|
2023-02-02 11:16:18 +00:00
|
|
|
}
|
2023-10-29 10:46:01 +00:00
|
|
|
|
|
|
|
type Expend[K comparable, V any] interface {
|
|
|
|
Gets(ctx context.Context, k []K) (map[K]V, error)
|
|
|
|
Vers(ctx context.Context, k []K) map[K]int
|
|
|
|
Sets(ctx context.Context, m map[K]V)
|
|
|
|
}
|