A sleek, Golang-powered learning adventure inspired by Redis
Pedis is a Redis clone written in Golang. It is a learning project for me to learn Redis protocol. It is not intended to be a production-ready Redis clone.
Pedis does not have any external dependencies. To build it, simply run:
$ go build -o pedis-server && ./pedis-server
- Initialize a Pedis server
package main
import (
"ahmedash95/pedis/pedis"
"fmt"
)
func main() {
fmt.Println("Listening on port 6379")
config := &pedis.Config{
EnableAof: true,
} // to enable AOF persistence or set config to nil
server := pedis.NewServer(config)
server.ListenAndServe("0.0.0.0:6379")
}
- Connect to the server using a Redis client
$ redis-cli -p 6379
- GET
- SET
- DEL
- EXISTS
- EXPIRE
- TTL
- HSET
- HGET
- HGETALL
- HDEL
- HLEN
- HKEYS
- HVALS
At the moment, Pedis supports AOF persistence. It is disable by default. To enabled it, set EnableAof
to true
in the config. the policy for now is to append to the AOF file every second.
With no disk persistence
go run main.go
$ redis-benchmark -p 6379 -n 100000 -c 100 -t set,get
SET: 411761.19 requests per second
GET: 476640.00 requests per second
MIT