MCPcopy
hub / github.com/go-gorm/gorm / TestLRUConcurrency

Function TestLRUConcurrency

tests/lru_test.go:351–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

349}
350
351func TestLRUConcurrency(t *testing.T) {
352 lc := lru.NewLRU[string, string](0, nil, 0)
353 wg := sync.WaitGroup{}
354 wg.Add(1000)
355 for i := 0; i < 1000; i++ {
356 go func(i int) {
357 lc.Add(fmt.Sprintf("key-%d", i/10), fmt.Sprintf("val-%d", i/10))
358 wg.Done()
359 }(i)
360 }
361 wg.Wait()
362 if lc.Len() != 100 {
363 t.Fatalf("length differs from expected")
364 }
365}
366
367func TestLRUInvalidateAndEvict(t *testing.T) {
368 var evicted int

Callers

nothing calls this directly

Calls 3

NewLRUFunction · 0.92
AddMethod · 0.80
LenMethod · 0.80

Tested by

no test coverage detected