rosedblabs / rosedb

Lightweight, fast and reliable key/value storage engine based on Bitcask.

Home Page:https://rosedblabs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: add a Command for Removing Key Expire

taroim opened this issue · comments

commented

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.

commented

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

commented

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.

commented

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

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.

commented

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

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

commented

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

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

Added in latest release, enjoy!

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

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