A lightweight, high-performance Redis-compatible server framework for Go
- Full Redis RESP Protocol - Works with any Redis client (redis-cli, go-redis, jedis)
- Middleware Chain Support - Logging, auth, timing, and custom interceptors
- Easy to extend - Simple command registration API
- High performance - Built for speed with Go's concurrency
- ️ TLS Support - Secure connections
- Connection management - State tracking and idle timeouts
- Comprehensive tests - Tested with official Redis clients
go get github.com/l00pss/redkitpackage main
import "github.com/l00pss/redkit"
func main() {
server := redkit.NewServer(":6379")
// Register custom command
server.RegisterCommandFunc("HELLO", func(conn *redkit.Connection, cmd *redkit.Command) redkit.RedisValue {
return redkit.RedisValue{Type: redkit.SimpleString, Str: "Hello from RedKit!"}
})
server.Serve()
}server := redkit.NewServer(":6379")
// Add logging middleware
server.UseFunc(func(conn *redkit.Connection, cmd *redkit.Command, next redkit.CommandHandler) redkit.RedisValue {
log.Printf("Command: %s", cmd.Name)
result := next.Handle(conn, cmd)
log.Printf("Result: %v", result.Type)
return result
})
// Add auth middleware
server.UseFunc(func(conn *redkit.Connection, cmd *redkit.Command, next redkit.CommandHandler) redkit.RedisValue {
if !isAuthenticated(conn) && cmd.Name != "AUTH" {
return redkit.RedisValue{Type: redkit.ErrorReply, Str: "NOAUTH Authentication required"}
}
return next.Handle(conn, cmd)
})
server.Serve()redis-cli -h localhost -p 6379
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SET key value
OK
127.0.0.1:6379> GET key
"value"PING,ECHO,QUIT- Connection commandsSET,GET,MSET,MGET,SETNX- String operationsDEL,EXISTS,TYPE,KEYS- Key managementINCR,DECR,INCRBY,DECRBY- Numeric operationsEXPIRE,TTL- Expiration managementFLUSHDB,FLUSHALL- Database operations
// Simple usage
server := redkit.NewServer(":6379")
// Advanced configuration
config := redkit.DefaultServerConfig()
config.Address = ":6379"
config.ReadTimeout = 30 * time.Second
config.WriteTimeout = 30 * time.Second
config.IdleTimeout = 120 * time.Second
config.MaxConnections = 1000
config.TLSConfig = &tls.Config{...}
config.ConnStateHook = func(conn net.Conn, state redkit.ConnState) {
log.Printf("Connection %s: %v", conn.RemoteAddr(), state)
}
server := redkit.NewServerWithConfig(config)# Run tests
go test -v
# Run with race detector
go test -race -v
# Run benchmarks
go test -bench=.MIT License - see LICENSE file for details.
Built with ❤️ and Go
⭐ Star this project if you find it useful!

