Simple Redis clone (both client & server) written in Rust for educational purposes.
Server can accept multiple connections spread out to the thread pool by using async-std
library. Following commands can be used to start server and/or client. Server uses port 7878
to listen for incoming connections.
$ cargo run --release --bin server
$ cargo run --release --bin client
RESP
(REdis Serialization Protocol) is implemented (almost) identically. For more info visit RESP specification. Currently, following types are suppored:
- Simple strings (with
+
starting byte) - Error type (with
-
starting byte) - 64-bit signed integers (with
:
starting byte) - Bulk strings (with
$
starting byte) - Arrays (with
*
starting byte) - NULL type (implemented as bulk string with length -1)
- All commands end with
!
as end-byte (this is where we diverge fromRESP
which has no end-of-instruction byte)
Other types can be added easily within current setup. You can write your own clients in any programming language by adhering to the protocol described above and use it with server written in Rust.
Currently following commands are available:
GET <key>
to read in-memory storageSET <key> <value>
to set given key to a valueDELETE <key>
to delete key from in-memory storageFLUSH
to clear everything from in-memory storageMGET <key1> <key2> <key3> ...
to get values from multiple keysMSET <key1> <val1> <key2> <val2> <key3> <val3> ...
to set values for multiple keys
To run tests use:
$ cargo test