3 stable releases
1.0.4 | Feb 6, 2023 |
---|---|
1.0.3 | Jan 27, 2023 |
#2951 in Database interfaces
16KB
337 lines
keyz
Simple async key value store with rust and tokio
CLI and clients
Run
- The port is always -
7667
Run locally using cargo
cargo install keyz
keyz
- If you get command not found you need to add cargo bin to the PATH
Run using docker image
docker pull zvado1/keyz
sudo docker run --network host -d keyz
Supported commands
SET [key] [value]
- Sets key and value
SET [key] [value] EX [seconds]
- Sets key and value but with expiration time in seconds
GET [key]
- Gets the value set for the given key
EXIN [key]
- Returns the seconds left before a key will expire
DEL [key]
- Deletes a key and value
CLOSE
- Closes the connection
Examples using commands
-
SET text some text blah
- Will set the
text
key with valuesome text blah
- Will set the
-
SET user:1 { "username": "testUsername", "password": "hashedandsecrurepass" }
- Again it will set the key
user:1
wit value{ "username": "testUsername", "password": "hashedandsecrurepass" }
- This time however we used key
user:1
because there might many users in your app
- Again it will set the key
-
SET user:1 { "username": "testUsername", "password": "hashedandsecrurepass" } EX 60
- Exact same thing as before but this time we added
EX 60
at the end so the user:1 key will expire in 60 seconds
- Exact same thing as before but this time we added
-
GET user:1
- Will give you the value of
user:1
key - However if the key is expired it will return
null
- Will give you the value of
-
EXIN user:1
- Will return the time left this key has before expiration in seconds
- If already expired it will return null
- If key has no expiration set return null
-
DEL user:1
- Will attempt to delete the key
user:1
- If deleted it will return the key name deleted back in this case it will return
user:1
- If the key does not exist it will return null
Features
Features besides the base SET GET DEL
- Key expiration
- Command to show time left a key has before expiry in seconds
- Settings reader from a config file
- Password protection
- Persistance
- Monitoring
- Data compression
- Data partitioning
- Statistics like connected clients, keys count, storage taken
- Will attempt to delete the key
Dependencies
~5–11MB
~116K SLoC