Skip to content

Commit

Permalink
Benchmark: Close redis client on each test iteration (-count=10)
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Aug 8, 2024
1 parent c164784 commit a2a09ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions httprateredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func (c *redisCounter) IsFallbackActivated() bool {
return c.fallbackActivated.Load()
}

func (c *redisCounter) Close() error {
return c.client.Close()
}

func (c *redisCounter) shouldFallback(err error) bool {
if err == nil {
return false
Expand Down
2 changes: 2 additions & 0 deletions httprateredis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestRedisCounter(t *testing.T) {
if err != nil {
t.Fatalf("redis not available: %v", err)
}
defer limitCounter.Close()

limitCounter.Config(1000, time.Minute)

Expand Down Expand Up @@ -166,6 +167,7 @@ func BenchmarkLocalCounter(b *testing.B) {
if err != nil {
b.Fatalf("redis not available: %v", err)
}
defer limitCounter.Close()

limitCounter.Config(1000, time.Minute)

Expand Down

0 comments on commit a2a09ff

Please sign in to comment.