-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
45 lines (37 loc) · 1.47 KB
/
types.go
File metadata and controls
45 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cache
import (
"context"
"time"
)
type Cache interface {
Set(ctx context.Context, key string, val any, expiration time.Duration) error
// Set(ctx context.Context, key string, val []byte, expiration time.Duration) error
// millis 毫秒数,过期时间
// Set(key string, val any, mills int64)
// Get 方法返回值
Get(ctx context.Context, key string) (any, error)
Delete(ctx context.Context, key string) error
// 同时会把被删除的数据返回
// Delete(key string) (any, error)
LoadAndDelete(ctx context.Context, key string) (any, error)
}
type CacheV2[T any] interface {
Set(ctx context.Context, key string, val T, expiration time.Duration) error
// Set(ctx context.Context, key string, val []byte, expiration time.Duration) error
// millis 毫秒数,过期时间
// Set(key string, val any, mills int64)
// Get 方法返回值
Get(ctx context.Context, key string) (T, error)
Delete(ctx context.Context, key string) error
}
//type CacheV3 interface {
// Set[T any](ctx context.Context, key string, val T, expiration time.Duration) error
// Set(ctx context.Context, key string, val []byte, expiration time.Duration) error
// millis 毫秒数,过期时间
// Set(key string, val any, mills int64)
// Get 方法返回值
//Get[T any](ctx context.Context, key string) (T, error)
//Delete(ctx context.Context, key string) error
// 同时会把被删除的数据返回
// Delete(key string) (any, error)
//}