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

Suggestion: add a Command for Removing Key Expire #284

Closed
taroim opened this issue Sep 11, 2023 · 9 comments
Closed

Suggestion: add a Command for Removing Key Expire #284

taroim opened this issue Sep 11, 2023 · 9 comments

Comments

@taroim
Copy link

taroim commented Sep 11, 2023

When we use the EXPIRE command to set a lifespan for a particular key, we would like the ability to remove the key's lifespan using a command similar to PERSIST, ensuring that the key remains in existence indefinitely and no longer automatically expires.

@Jeremy-Run
Copy link
Contributor

If I understand correctly, db.Put(k, v) again will give you the effect you want.

@taroim
Copy link
Author

taroim commented Sep 11, 2023

yes, it can achieve the desired outcome, but to clear the expiration time, you would need to execute the Put command, which involves overwriting the data. This can lead to increased network transfer overhead, especially when dealing with a large amount of data.

@Jeremy-Run
Copy link
Contributor

If this function is to be implemented, it will be designed as follows:

func demo(k) {
	v, _ := db.Get(key)
	db.Put(k, v)
}

Whether the built-in implementation or the external call has similar overhead to the db.
@taroim @roseduan I can do this if necessary

@roseduan
Copy link
Collaborator

yes, it can achieve the desired outcome, but to clear the expiration time, you would need to execute the Put command, which involves overwriting the data. This can lead to increased network transfer overhead, especially when dealing with a large amount of data.

How large is your data?
A common way to do this is as @Jeremy-Run said, to Get the data first, and rewrite it by Put().

But if this does not meet your needs, I can rethink another approach.

@taroim
Copy link
Author

taroim commented Sep 12, 2023

My current use case involves storing meteorological data. Typically, each KEY holds data packets of around 500KB in size, and the number of KEYs processed in a single business operation is around 3000. Therefore, I am particularly concerned about duplicate data writes

@roseduan
Copy link
Collaborator

roseduan commented Sep 13, 2023

My current use case involves storing meteorological data. Typically, each KEY holds data packets of around 500KB in size, and the number of KEYs processed in a single business operation is around 3000. Therefore, I am particularly concerned about duplicate data writes.

I have checked the WAL logic, it is a little hard to do the in-place update.

So I think the only solution is to rewrite the data to clear its expire time.

I can add a Persist function to you if you want. @taroim

@taroim
Copy link
Author

taroim commented Sep 15, 2023

It is needed in my current application scenario. I hope you can add it, Thanks!

@roseduan
Copy link
Collaborator

It is needed in my current application scenario. I hope you can add it, Thanks!

Added in latest release, enjoy!

@roseduan
Copy link
Collaborator

It is needed in my current application scenario. I hope you can add it, Thanks!

如果你在使用 RoseDB,可以在这个 issue #226 上贴一下你的使用场景,也可以提出任何建议和期待功能,非常感谢! @taroim

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

3 participants