close
The Wayback Machine - https://web.archive.org/web/20201203122000/https://github.com/patrickmn/go-cache/issues/65
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

best way to extend time on an not expired object? #65

Open
dabba39 opened this issue Aug 4, 2017 · 2 comments
Open

best way to extend time on an not expired object? #65

dabba39 opened this issue Aug 4, 2017 · 2 comments
Labels

Comments

@dabba39
Copy link

@dabba39 dabba39 commented Aug 4, 2017

is there a helper function?

@dossy
Copy link

@dossy dossy commented Aug 23, 2017

It would be great to have complementary Increment and Decrement methods that refresh the expiration. Unfortunately, it's not safe to do a Replace(Get(), ...) as that would be a race (another goroutine could change the value between the time the Get() and the Replace() happens).

Perhaps just a new method to UpdateExpiration on a key would be sufficient, here? You could pass a time, or DefaultExpiration, or NoExpiration as appropriate. So:

func (c Cache) UpdateExpiration(k string, d time.Duration)

@dossy
Copy link

@dossy dossy commented Aug 23, 2017

Related: PR #20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.