MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestMemoryList_Stat

Function TestMemoryList_Stat

internal/caches/list_memory_test.go:122–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestMemoryList_Stat(t *testing.T) {
123 list := caches.NewMemoryList()
124 _ = list.Init()
125 _ = list.Add("a", &caches.Item{
126 Key: "a1",
127 ExpiresAt: time.Now().Unix() + 3600,
128 HeaderSize: 1024,
129 })
130 _ = list.Add("b", &caches.Item{
131 Key: "b1",
132 ExpiresAt: time.Now().Unix() + 3600,
133 HeaderSize: 1024,
134 })
135 _ = list.Add("c", &caches.Item{
136 Key: "c1",
137 ExpiresAt: time.Now().Unix(),
138 HeaderSize: 1024,
139 })
140 _ = list.Add("d", &caches.Item{
141 Key: "d1",
142 ExpiresAt: time.Now().Unix() - 2,
143 HeaderSize: 1024,
144 })
145 result, _ := list.Stat(func(hash string) bool {
146 // 随机测试
147 return rand.Int()%2 == 0
148 })
149 t.Log(result)
150}
151
152func TestMemoryList_CleanPrefix(t *testing.T) {
153 list := caches.NewMemoryList()

Callers

nothing calls this directly

Calls 6

InitMethod · 0.95
AddMethod · 0.95
StatMethod · 0.95
NewMemoryListFunction · 0.92
UnixMethod · 0.80
LogMethod · 0.80

Tested by

no test coverage detected