MCPcopy Create free account
hub / github.com/allegro/bigcache / TestEntriesIteratorParallelAdd

Function TestEntriesIteratorParallelAdd

iterator_test.go:161–188  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func TestEntriesIteratorParallelAdd(t *testing.T) {
162 bc, err := New(context.Background(), DefaultConfig(1*time.Minute))
163 if err != nil {
164 panic(err)
165 }
166
167 wg := sync.WaitGroup{}
168 wg.Add(1)
169 go func() {
170 for i := 0; i < 10000; i++ {
171 err := bc.Set(strconv.Itoa(i), []byte("aaaaaaa"))
172 if err != nil {
173 panic(err)
174 }
175
176 runtime.Gosched()
177 }
178 wg.Done()
179 }()
180
181 for i := 0; i < 100; i++ {
182 iter := bc.Iterator()
183 for iter.SetNext() {
184 _, _ = iter.Value()
185 }
186 }
187 wg.Wait()
188}
189
190func TestParallelSetAndIteration(t *testing.T) {
191 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
DefaultConfigFunction · 0.85
SetMethod · 0.80
IteratorMethod · 0.80
SetNextMethod · 0.80
ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…