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

fix cache entry expiration - monotinic vs realtime #591

Merged
merged 3 commits into from
Sep 24, 2021

Conversation

yurique
Copy link

@yurique yurique commented Sep 23, 2021

Fixes #522

@yurique yurique changed the title fix cache entry expiration - monotinic vs realtime (fix #522) fix cache entry expiration - monotinic vs realtime Sep 23, 2021
@yurique
Copy link
Author

yurique commented Sep 23, 2021

The tests make sense to me, but would be great if someone could double-check :)


behavior of "get put with TTL"

it should "store the given key-value pair in the underlying cache with the given TTL, then get it back when not expired" in ticked {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's have another one like this, but with an IO.sleep between put and get. It'll be instant because of how ticked works.

Copy link
Author

Choose a reason for hiding this comment

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

Added a couple of tests with sleep.

@kubukoz
Copy link
Collaborator

kubukoz commented Sep 23, 2021

Thanks! I always mix up the two kinds of clocks, this whole thing reminded me what the difference is 😅

@kubukoz
Copy link
Collaborator

kubukoz commented Sep 24, 2021

Think we could remove expired keys if we read one, as a space optimization - but that can be a different PR :)

@kubukoz kubukoz merged commit c56ad7f into cb372:master Sep 24, 2021
@yurique yurique deleted the fix/entry-expiration branch September 24, 2021 00:29
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.

Get returns nothing when TTL set
2 participants