Skip to content

GoCache is a lightweight Redis clone in Go, supporting key-value storage, RDB persistence, partial replication, streams, and basic transactions. It provides essential Redis-like functionality with commands like SET, GET, XADD, and MULTI, designed for learning and experimentation.

License

Notifications You must be signed in to change notification settings

Pirate-Emperor/GoCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoCache

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.


🚀 Features

  1. Key/Value Storage:
    • GET and SET commands with support for setting expiry times.
  2. RDB Persistence:
    • Load data from RDB files for persistent storage.
  3. Replication:
    • Partial support for replication with basic master-replica setups.
  4. Streams:
    • TYPE, XADD, XREAD, and XRANGE commands for basic stream operations.
  5. Transactions:
    • Commands like MULTI, EXEC, DISCARD, and INCR for transactional workflows.

🛠 Prerequisites


🔧 Installation

Follow these steps to set up GoCache:

  1. Clone the repository:

    git clone https://github.com/Pirate-Emperor/GoCache.git
  2. Navigate to the project directory:

    cd GoCache
  3. Build the project:

    go build -o goredis ./app

    The executable goredis will be created in the project directory.


🖥 Usage

Start the GoCache server:

./goredis

⚙️ Configuration Options

  • 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"

🛑 Limitations

  • Unsupported Commands:
    • Hash operations like HGET and HSET are not implemented.
  • Replication:
    • Partial replication support; commands like WAIT are not yet implemented.
  • RDB Saving:
    • Server can load RDB files but does not support saving with the SAVE command.
  • Basic Feature Set:
    • Limited to fundamental Redis-like features for simplicity.

📋 Supported Commands

General

  • PING: Test server connection.
  • ECHO: Return the given string.

Key/Value Operations

  • SET and GET: Basic key-value operations.
  • INCR: Increment integer values.

Transactions

  • MULTI: Start a transaction.
  • EXEC: Execute queued commands in a transaction.
  • DISCARD: Discard queued transaction commands.

Streams

  • 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).

Configuration and Replication

  • CONFIG: Get or set server configuration parameters.
  • INFO: Display server statistics.
  • REPLCONF: Configure replication settings.
  • PSYNC: Partial synchronization for replicas.

🏗 Future Enhancements

  • Implement advanced Redis commands, including HGET, HSET, and WAIT.
  • Add support for RDB file saving.
  • Expand replication support for comprehensive master-replica setups.

📚 Acknowledgments

  • Redis: For inspiration and documentation.
  • HDT3213: For the CRC64 checksum implementation.

📜 License

This project is licensed under the Pirate-Emperor License. See the LICENSE file for details.


👤 Author

Rahul Kumar Singh

Twitter Discord LinkedIn

Reddit Medium


Start using GoCache today and experience the power of lightweight key-value storage! 🌟

About

GoCache is a lightweight Redis clone in Go, supporting key-value storage, RDB persistence, partial replication, streams, and basic transactions. It provides essential Redis-like functionality with commands like SET, GET, XADD, and MULTI, designed for learning and experimentation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published