{"id":13481786,"url":"https://github.com/HDT3213/godis","last_synced_at":"2025-03-27T12:31:26.194Z","repository":{"id":37329019,"uuid":"189705577","full_name":"HDT3213/godis","owner":"HDT3213","description":"A Golang implemented Redis Server and Cluster. Go 语言实现的 Redis 服务器和分布式集群","archived":false,"fork":false,"pushed_at":"2025-03-23T14:10:25.000Z","size":751,"stargazers_count":3618,"open_issues_count":19,"forks_count":583,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-26T00:04:03.870Z","etag":null,"topics":["cluster","go","godis","golang","kv-cache","redis","redis-cluster","redis-server"],"latest_commit_sha":null,"homepage":"https://www.cnblogs.com/Finley/category/1598973.html","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HDT3213.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-01T07:49:11.000Z","updated_at":"2025-03-25T01:47:20.000Z","dependencies_parsed_at":"2024-03-26T03:34:42.216Z","dependency_job_id":"5266ffd4-a253-4c99-8c01-0bd29ff3c35e","html_url":"https://github.com/HDT3213/godis","commit_stats":{"total_commits":255,"total_committers":40,"mean_commits":6.375,"dds":0.3058823529411765,"last_synced_commit":"0c6b0863f347f8dd97ac47fd68a50c7de6349151"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDT3213%2Fgodis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDT3213%2Fgodis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDT3213%2Fgodis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDT3213%2Fgodis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HDT3213","download_url":"https://codeload.github.com/HDT3213/godis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245844954,"owners_count":20681807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cluster","go","godis","golang","kv-cache","redis","redis-cluster","redis-server"],"created_at":"2024-07-31T17:00:55.658Z","updated_at":"2025-03-27T12:31:26.159Z","avatar_url":"https://github.com/HDT3213.png","language":"Go","readme":"# Godis\n\n![license](https://img.shields.io/github/license/HDT3213/godis)\n[![Build Status](https://github.com/hdt3213/godis/actions/workflows/coverall.yml/badge.svg)](https://github.com/HDT3213/godis/actions?query=branch%3Amaster)\n[![Coverage Status](https://coveralls.io/repos/github/HDT3213/godis/badge.svg?branch=master)](https://coveralls.io/github/HDT3213/godis?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/HDT3213/godis)](https://goreportcard.com/report/github.com/HDT3213/godis)\n[![Go Reference](https://pkg.go.dev/badge/github.com/hdt3213/godis.svg)](https://pkg.go.dev/github.com/hdt3213/godis)\n\u003cbr\u003e\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go)\n\n[中文版](https://github.com/hdt3213/godis/blob/master/README_CN.md)\n\n`Godis` is a golang implementation of Redis Server, which intents to provide an example of writing a high concurrent\nmiddleware using golang.\n\nKey Features:\n\n- Support string, list, hash, set, sorted set, bitmap\n- Multi Database and `SELECT` command\n- TTL\n- Publish/Subscribe\n- GEO\n- AOF and AOF Rewrite\n- RDB read and write\n- MULTI Commands Transaction is Atomic and Isolated. If any errors are encountered during execution, godis will rollback\n  the executed commands\n- Replication (experimental)\n- Server-side Cluster which is transparent to client. You can connect to any node in the cluster to\n  access all data in the cluster.\n  - Use the raft algorithm to maintain cluster metadata. (experimental)\n  - `MSET`, `MSETNX`, `DEL`, `Rename`, `RenameNX` command is supported and atomically executed in cluster mode, allow over multi node\n  - `MULTI` Commands Transaction is supported within slot in cluster mode\n- Concurrent Core, so you don't have to worry about your commands blocking the server too much. \n\nIf you could read Chinese, you can find more details in [My Blog](https://www.cnblogs.com/Finley/category/1598973.html).\n\n## Get Started\n\nYou can get runnable program in the releases of this repository, which supports Linux and Darwin system.\n\n```bash\n./godis-darwin\n./godis-linux\n```\n\n![](https://i.loli.net/2021/05/15/oQM1yZ6pWm3AIEj.png)\n\nYou could use redis-cli or other redis client to connect godis server, which listens on 0.0.0.0:6399 on default mode.\n\n![](https://i.loli.net/2021/05/15/7WquEgonzY62sZI.png)\n\nThe program will try to read config file path from environment variable `CONFIG`.\n\nIf environment variable is not set, then the program try to read `redis.conf` in the working directory.\n\nIf there is no such file, then the program will run with default config.\n\n### cluster mode\n\nGodis can work in cluster mode, please append following lines to redis.conf file\n\n```ini\npeers localhost:7379,localhost:7389 // other node in cluster\nself  localhost:6399 // self address\n```\n\nWe provide node1.conf and node2.conf for demonstration. use following command line to start a two-node-cluster:\n\n```bash\nCONFIG=node1.conf ./godis-darwin \u0026\nCONFIG=node2.conf ./godis-darwin \u0026\n``` \n\nConnect to a node in the cluster to access all data in the cluster:\n\n```cmd\nredis-cli -p 6399\n```\n\n## Supported Commands\n\nSee: [commands.md](https://github.com/HDT3213/godis/blob/master/commands.md)\n\n## Benchmark\n\nEnvironment:\n\nGo version：1.17\n\nSystem: macOS Catalina 10.15.7\n\nCPU: 2.6GHz 6-Core Intel Core i7\n\nMemory: 16 GB 2667 MHz DDR4\n\nPerformance report by redis-benchmark: \n\n```\nPING_INLINE: 87260.03 requests per second\nPING_BULK: 89206.06 requests per second\nSET: 85034.02 requests per second\nGET: 87565.68 requests per second\nINCR: 91157.70 requests per second\nLPUSH: 90334.23 requests per second\nRPUSH: 90334.23 requests per second\nLPOP: 90334.23 requests per second\nRPOP: 90415.91 requests per second\nSADD: 90909.09 requests per second\nHSET: 84104.29 requests per second\nSPOP: 82918.74 requests per second\nLPUSH (needed to benchmark LRANGE): 78247.26 requests per second\nLRANGE_100 (first 100 elements): 26406.13 requests per second\nLRANGE_300 (first 300 elements): 11307.10 requests per second\nLRANGE_500 (first 450 elements): 7968.13 requests per second\nLRANGE_600 (first 600 elements): 6092.73 requests per second\nMSET (10 keys): 65487.89 requests per second\n```\n\n## Todo List\n\n+ [x] `Multi` Command\n+ [x] `Watch` Command and CAS support\n+ [ ] Stream support\n+ [x] RDB file loader\n+ [ ] Master-Slave mode\n+ [ ] Sentinel\n\n## Read My Code\n\nIf you want to read my code in this repository, here is a simple guidance.\n\n- project root: only the entry point\n- config: config parser\n- interface: some interface definitions\n- lib: some utils, such as logger, sync utils and wildcard\n\nI suggest focusing on the following directories:\n\n- tcp: the tcp server\n- redis: the redis protocol parser\n- datastruct: the implements of data structures\n    - dict: a concurrent hash map\n    - list: a linked list\n    - lock: it is used to lock keys to ensure thread safety\n    - set: a hash set based on map\n    - sortedset: a sorted set implements based on skiplist\n- database: the core of storage engine\n    - server.go: a standalone redis server, with multiple database\n    - database.go: data structure and base functions of single database\n    - exec.go: the gateway of database\n    - router.go: the command table\n    - keys.go: handlers for keys commands\n    - string.go: handlers for string commands\n    - list.go: handlers for list commands\n    - hash.go: handlers for hash commands\n    - set.go: handlers for set commands\n    - sortedset.go: handlers for sorted set commands\n    - pubsub.go: implements of publish / subscribe\n    - aof.go: implements of AOF persistence and rewrite\n    - geo.go: implements of geography features\n    - sys.go: authentication and other system function\n    - transaction.go: local transaction\n- cluster: \n    - cluster.go: entrance of cluster mode\n    - com.go: communication within nodes\n    - del.go: atomic implementation of `delete` command in cluster\n    - keys.go: keys command\n    - mset.go: atomic implementation of `mset` command in cluster\n    - multi.go: entrance of distributed transaction\n    - pubsub.go: pub/sub in cluster\n    - rename.go: `rename` command in cluster \n    - tcc.go: try-commit-catch distributed transaction implementation\n- aof: AOF persistence\n\n# License\n\nThis project is licensed under the [GPL license](https://github.com/hdt3213/godis/blob/master/LICENSE).","funding_links":[],"categories":["Database","Go","Repositories","Generators","Uncategorized"],"sub_categories":["Databases Implemented in Go"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHDT3213%2Fgodis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHDT3213%2Fgodis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHDT3213%2Fgodis/lists"}