forked from grafana-cold-storage/metrictank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_mock.go
More file actions
43 lines (37 loc) · 735 Bytes
/
Copy pathcache_mock.go
File metadata and controls
43 lines (37 loc) · 735 Bytes
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 cache
import (
"github.com/raintank/metrictank/mdata/chunk"
"sync"
)
type MockCache struct {
sync.Mutex
AddCount int
CacheIfHotCount int
CacheIfHotCb func()
StopCount int
SearchCount int
}
func (mc *MockCache) Add(m string, t uint32, i chunk.IterGen) {
mc.Lock()
defer mc.Unlock()
mc.AddCount++
}
func (mc *MockCache) CacheIfHot(m string, t uint32, i chunk.IterGen) {
mc.Lock()
defer mc.Unlock()
mc.CacheIfHotCount++
if mc.CacheIfHotCb != nil {
mc.CacheIfHotCb()
}
}
func (mc *MockCache) Stop() {
mc.Lock()
defer mc.Unlock()
mc.StopCount++
}
func (mc *MockCache) Search(m string, f uint32, u uint32) *CCSearchResult {
mc.Lock()
defer mc.Unlock()
mc.SearchCount++
return nil
}