https://github.com/maniktherana/godbase
My attempt at writing a Redis™ clone in Go
https://github.com/maniktherana/godbase
database go golang in-memory redis
Last synced: 3 months ago
JSON representation
My attempt at writing a Redis™ clone in Go
- Host: GitHub
- URL: https://github.com/maniktherana/godbase
- Owner: Maniktherana
- License: mit
- Created: 2024-01-18T16:59:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-21T07:45:27.000Z (almost 2 years ago)
- Last Synced: 2025-02-26T16:49:40.239Z (over 1 year ago)
- Topics: database, go, golang, in-memory, redis
- Language: Go
- Homepage:
- Size: 1.56 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


# Godbase
A drop-in replacement for redis written in Go
## Table of Contents
- [Introduction](#introduction)
- [Feature parity](#feature-parity)
- [Available commands](#available-commands)
- [The SET Command](#the-set-command)
- [Installation](#installation)
- [Compatibility](#compatibility)
- [License](#license)
## Introduction
`Godbase` is a blazingly fast drop-in replacement for redis, built with golang.
It's a fun project that i started to learn more about redis and golang, taking help from this fantastic [guide](https://www.build-redis-from-scratch.dev/en/introduction) by [ahmedash95](https://github.com/ahmedash95). This project builds upon the concepts in this guide and adds features such as `TTL` options for the `SET` command.
The project is still in its early stages and is not recommended for production use. It's a fun project to learn more about redis and golang.
## Feature parity
| Feature | Redis | Godbase |
| ------------------------- | ----- | -------- |
| In-memory key-value store | ✅ | ✅ |
| Strings | ✅ | ✅ |
| Persistence | ✅ | ✅ |
| Hashes | ✅ | ✅ |
| TTL | ✅ | ✅ |
| Lists | ✅ | ❌ |
| Sets | ✅ | ❌ |
| Sorted sets | ✅ | ❌ |
| Streams | ✅ | ❌ |
| HyperLogLogs | ✅ | ❌ |
| Bitmaps | ✅ | ❌ |
| Pub/Sub | ✅ | ❌ |
| Transactions | ✅ | ❌ |
## Available commands
The following commands are supported by Godbase as of now:
#### MISC
`PING`
#### Strings
`SET` `GET`
#### Hashes
`HSET` `HGET` `HGETALL`
### The SET Command
```
SET key value [NX | XX] [GET] [EX seconds | PX milliseconds | KEEPTTL]
```
The SET command supports the following options:
- EX seconds -- Set the specified expire time, in seconds (a positive integer).
- PX milliseconds -- Set the specified expire time, in milliseconds (a positive integer).
- NX -- Only set the key if it does not already exist.
- XX -- Only set the key if it already exists.
- KEEPTTL -- Retain the time to live associated with the key.
- GET -- Return the old string stored at key, or nil if key did not exist. An error is returned and SET aborted if the value stored at key is not a string.
**Time complexity**: O(1)
## Installation
Clone this repository and use the makefile to build or run the binary.
```
git clone https://github.com/Maniktherana/godbase.git
make build
```
## Compatibility
Godbase is compatible with existing redis clients. You can use the redis-cli to interact with godbase for the supported commands.
```
redis-cli -h localhost -p 6379
localhost:6379> set hello world
OK
localhost:6379> get hello
world
localhost:6379> set god man
OK
localhost:6379> set god base xx
OK
localhost:6379> get god
base
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.