Redis 0.1, entirely built in Go and exposed via a TCP server, features in-memory storage capabilities. The program accepts database commands from the client connections and processes them, creating in-memory database structures. The output is then displayed both on the standard output stream and to the connected clients.
- Clone the repository and run the program using
go run ./process
from the 'process' folder. - Connect to the default server at port 8000 using
telnet localhost 8000
. - For a custom port, use the following command:
go run ./process -p :<custom_port>
.
Redis 0.1 supports basic CRUD commands:
SET <k> <v>
: Set the key to a specified value, if the value, has spaces, then it must be enclsed in quotes asSET sample_key "spaced value"
.GET <k>
: Retrieve the value of a previously set key.DELETE <k>
: Delete a key if present.
Arithmetic operation commands include:
INCR <k>
: Increment the value of a specified key by 1 (if it's an integer), sets new key with default value of "1" if key not present.INCRBY <k> <v>
: Increment the value of a specified key by v (if it's an integer), gives error if key not present.
Commands for executing multiple instructions at once:
MULTI
: Start queuing commands.EXEC
: Execute the queued commands.DISCARD
: Discard the queued commands.
Additional commands:
COMPACT
: Display the final SET value of a key if the value was an integer.
Redis features databases indexed from 0 to 15. After connection establishment, select a database to operate on using:
SELECT <db_number>
: Select a database ranging from 0 to 15 based on the provided number.
To terminate an established connection, use the DISCONNECT
command, which will terminate the connection from the client-side.
A video demonstrating the application, showcasing various commands executed over multiple TCP connections communicating with the same in-memory database simultaneously, can be found here.