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

New data structure —— Expiring key #142

Closed
qishenonly opened this issue Jul 3, 2023 · 10 comments
Closed

New data structure —— Expiring key #142

qishenonly opened this issue Jul 3, 2023 · 10 comments
Assignees
Labels
difficult:⭐⭐⭐⭐⭐ Up to five stars enhancement New feature or request

Comments

@qishenonly
Copy link
Member

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 qishenonly added difficult:⭐⭐⭐⭐⭐ Up to five stars enhancement New feature or request labels Jul 3, 2023
@SandTripper
Copy link
Contributor

I want to receive tasks from ID1 to 11

@qishenonly
Copy link
Member Author

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

@SandTripper
Copy link
Contributor

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.

@qishenonly
Copy link
Member Author

ok, no problem

@saeid-a
Copy link
Contributor

saeid-a commented Jul 24, 2023

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

@qishenonly
Copy link
Member Author

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

@SandTripper
Copy link
Contributor

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

@qishenonly
Copy link
Member Author

"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.

@SandTripper
Copy link
Contributor

"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 added a commit to SandTripper/FlyDB that referenced this issue Jul 24, 2023
@SandTripper
Copy link
Contributor

#239

qishenonly added a commit that referenced this issue Aug 1, 2023
Implement all functions of ExpireStructure(#142 ID 1~11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficult:⭐⭐⭐⭐⭐ Up to five stars enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants