New data structure —— Expiring key
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 |
I want to receive tasks from ID1 to 11
Sure. Can you give me a rough idea of what you think about it?
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.
ok, no problem
Do the keys also need to have values associated with them?
Perhaps, but this issue has already been claimed, sorry.
Can you explain the "ex" parameter? Or, could you provide an example to illustrate the usage of "EXPIREBY key duration ex"?
"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.
"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 exThis 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
#239