-
Notifications
You must be signed in to change notification settings - Fork 199
/
cacherStub.go
72 lines (58 loc) · 1.75 KB
/
cacherStub.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package mock
type CacherStub struct {
ClearCalled func()
PutCalled func(key []byte, value interface{}) (evicted bool)
GetCalled func(key []byte) (value interface{}, ok bool)
HasCalled func(key []byte) bool
PeekCalled func(key []byte) (value interface{}, ok bool)
HasOrAddCalled func(key []byte, value interface{}) (ok, evicted bool)
RemoveCalled func(key []byte)
RemoveOldestCalled func()
KeysCalled func() [][]byte
LenCalled func() int
MaxSizeCalled func() int
RegisterHandlerCalled func(func(key []byte))
}
func (cs *CacherStub) Clear() {
cs.ClearCalled()
}
func (cs *CacherStub) Put(key []byte, value interface{}) (evicted bool) {
return cs.PutCalled(key, value)
}
func (cs *CacherStub) Get(key []byte) (value interface{}, ok bool) {
return cs.GetCalled(key)
}
func (cs *CacherStub) Has(key []byte) bool {
return cs.HasCalled(key)
}
func (cs *CacherStub) Peek(key []byte) (value interface{}, ok bool) {
return cs.PeekCalled(key)
}
func (cs *CacherStub) HasOrAdd(key []byte, value interface{}) (ok, evicted bool) {
return cs.HasOrAddCalled(key, value)
}
func (cs *CacherStub) Remove(key []byte) {
cs.RemoveCalled(key)
}
func (cs *CacherStub) RemoveOldest() {
cs.RemoveOldestCalled()
}
func (cs *CacherStub) Keys() [][]byte {
return cs.KeysCalled()
}
func (cs *CacherStub) Len() int {
return cs.LenCalled()
}
func (cs *CacherStub) MaxSize() int {
return cs.MaxSizeCalled()
}
func (cs *CacherStub) RegisterHandler(handler func(key []byte)) {
cs.RegisterHandlerCalled(handler)
}
// IsInterfaceNil returns true if there is no value under the interface
func (cs *CacherStub) IsInterfaceNil() bool {
if cs == nil {
return true
}
return false
}