Suggestion: add a Command for Removing Key Expire
taroim opened this issue · comments
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.
If I understand correctly, db.Put(k, v) again will give you the effect you want.
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.
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.
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
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!