Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

godis

> 数据库
Open source

A Golang implemented Redis Server and Cluster. Go 语言实现的 Redis 服务器和分布式集群

3.8K stars0 likes0 views
WebsiteGitHub

About

A Golang implemented Redis Server and Cluster. Go 语言实现的 Redis 服务器和分布式集群

# Godis
[中文版](https://github.com/hdt3213/godis/blob/master/README_CN.md) `Godis` is a golang implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang. Key Features: - Support string, list, hash, set, sorted set, bitmap - Concurrent Core for better performance - TTL - Publish/Subscribe - GEO - AOF and AOF Rewrite - RDB read and write - Multi Database and `SELECT` command - Transaction is **Atomic** and Isolated. If any errors are encountered during execution, godis will rollback the executed commands - Replication - Server-side Cluster which is transparent to client. You can connect to any node in the cluster to access all data in the cluster. - Cluster metadata management based on Raft. Support dynamic expansion, rebalancing and failover. - `MSET`, `MSETNX`, `DEL`, `Rename`, `RenameNX` command is supported and atomically executed in cluster mode, allow over multi node. - `MULTI` Commands Transaction is supported within slot in cluster mode If you could read Chinese, you can find more details in [My Blog](https://www.cnblogs.com/Finley/category/1598973.html). ## Get Started You can get runnable program in the releases of this repository, which supports Linux and Darwin system. ```bash ./godis-darwin ``` ```bash ./godis-linux ``` You could use redis-cli or other redis client to connect godis server, which listens on 0.0.0.0:6399 on default mode. The program will try to read config file path from environment variable `CONFIG`. If environment variable is not set, then the program try to read `redis.conf` in the working directory. Please see [example.conf](./example.conf) for all configuration information. ### cluster mode We provide node1.conf and node2.conf for demonstration. use following command line to start a two-node-cluster: ```bash CONFIG=node1.conf ./godis-darwin & CONFIG=node2.conf ./godis-darwin & ``` Connect to a node in the cluster to access all data in the cluster: ```cmd redis-cli -p 6399 ``` Please refer to [example.conf](./example.conf) for cluster configuration. ## Supported Commands See: [commands.md](https://github.com/HDT3213/godis/blob/master/commands.md) ## Benchmark Environment: Go version:1.23 System: MacOS Monterey 12.5 M2 Air Performance report by redis-benchmark: ``` … ``` ## Read My Code If you want to read my code in this repository, here is a simple guidance. - project root: only the entry point - config: config parser - interface: some interface definitions - lib: some utils, such as logger, sync utils and wildcard I suggest focusing on the following directories: - tcp: the tcp server - redis: the redis protocol parser - datastruct: the implements of data structures - dict: a concurrent hash map - list: a linked list - lock: it is used to lock keys to ensure thread safety - set: a hash set based on map - sortedset: a sorted set implements based on skiplist - database: the core of storage engine - server.go: a standalone redis server, with multiple database - database.go: data structure and base functions of single database - exec.go: the gateway of database - router.go: the command table - keys.go: handlers for keys commands - string.go: handlers for string commands - list.go: handlers for list commands - hash.go: handlers for hash commands - set.go: handlers for set commands - sortedset.go: handlers for sorted set commands - pubsub.go: implements of publish / subscribe - aof.go: implements of AOF persistence and rewrite - geo.go: implements of geography features - sys.go: authentication and other system function - transaction.go: local transaction - cluster: - cluster.go: entrance of cluster mode - com.go: communication within nodes - del.go: atomic implementation of `delete` command in cluster - keys.go: keys command - mset.go: atomic implementation of `mset` command in cluster - multi.go: entrance of distributed transaction - pubsub.go: pub/sub in cluster - rename.go: `rename` command in cluster - tcc.go: try-commit-catch distributed transaction implementation - aof: AOF persistence # License This project is licensed under the [GPL license](https://github.com/hdt3213/godis/blob/master/LICENSE).

GitHub Issues· 20 open

View all on GitHub
  • #262

    Memory exhaustion vulnerability in the parser

    Updated Jul 16, 2026
  • #261

    signal.Notify() requires a buffered channel.

    Updated Jun 12, 2026
  • #252

    分布式事务

    Updated May 23, 2025
  • #242

    LoadAof疑问

    Updated May 23, 2025
  • #251

    是否能增加hello协商指令的支持

    Updated May 22, 2025
  • #233

    timewheel concurrency issue

    Updated Nov 26, 2024
  • #227

    关于ConcurrentDict的实现问题。

    Updated Jul 23, 2024
  • #220

    georadius是错误的

    Updated May 18, 2024
  • #150

    support LRU and LFU eviction

    mediumassignedUpdated Jul 25, 2023
  • #151

    support CONFIG command

    good first issueassignedUpdated Jul 7, 2023

Highlights

  • •Support string, list, hash, set, sorted set, bitmap
  • •Concurrent Core for better performance
  • •Publish/Subscribe
  • •AOF and AOF Rewrite
  • •RDB read and write
  • •Multi Database and SELECT command
  • •Transaction is Atomic and Isolated. If any errors are encountered during execution, godis will rollback the executed commands
  • •Replication
  • •Server-side Cluster which is transparent to client. You can connect to any node in the cluster to access all data in the cluster.
  • •Cluster metadata management based on Raft. Support dynamic expansion, rebalancing and failover.

> Tags

Goclustergogodisgolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库