Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop printing message when doing a context shutdown #374

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bigcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bigcache
import (
"context"
"errors"
"fmt"
"time"
)

Expand Down Expand Up @@ -101,12 +100,13 @@ func newBigCache(ctx context.Context, config Config, clock clock) (*BigCache, er

if config.CleanWindow > 0 {
go func() {
logger := newLogger(config.Logger)
Comment on lines 102 to +103
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will solve the data race

Suggested change
go func() {
logger := newLogger(config.Logger)
logger := newLogger(config.Logger)
go func() {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! anyway, replacing ctx is also a good thing for the future.

ticker := time.NewTicker(config.CleanWindow)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
fmt.Println("ctx done, shutting down bigcache cleanup routine")
logger.Printf("ctx done, shutting down bigcache cleanup routine")
return
case t := <-ticker.C:
cache.cleanUp(uint64(t.Unix()))
Expand Down
Loading