FlyDB icon indicating copy to clipboard operation
FlyDB copied to clipboard

New data structure —— Expiring key

Open qishenonly opened this issue 2 years ago • 10 comments

We need a new data structure, Expiring key, to extend the database's key-value storage structure. We need to build some instructions into Expiring key to make it more complete. If you are interested in extending the Expiring key data structure, you can comment below on the issue id you would like to try and we will assign it to you.

ID Method Command Description Progress People
1 EXPIRE EXPIRE key seconds Set a key's expiration time in seconds    
2 PEXPIRE PEXPIRE key milliseconds Set a key's expiration time in milliseconds    
3 EXPIREAT EXPIREAT key timestamp Set a key's expiration time in UNIX timestamp    
4 PEXPIREAT PEXPIREAT key milliseconds-timestamp Set a key's expiration time in UNIX milliseconds    
5 TTL TTL key Get the remaining time to live for a key    
6 PTTL PTTL key Get the remaining time to live in milliseconds    
7 PERSIST PERSIST key Remove the expiration time of a key    
8 EXPIREBY EXPIREBY key duration ex Set a key's expiration time by a duration    
9 PEXPIREBY PEXPIREBY key duration ex Set a key's expiration time by a duration in milliseconds    
10 EXPIREATBY EXPIREATBY key timestamp ex Set a key's expiration time by a UNIX timestamp    
11 PEXPIREATBY PEXPIREATBY key timestamp ex Set a key's expiration time by a UNIX timestamp in milliseconds

qishenonly avatar Jul 03 '23 07:07 qishenonly

I want to receive tasks from ID1 to 11

SandTripper avatar Jul 20 '23 06:07 SandTripper

Sure. Can you give me a rough idea of what you think about it?

qishenonly avatar Jul 20 '23 09:07 qishenonly

Sure. Can you give me a rough idea of what you think about it?

Based on the above requirements, we might consider directly storing the expiration time corresponding to the key, and then check whether it's expired when accessing the key. If there are more requirements, please let me know.

SandTripper avatar Jul 20 '23 16:07 SandTripper

ok, no problem

qishenonly avatar Jul 23 '23 09:07 qishenonly

Do the keys also need to have values associated with them?

saeid-a avatar Jul 24 '23 05:07 saeid-a

Perhaps, but this issue has already been claimed, sorry.

qishenonly avatar Jul 24 '23 06:07 qishenonly

Can you explain the "ex" parameter? Or, could you provide an example to illustrate the usage of "EXPIREBY key duration ex"?

SandTripper avatar Jul 24 '23 08:07 SandTripper

"ex" is a flag indicating that the "duration" is relative to the current time. If "ex" is not specified, the "duration" is an absolute timestamp.

Example: SET mykey "Hello, World!"

Now, let's set an expiration time of 60 seconds for the key "mykey": EXPIREBY mykey 60000 ex

This command sets the expiration time of "mykey" to 60 seconds from the current time. After 60 seconds, the key is automatically removed from the database, making it no longer accessible.

qishenonly avatar Jul 24 '23 08:07 qishenonly

"ex" is a flag indicating that the "duration" is relative to the current time. If "ex" is not specified, the "duration" is an absolute timestamp.

Example: SET mykey "Hello, World!"

Now, let's set an expiration time of 60 seconds for the key "mykey": EXPIREBY mykey 60000 ex

This command sets the expiration time of "mykey" to 60 seconds from the current time. After 60 seconds, the key is automatically removed from the database, making it no longer accessible.

Ok, got it

SandTripper avatar Jul 24 '23 08:07 SandTripper

#239

SandTripper avatar Jul 24 '23 10:07 SandTripper