https://github.com/apachecn-archive/godis

https://github.com/apachecn-archive/godis

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.2%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: apachecn-archive
  • License: gpl-3.0
  • Language: Go
  • Default Branch: master
  • Size: 349 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme License

README.md

Godis

license Build Status Coverage Status Go Report Card Go Reference
Mentioned in Awesome Go

中文版

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
  • TTL
  • Publish/Subscribe
  • GEO
  • AOF and AOF Rewrite
  • MULTI Commands Transaction is Atomic and Isolated. If any errors are encountered during execution, godis will rollback the executed commands
  • Server-side Cluster which is transparent to client. You can connect to any node in the cluster to access all data in the cluster.
    • MSET, DEL command is supported and atomically executed in cluster mode
    • Rename, RenameNX command is supported within slot in cluster mode
    • MULTI Commands Transaction is supported within slot in cluster mode
  • Concurrent Core, so you don't have to worry about your commands blocking the server too much.

If you could read Chinese, you can find more details in My Blog.

Get Started

You can get runnable program in the releases of this repository, which supports Linux and Darwin system.

bash ./godis-darwin ./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.

If there is no such file, then the program will run with default config.

cluster mode

Godis can work in cluster mode, please append following lines to redis.conf file

ini peers localhost:7379,localhost:7389 // other node in cluster self localhost:6399 // self address

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

Supported Commands

See: commands.md

Benchmark

Environment:

Go version:1.16

System: macOS Catalina 10.15.7

CPU: 2.6GHz 6-Core Intel Core i7

Memory: 16 GB 2667 MHz DDR4

Performance report by redis-benchmark:

PING_INLINE: 87260.03 requests per second PING_BULK: 89206.06 requests per second SET: 85034.02 requests per second GET: 87565.68 requests per second INCR: 91157.70 requests per second LPUSH: 90334.23 requests per second RPUSH: 90334.23 requests per second LPOP: 90334.23 requests per second RPOP: 90415.91 requests per second SADD: 90909.09 requests per second HSET: 84104.29 requests per second SPOP: 82918.74 requests per second LPUSH (needed to benchmark LRANGE): 78247.26 requests per second LRANGE_100 (first 100 elements): 26406.13 requests per second LRANGE_300 (first 300 elements): 11307.10 requests per second LRANGE_500 (first 450 elements): 7968.13 requests per second LRANGE_600 (first 600 elements): 6092.73 requests per second MSET (10 keys): 65487.89 requests per second

Todo List

  • [x] Multi Command
  • [x] Watch Command and CAS support
  • [ ] Stream support
  • [ ] RDB file loader
  • [ ] Master-Slave mode
  • [ ] Sentinel

Read My Code

If you want to read my code in this repository, here is a simple guidance.

  • github.com/hdt3213/godis/cmd: only the entry point
  • github.com/hdt3213/godis/config: config parser
  • github.com/hdt3213/godis/interface: some interface definitions
  • github.com/hdt3213/godis/lib: some utils, such as logger, sync utils and wildcard

I suggest focusing on the following directories:

  • github.com/hdt3213/godis/tcp: the tcp server
  • github.com/hdt3213/godis/redis: the redis protocol parser
  • github.com/hdt3213/godis/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
  • github.com/hdt3213/godis: the core of storage engine
    • db.go: the basement of 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

License

This project is licensed under the GPL license.

Owner

  • Name: ApacheCN 归档
  • Login: apachecn-archive
  • Kind: organization
  • Email: wizard.z@qq.com

防止重要项目丢失而设立的归档

GitHub Events

Total
Last Year

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 5
proxy.golang.org: github.com/apachecn-archive/godis
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.2%
Average: 5.4%
Dependent repos count: 5.6%
Last synced: 10 months ago

Dependencies

go.mod go
  • github.com/jolestar/go-commons-pool/v2 v2.1.1
  • github.com/shopspring/decimal v1.2.0
  • golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
  • golang.org/x/tools v0.1.0
go.sum go
  • github.com/davecgh/go-spew v1.1.0
  • github.com/davecgh/go-spew v1.1.1
  • github.com/fortytw2/leaktest v1.3.0
  • github.com/jolestar/go-commons-pool/v2 v2.1.1
  • github.com/pmezard/go-difflib v1.0.0
  • github.com/shopspring/decimal v1.2.0
  • github.com/stretchr/objx v0.1.0
  • github.com/stretchr/testify v1.4.0
  • github.com/yuin/goldmark v1.2.1
  • golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
  • golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
  • golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
  • golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
  • golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee
  • golang.org/x/mod v0.3.0
  • golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
  • golang.org/x/net v0.0.0-20190620200207-3b0461eec859
  • golang.org/x/net v0.0.0-20201021035429-f5854403a974
  • golang.org/x/sync v0.0.0-20190423024810-112230192c58
  • golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
  • golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
  • golang.org/x/sys v0.0.0-20190412213103-97732733099d
  • golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f
  • golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4
  • golang.org/x/text v0.3.0
  • golang.org/x/text v0.3.3
  • golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
  • golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
  • golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7
  • golang.org/x/tools v0.1.0
  • golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
  • golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
  • golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
  • gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
  • gopkg.in/yaml.v2 v2.2.2
  • gopkg.in/yaml.v2 v2.2.5