Skip to content

cache: add Close to stop the janitor - #195

Open
team-humaki wants to merge 1 commit into
patrickmn:masterfrom
team-humaki:fix/close-janitor
Open

cache: add Close to stop the janitor#195
team-humaki wants to merge 1 commit into
patrickmn:masterfrom
team-humaki:fix/close-janitor

Conversation

@team-humaki

Copy link
Copy Markdown

The janitor goroutine is only stopped from a finalizer, so caches with a cleanup interval never exit under testing/synctest (and callers have no way to stop it themselves).

Close() stops the janitor without waiting for GC. Safe to call more than once, including when no janitor was started. The stop channel is closed once so a later finalizer cannot block.

Fixes #185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using testing/synctest on cache with janitor goroutine will hang forever

1 participant