This repository contains a simple implementation of a Redis server in Go. It is designed to support a variety of basic Redis commands, providing a lightweight alternative to the full Redis server for learning and experimentation purposes.
To install and run the server, you need to have Go installed on your machine. If you haven't installed Go yet, you can download it from the official Go website.
Clone this repository:
git clone https://github.com/elordeiro/building-my-own-redis
cd building-my-own-redis
To run the server, execute the following command:
./spawn_redis_server.sh
This script will compile the Go code and start the Redis server.
The server currently supports the following Redis commands:
PING
: Returns PONG.ECHO <message>
: Returns the input string.SET <key> <value>
: Sets a key to a value.GET <key>
: Gets the value of a key.INCR <key>
: Increments the integer value of a key.INFO
: Returns information about the server.KEYS <pattern>
: Returns all keys matching a pattern.TYPE <key>
: Returns the type of a key.
XADD <stream> <id> <field> <value>
: Adds a message to a stream.XRANGE <stream> <start> <end>
: Gets a range of messages from a stream.XREAD STREAMS <stream> <id>
: Reads messages from a stream.
MULTI
: Starts a transaction.EXEC
: Executes a transaction.DISCARD
: Discards a transaction.
REPLCONF <option> <value>
: Configures replication.PSYNC <replicaid> <offset>
: Partial synchronization.WAIT <numreplicas> <timeout>
: Blocks until the specified number of replicas acknowledge the write.
This implementation is a work in progress. Future enhancements may include:
- Adding support for more Redis commands.
- Improving performance and concurrency.
- Adding persistence mechanisms.
- Enhancing the server's configuration options.
Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or new features to add.
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.