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

Feature request: Renaming #155

Open
codesoap opened this issue May 26, 2022 · 3 comments
Open

Feature request: Renaming #155

codesoap opened this issue May 26, 2022 · 3 comments

Comments

@codesoap
Copy link

There is no way to just change the key for an item. If I wanted to do this manually, I would have to use Delete and then Add, but upon deletion the OnEvicted function would be called, which I don't want.

My use case is a webservice, where the user can create some data entry using an assistant, which consists of multiple web pages. I use go-cache to store the already entered data from past pages until the assistant is finished. I use an XSRF-token (generated with golang.org/x/net/xsrftoken) as the key for the cache item. My issue with this is, that I cannot extend the validity of the token after one step of the assistant has been completed, so I would have to generate a new one, but copying the cache item, so that it can be found with the new token would be expensive (contains large files, which are deleted through OnEvicted).

Ideally I could also set a new duration upon renaming, but maybe this would be better as a separate feature.

@arp242
Copy link

arp242 commented May 26, 2022

I implemented this as Rename() in https://github.com/arp242/zcache; it doesn't update the expiry, so you'll have to do a second Touch() call to update that if you want it.

Since this hasn't been maintained for a few years, I've been maintaining a fork over there.

@arp242
Copy link

arp242 commented May 26, 2022

Oh, also your PR #153 from last month is implemented as DeleteAll() in zcache. I did that last year already (I made a new function because both calling and not calling onEvicted have valid use cases).

@codesoap
Copy link
Author

Thanks for the info and thanks for implementing Rename() so quickly. I'll check out your fork.

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

2 participants