test: add test for cache's ttl behavior#3218
Open
tstirrat15 wants to merge 1 commit into
Open
Conversation
tstirrat15
marked this pull request as ready for review
July 8, 2026 12:57
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
miparnisari
approved these changes
Jul 8, 2026
miparnisari
previously approved these changes
Jul 10, 2026
miparnisari
force-pushed
the
tstirrat/add-cache-ttl-test
branch
from
July 10, 2026 20:08
7230fde to
fa34281
Compare
miparnisari
enabled auto-merge (squash)
July 10, 2026 20:08
tstirrat15
force-pushed
the
tstirrat/add-cache-ttl-test
branch
from
July 13, 2026 20:17
fa34281 to
bb5e67e
Compare
tstirrat15
force-pushed
the
tstirrat/add-cache-ttl-test
branch
from
July 14, 2026 13:41
bb5e67e to
75509d4
Compare
ecordell
reviewed
Jul 14, 2026
|
|
||
| cache.Close() | ||
|
|
||
| synctest.Wait() |
Contributor
There was a problem hiding this comment.
I would've expected this above the cache.Get?
tstirrat15
force-pushed
the
tstirrat/add-cache-ttl-test
branch
from
July 14, 2026 21:17
75509d4 to
a57e24c
Compare
ecordell
reviewed
Jul 15, 2026
|
|
||
| cache.Close() | ||
|
|
||
| synctest.Wait() |
Contributor
There was a problem hiding this comment.
Suggested change
| synctest.Wait() |
Looked at this more and I think it can just be removed. The synctest.Test wrapper already waits for all goroutines to exit so this is redundant.
I thought moving it after the time.Sleep would make sense so that any goroutines that fire in otter machinery for TTLs have a chance to run before the cache.Get, but it looks like the TTL check fires syncronously when you call cache.Get so clock advance is enough.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We had questions about whether TTL behavior was working as expected in the new caching library so I wrote a test.
Changes
Wait()from interface, since the implementation that required it (ristretto) no longer exists.Testing
Review.