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 · 4 comments
Open

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

dabba39 opened this issue Aug 4, 2017 · 4 comments

Comments

@dabba39
Copy link

dabba39 commented Aug 4, 2017

is there a helper function?

@dossy
Copy link

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 commented Aug 23, 2017

Related: PR #20.

@glebteterin
Copy link

Any update on this one? Is the project dead?

@arp242
Copy link

arp242 commented Dec 23, 2020

As far as I know Patrick is no longer maintaining this @g-rad; I made a compatible fork which adds some commonly requested features over here: https://github.com/zgoat/zcache

v1 is designed to remain compatible with go-cache; so you can use it as a drop-in replacement. It adds Touch() to update expiry times.

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

No branches or pull requests

5 participants