|
| 1 | +<div align="center"> |
| 2 | +<!-- logo --> |
| 3 | +<img src = "assets/icon.png" width="300"> |
| 4 | +<h1 align="center">Go-Redis</h1> |
| 5 | +<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" /><br> |
| 6 | +Super fast drop-in replacement of the in memory key-value store redis in golang |
| 7 | +</div> |
| 8 | + |
| 9 | +*** |
| 10 | +[](code_of_conduct.md) |
| 11 | +[Try it out instantly](#installation) |
| 12 | + |
| 13 | +## 👀 What is this? Why? |
| 14 | +`go-redis` is a super fast drop-in replacement of the in memory key-value store redis, built with golang. |
| 15 | + |
| 16 | +Why? |
| 17 | +Redis recently (Last week, as of Mar 25 2024) changed their license to a [dual 'source-available' license](https://news.ycombinator.com/item?id=39772562) - which means that it can't be used for commercial purposes without paying for a license. Everyone hated it. This is a problem for many companies and developers who use redis in their projects. |
| 18 | + |
| 19 | +And, I was kinda bored and wanted to learn golang properly, so I built this. |
| 20 | + |
| 21 | +Should you use this in production? Probably, probably not. It's not battle tested yet, but i (as a single person team) have tried to do my best to make it as reliable as possible. |
| 22 | + |
| 23 | +I even made a cute mascot (Godis crushing Redis) |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +## 📜 Features |
| 28 | + |
| 29 | +| Feature | Redis | Go-Redis | |
| 30 | +| ------------------------- | ----- | -------- | |
| 31 | +| In-memory key-value store | ✅ | ✅ | |
| 32 | +| Strings | ✅ | ✅ | |
| 33 | +| Lists | ✅ | ✅ | |
| 34 | +| Sets | ✅ | ✅ | |
| 35 | +| Sorted sets | ✅ | ✅ | |
| 36 | +| Hashes | ✅ | ✅ | |
| 37 | +| Streams | ✅ | ❌ | |
| 38 | +| HyperLogLogs | ✅ | ❌ | |
| 39 | +| Bitmaps | ✅ | ❌ | |
| 40 | +| Persistence | ✅ | ✅ | |
| 41 | +| Pub/Sub | ✅ | ✅ | |
| 42 | +| Transactions | ✅ | ✅ | |
| 43 | +| Lua scripting | ✅ | ❌ | |
| 44 | +| LRU eviction | ✅ | ❌ | |
| 45 | +| TTL | ✅ | 😅 | |
| 46 | +| Clustering | ✅ | ❌ | |
| 47 | +| Auth | ✅ | ❌ | |
| 48 | + |
| 49 | +### Available commands |
| 50 | + |
| 51 | +For now, these commands are available (more to come) |
| 52 | + |
| 53 | +#### MISC |
| 54 | +`INFO` `PING` `FLUSHALL` `SHUTDOWN` `SAVE` `BGSAVE` |
| 55 | + |
| 56 | +#### Keys |
| 57 | +`DEL` `EXISTS` `KEYS` `EXPIRE` `TTL` |
| 58 | + |
| 59 | +#### Strings |
| 60 | +`SET` `GET` `APPEND` `INCR` `INCRBY` `DECR` `DECRBY` `MSET` `MGET` |
| 61 | + |
| 62 | +#### Lists |
| 63 | +`LPUSH` `LPOP` `RPUSH` `RPOP` `LRANGE` `LLEN` |
| 64 | + |
| 65 | +#### Hashes |
| 66 | +`HSET` `HGET` `HMSET` `HMGET` `HGETALL` `HDEL` |
| 67 | + |
| 68 | +#### Sets |
| 69 | +`SADD` `SMEMBERS` `SISMEMBER` `SREM` |
| 70 | + |
| 71 | +#### Sorted Sets |
| 72 | +`ZADD` `ZRANGE` `ZREM` |
| 73 | + |
| 74 | +#### Pub/Sub |
| 75 | +`SUBSCRIBE` `PUBLISH` `UNSUBSCRIBE` |
| 76 | + |
| 77 | +#### Transactions |
| 78 | +`MULTI` `EXEC` `DISCARD` |
| 79 | + |
| 80 | +## Installation |
| 81 | + |
| 82 | +### Using `docker` |
| 83 | +To get it up and running instantly, you can use the docker image |
| 84 | + |
| 85 | +``` |
| 86 | +docker run -d -p 6379:6379 dhravyashah/go-redis |
| 87 | +``` |
| 88 | + |
| 89 | +### Using `go` |
| 90 | + |
| 91 | +``` |
| 92 | +go get github.com/dhrvyashah/go-redis |
| 93 | +``` |
| 94 | + |
| 95 | +and then just build and run the binary |
| 96 | + |
| 97 | + |
| 98 | +### Using the binary |
| 99 | + |
| 100 | +Download the binary executables from `./bin/go-redis`. |
| 101 | + |
| 102 | +Click here to get it [instantly]( |
| 103 | + https://github.com/dhrvyashah/go-redis/releases/download/v0.1.0/go-redis-0.1.0-linux-amd64.tar.gz). |
| 104 | + |
| 105 | + |
| 106 | +## Having fun |
| 107 | + |
| 108 | +This IS compatible with the existing redis tooling and client libraries! Try it out with some of them. |
| 109 | + |
| 110 | +For eg. |
| 111 | +``` |
| 112 | +npm i -g redis-cli |
| 113 | +``` |
| 114 | +(make sure the server is running - docker is the easiest and fastest way) |
| 115 | +``` |
| 116 | +❯ rdcli |
| 117 | +127.0.0.1:6379> incr mycounter |
| 118 | +(integer) 1 |
| 119 | +127.0.0.1:6379> incr mycounter |
| 120 | +(integer) 2 |
| 121 | +127.0.0.1:6379> set foo bar |
| 122 | +OK |
| 123 | +127.0.0.1:6379> get foo |
| 124 | +bar |
| 125 | +127.0.0.1:6379> get bar |
| 126 | +(nil) |
| 127 | +``` |
| 128 | + |
| 129 | +## Contributing |
| 130 | +Go-redis is *completely* open source. If you want to contribute, please create an issue on the repo and I will assign the task to someone (or you). |
| 131 | + |
| 132 | +Steps to contribute: |
| 133 | +1. Clone the repo |
| 134 | +``` |
| 135 | +git clone https://github.com/dhravya/go-redis |
| 136 | +``` |
| 137 | + |
| 138 | +2. Create a new branch |
| 139 | + |
| 140 | +3. Make sure to build and test the code before creating a PR |
| 141 | +``` |
| 142 | +go build -o ./bin |
| 143 | +``` |
| 144 | + |
| 145 | +4. Create a PR |
| 146 | + |
| 147 | +## Help and the community |
| 148 | +If you need any help, or want to ask questions, or suggest features, please feel free to DM me on twitter - [https://dm.new/dhravya](https://dm.new/dhravya) or create an issue on the repo. |
| 149 | + |
| 150 | +You can also join our [Discord server](https://discord.gg/z7MZYhmx6w) where we have a community of developers ready to help you out. |
| 151 | + |
| 152 | +## License |
| 153 | + |
| 154 | +Unlike redis, go-redis is licensed under the MIT license. You can use it for commercial purposes without any restrictions. Go wild! |
0 commit comments