-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.go
31 lines (24 loc) · 1.23 KB
/
cache.go
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
package contract
import (
"context"
"time"
)
// CacheManager defines the main caching interface
// - Get methods can return domain.ErrCacheMiss
type CacheManager interface {
GetItem(ctx context.Context, key string) ([]byte, error)
SetItem(ctx context.Context, key string, data []byte) error
SetItemWithExpiration(ctx context.Context, key string, data []byte, expiration time.Duration) error
GetString(ctx context.Context, key string) (string, error)
SetString(ctx context.Context, key string, data string) error
SetStringWithExpiration(ctx context.Context, key string, data string, expiration time.Duration) error
GetInt(ctx context.Context, key string) (data int64, err error)
Increase(ctx context.Context, key string) error
GetStruct(ctx context.Context, key string, data interface{}) error
SetStruct(ctx context.Context, key string, data interface{}, expiration time.Duration) error
SetStructWithExpiration(ctx context.Context, key string, data interface{}, expiration time.Duration) error
GetExpiration(ctx context.Context, key string) (time.Duration, error)
SetExpiration(ctx context.Context, key string, expiration time.Duration) error
Delete(ctx context.Context, keys ...string) error
CleanAll(ctx context.Context) error
}