(t *testing.T)
| 647 | assertEqual(t, stats.DelMisses, int64(10)) |
| 648 | } |
| 649 | func TestCacheEntryStats(t *testing.T) { |
| 650 | t.Parallel() |
| 651 | |
| 652 | // given |
| 653 | cache, _ := New(context.Background(), Config{ |
| 654 | Shards: 8, |
| 655 | LifeWindow: time.Second, |
| 656 | MaxEntriesInWindow: 1, |
| 657 | MaxEntrySize: 256, |
| 658 | StatsEnabled: true, |
| 659 | }) |
| 660 | |
| 661 | cache.Set("key0", []byte("value")) |
| 662 | |
| 663 | for i := 0; i < 10; i++ { |
| 664 | _, err := cache.Get("key0") |
| 665 | noError(t, err) |
| 666 | } |
| 667 | |
| 668 | // then |
| 669 | keyMetadata := cache.KeyMetadata("key0") |
| 670 | assertEqual(t, uint32(10), keyMetadata.RequestCount) |
| 671 | } |
| 672 | |
| 673 | func TestCacheRestStats(t *testing.T) { |
| 674 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…