GoCache is a lightweight Redis clone implemented in Go. It provides a simplified yet functional key-value store with support for persistence, basic replication, transactions, and streams.
- Key/Value Storage:
GET
andSET
commands with support for setting expiry times.
- RDB Persistence:
- Load data from RDB files for persistent storage.
- Replication:
- Partial support for replication with basic master-replica setups.
- Streams:
TYPE
,XADD
,XREAD
, andXRANGE
commands for basic stream operations.
- Transactions:
- Commands like
MULTI
,EXEC
,DISCARD
, andINCR
for transactional workflows.
- Commands like
- Go: Install the latest version from the official website.
Follow these steps to set up GoCache:
-
Clone the repository:
git clone https://github.com/Pirate-Emperor/GoCache.git
-
Navigate to the project directory:
cd GoCache
-
Build the project:
go build -o goredis ./app
The executable
goredis
will be created in the project directory.
Start the GoCache server:
./goredis
-
Port: By default, the server binds to port
6379
. Use the--port
flag to specify a different port:./goredis --port 6380
-
RDB File: Load an existing RDB file with the
--dir
(directory) and--dbfilename
(filename) flags:./goredis --dir /tmp/redis-files --dbfilename dump.rdb
Default:
/tmp/redis-files/dump.rdb
. -
Replication: Start the server in replica mode with the
--replicaof
flag:./goredis --replicaof "localhost 6379"
- Unsupported Commands:
- Hash operations like
HGET
andHSET
are not implemented.
- Hash operations like
- Replication:
- Partial replication support; commands like
WAIT
are not yet implemented.
- Partial replication support; commands like
- RDB Saving:
- Server can load RDB files but does not support saving with the
SAVE
command.
- Server can load RDB files but does not support saving with the
- Basic Feature Set:
- Limited to fundamental Redis-like features for simplicity.
PING
: Test server connection.ECHO
: Return the given string.
SET
andGET
: Basic key-value operations.INCR
: Increment integer values.
MULTI
: Start a transaction.EXEC
: Execute queued commands in a transaction.DISCARD
: Discard queued transaction commands.
TYPE
: Identify the type of a key.XADD
: Add a new entry to a stream.XRANGE
: Retrieve entries within an ID range.XREAD
: Read from streams (supports blocking and non-blocking).
CONFIG
: Get or set server configuration parameters.INFO
: Display server statistics.REPLCONF
: Configure replication settings.PSYNC
: Partial synchronization for replicas.
- Implement advanced Redis commands, including
HGET
,HSET
, andWAIT
. - Add support for RDB file saving.
- Expand replication support for comprehensive master-replica setups.
- Redis: For inspiration and documentation.
- HDT3213: For the CRC64 checksum implementation.
This project is licensed under the Pirate-Emperor License. See the LICENSE file for details.
Rahul Kumar Singh
- 📧 Email: piratekingrahul@gmail.com
- 📍 Location: Surat, Gujarat, India
- 🌐 GitHub: Rahul Kumar Singh
Start using GoCache today and experience the power of lightweight key-value storage! 🌟