Skip to content

test: add test for cache's ttl behavior#3218

Open
tstirrat15 wants to merge 1 commit into
mainfrom
tstirrat/add-cache-ttl-test
Open

test: add test for cache's ttl behavior#3218
tstirrat15 wants to merge 1 commit into
mainfrom
tstirrat/add-cache-ttl-test

Conversation

@tstirrat15

Copy link
Copy Markdown
Contributor

Description

We had questions about whether TTL behavior was working as expected in the new caching library so I wrote a test.

Changes

  • Add TTL test
  • Remove Wait() from interface, since the implementation that required it (ristretto) no longer exists.

Testing

Review.

@tstirrat15
tstirrat15 marked this pull request as ready for review July 8, 2026 12:57
@tstirrat15
tstirrat15 requested a review from a team as a code owner July 8, 2026 12:57
@github-actions github-actions Bot added area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

github-actions[bot]

This comment was marked as off-topic.

miparnisari
miparnisari previously approved these changes Jul 10, 2026
@miparnisari
miparnisari force-pushed the tstirrat/add-cache-ttl-test branch from 7230fde to fa34281 Compare July 10, 2026 20:08
@miparnisari
miparnisari enabled auto-merge (squash) July 10, 2026 20:08
@tstirrat15
tstirrat15 force-pushed the tstirrat/add-cache-ttl-test branch from fa34281 to bb5e67e Compare July 13, 2026 20:17
@tstirrat15
tstirrat15 force-pushed the tstirrat/add-cache-ttl-test branch from bb5e67e to 75509d4 Compare July 14, 2026 13:41
Comment thread pkg/cache/cache_test.go

cache.Close()

synctest.Wait()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would've expected this above the cache.Get?

@tstirrat15
tstirrat15 force-pushed the tstirrat/add-cache-ttl-test branch from 75509d4 to a57e24c Compare July 14, 2026 21:17
Comment thread pkg/cache/cache_test.go

cache.Close()

synctest.Wait()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@miparnisari miparnisari changed the title chore: add test for ttl behavior test: add test for cache's ttl behavior Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) Skip-Changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants