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

Cannot write reliable tests for cache invalidation #176

Open
sgtsquiggs opened this issue Oct 27, 2022 · 0 comments
Open

Cannot write reliable tests for cache invalidation #176

sgtsquiggs opened this issue Oct 27, 2022 · 0 comments

Comments

@sgtsquiggs
Copy link
Contributor

I am testing a cache that I've written on top of eko/gocache. I need to wait for an invalidation to occur before I can move on to my next step. Currently I am waiting for the invalidation via:

	// wait for cache invalidation
	assert.Eventually(t, func() bool {
		_, err = s.localStore.Get(ctx, key)
		return err != nil
	}, 10*time.Second, 10*time.Millisecond, "timed out waiting for local store")

this loops for 10 seconds, checking every 10 milliseconds to see if the value has been ejected.

Usually this passes, but sometimes it does not pass. I cannot figure out why this sometimes fails.

I am using Invalidate and not Delete, so it is invalidating via the tag.

Local store in this case is Ristretto.

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

No branches or pull requests

1 participant