Пример #1
0
func NewStatsHandler(pool *redis.Pool) func(w http.ResponseWriter, req *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		switch r.Method {
		case "GET":
			c := pool.Get()
			defer c.Close()
			connectionCount, _ := redis.String(c.Do("GET", "connection-count"))

			fmt.Fprintf(w, connectionCount)
		}
	}
}
Пример #2
0
func ExampleString() {
	c, err := dial()
	if err != nil {
		panic(err)
	}
	defer c.Close()

	c.Do("SET", "hello", "world")
	s, err := redis.String(c.Do("GET", "hello"))
	fmt.Printf("%#v\n", s)
	// Output:
	// "world"
}