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

Function TestParallelSetAndIteration

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

Source from the content-addressed store, hash-verified

188}
189
190func TestParallelSetAndIteration(t *testing.T) {
191 t.Parallel()
192
193 rand.Seed(0)
194
195 cache, _ := New(context.Background(), Config{
196 Shards: 1,
197 LifeWindow: time.Second,
198 MaxEntriesInWindow: 100,
199 MaxEntrySize: 256,
200 HardMaxCacheSize: 1,
201 Verbose: true,
202 })
203
204 entrySize := 1024 * 100
205 ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
206 defer cancel()
207
208 wg := sync.WaitGroup{}
209 wg.Add(2)
210
211 go func() {
212 defer func() {
213 err := recover()
214 // no panic
215 assertEqual(t, err, nil)
216 }()
217
218 defer wg.Done()
219
220 isTimeout := false
221
222 for {
223 if isTimeout {
224 break
225 }
226 select {
227 case <-ctx.Done():
228 isTimeout = true
229 default:
230 err := cache.Set(strconv.Itoa(rand.Intn(100)), blob('a', entrySize))
231 noError(t, err)
232 }
233 }
234 }()
235
236 go func() {
237 defer func() {
238 err := recover()
239 // no panic
240 assertEqual(t, nil, err)
241 }()
242
243 defer wg.Done()
244
245 isTimeout := false
246
247 for {

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
SetMethod · 0.80
IteratorMethod · 0.80
SetNextMethod · 0.80
assertEqualFunction · 0.70
blobFunction · 0.70
noErrorFunction · 0.70
ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…