Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Twemproxy | 11,674 | 3 months ago | 1 | February 27, 2018 | 187 | apache-2.0 | C | |||
A fast, light-weight proxy for memcached and redis | ||||||||||
Springcloud | 7,971 | a month ago | 54 | apache-2.0 | Java | |||||
基于SpringCloud2.1的微服务开发脚手架,整合了spring-security-oauth2、nacos、feign、sentinel、springcloud-gateway等。服务治理方面引入elasticsearch、skywalking、springboot-admin、zipkin等,让项目开发快速进入业务开发,而不需过多时间花费在架构搭建上。持续更新中 | ||||||||||
Rap2 Delos | 7,400 | 5 months ago | 73 | mit | TypeScript | |||||
阿里妈妈前端团队出品的开源接口管理工具RAP第二代 | ||||||||||
Backendlore | 4,542 | 2 years ago | ||||||||
How I write backends | ||||||||||
Proxypool | 4,411 | a month ago | 33 | mit | Python | |||||
An Efficient ProxyPool with Getter, Tester and Server | ||||||||||
Dynomite | 3,957 | 6 months ago | 1 | December 15, 2021 | 106 | apache-2.0 | C | |||
A generic dynamo implementation for different k-v storage engines | ||||||||||
Phpredisadmin | 2,968 | 1 | a month ago | 25 | October 14, 2020 | 9 | PHP | |||
Simple web interface to manage Redis databases. | ||||||||||
Mini Redis | 2,501 | 2 | 19 hours ago | 6 | July 12, 2021 | 30 | mit | Rust | ||
Incomplete Redis client and server implementation using Tokio - for learning purposes only | ||||||||||
Redcon | 1,928 | 17 | 40 | a month ago | 29 | August 25, 2022 | 14 | mit | Go | |
Redis compatible server framework for Go | ||||||||||
Picfit | 1,791 | 15 days ago | 2 | April 22, 2021 | 17 | mit | Go | |||
An image resizing server written in Go |
Redis compatible server framework for Go
ListenAndServe
and two types Conn
& Command
This library is also avaliable for Rust and C.
go get -u github.com/tidwall/redcon
Here's a full example of a Redis clone that accepts:
You can run this example from a terminal:
go run example/clone.go
package main
import (
"log"
"strings"
"sync"
"github.com/tidwall/redcon"
)
var addr = ":6380"
func main() {
var mu sync.RWMutex
var items = make(map[string][]byte)
var ps redcon.PubSub
go log.Printf("started server at %s", addr)
err := redcon.ListenAndServe(addr,
func(conn redcon.Conn, cmd redcon.Command) {
switch strings.ToLower(string(cmd.Args[0])) {
default:
conn.WriteError("ERR unknown command '" + string(cmd.Args[0]) + "'")
case "ping":
conn.WriteString("PONG")
case "quit":
conn.WriteString("OK")
conn.Close()
case "set":
if len(cmd.Args) != 3 {
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
return
}
mu.Lock()
items[string(cmd.Args[1])] = cmd.Args[2]
mu.Unlock()
conn.WriteString("OK")
case "get":
if len(cmd.Args) != 2 {
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
return
}
mu.RLock()
val, ok := items[string(cmd.Args[1])]
mu.RUnlock()
if !ok {
conn.WriteNull()
} else {
conn.WriteBulk(val)
}
case "del":
if len(cmd.Args) != 2 {
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
return
}
mu.Lock()
_, ok := items[string(cmd.Args[1])]
delete(items, string(cmd.Args[1]))
mu.Unlock()
if !ok {
conn.WriteInt(0)
} else {
conn.WriteInt(1)
}
case "publish":
if len(cmd.Args) != 3 {
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
return
}
conn.WriteInt(ps.Publish(string(cmd.Args[1]), string(cmd.Args[2])))
case "subscribe", "psubscribe":
if len(cmd.Args) < 2 {
conn.WriteError("ERR wrong number of arguments for '" + string(cmd.Args[0]) + "' command")
return
}
command := strings.ToLower(string(cmd.Args[0]))
for i := 1; i < len(cmd.Args); i++ {
if command == "psubscribe" {
ps.Psubscribe(conn, string(cmd.Args[i]))
} else {
ps.Subscribe(conn, string(cmd.Args[i]))
}
}
}
},
func(conn redcon.Conn) bool {
// Use this function to accept or deny the connection.
// log.Printf("accept: %s", conn.RemoteAddr())
return true
},
func(conn redcon.Conn, err error) {
// This is called when the connection has been closed
// log.Printf("closed: %s, err: %v", conn.RemoteAddr(), err)
},
)
if err != nil {
log.Fatal(err)
}
}
Redcon has full TLS support through the ListenAndServeTLS
function.
The same example is also provided for serving Redcon over TLS.
go run example/tls/clone.go
Redis: Single-threaded, no disk persistence.
$ redis-server --port 6379 --appendonly no
redis-benchmark -p 6379 -t set,get -n 10000000 -q -P 512 -c 512
SET: 941265.12 requests per second
GET: 1189909.50 requests per second
Redcon: Single-threaded, no disk persistence.
$ GOMAXPROCS=1 go run example/clone.go
redis-benchmark -p 6380 -t set,get -n 10000000 -q -P 512 -c 512
SET: 2018570.88 requests per second
GET: 2403846.25 requests per second
Redcon: Multi-threaded, no disk persistence.
$ GOMAXPROCS=0 go run example/clone.go
$ redis-benchmark -p 6380 -t set,get -n 10000000 -q -P 512 -c 512
SET: 1944390.38 requests per second
GET: 3993610.25 requests per second
Running on a MacBook Pro 15" 2.8 GHz Intel Core i7 using Go 1.7
Josh Baker @tidwall
Redcon source code is available under the MIT License.