-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
43 lines (38 loc) · 964 Bytes
/
types.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
32
33
34
35
36
37
38
39
40
41
42
43
package gcache
import "time"
const (
//NoExpiration mean It willl not be deleted by timeout
NoExpiration time.Duration = -1
//DefaultExpirationMarker identify is need set default expiration or not
DefaultExpirationMarker time.Duration = 0
//DefaultExpiration default expiration time
DefaultExpiration time.Duration = time.Duration(5 * time.Minute)
)
//Stats is a statistic holder for cache
type Stats struct {
ItemsCount,
GetSuccessNumber,
GetErrorNumber,
SetOrReplaceCount,
DeleteCount,
DeleteExpired,
SizeLimit int64
}
//Cacher interface for a storage
type Cacher interface {
//Get func for getting item
Get(name string) []byte
//Set or update item
SetOrUpdate(name string, value []byte, exp time.Duration)
//Purge cache cleanup but it still alive
Purge()
//Dead should stop cashing and clean
Dead()
//Return stats of cache
Statistic() Stats
}
//Item is a wrapper for storage
type Item struct {
Object []byte
Expiration int64
}