blob: 0df9dfa89eaad66b1487e366b8e9dc69a2316cc4 (
plain) (
blame)
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
|
package cachedtvm
import "time"
type (
Option interface{ isCachedOption() }
cacheOptions struct {
ttl time.Duration
maxItems int64
}
OptionServiceTicket struct {
Option
cacheOptions
}
OptionUserTicket struct {
Option
cacheOptions
}
)
func WithCheckServiceTicket(ttl time.Duration, maxSize int) Option {
return OptionServiceTicket{
cacheOptions: cacheOptions{
ttl: ttl,
maxItems: int64(maxSize),
},
}
}
func WithCheckUserTicket(ttl time.Duration, maxSize int) Option {
return OptionUserTicket{
cacheOptions: cacheOptions{
ttl: ttl,
maxItems: int64(maxSize),
},
}
}
|