-
Notifications
You must be signed in to change notification settings - Fork 2
/
doc.go
36 lines (29 loc) · 848 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Package redeo provides a toolkit for building redis-protocol compatible services
optimised for high thoughput and low latency.
A simple server example with two commands:
srv := redeo.NewServer(nil)
// Define handlers
srv.HandleFunc("ping", func(w resp.ResponseWriter, _ *resp.Command) {
w.AppendInlineString("PONG")
})
srv.HandleFunc("info", func(w resp.ResponseWriter, _ *resp.Command) {
w.AppendBulkString(srv.Info().String())
})
// More handlers; demo usage of redeo.WrapperFunc
srv.Handle("echo", redeo.WrapperFunc(func(c *resp.Command) interface{} {
if c.ArgN() != 1 {
return redeo.ErrWrongNumberOfArgs(c.Name)
}
return c.Arg(0)
}))
// Open a new listener
lis, err := net.Listen("tcp", ":9736")
if err != nil {
panic(err)
}
defer lis.Close()
// Start serving (blocking)
srv.Serve(lis)
*/
package redeo