forked from gosexy/redis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (37 loc) · 822 Bytes
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"menteslibres.net/gosexy/redis"
"log"
)
var host = "127.0.0.1"
var port = uint(6379)
var client *redis.Client
func main() {
var err error
client = redis.New()
err = client.Connect(host, port)
if err != nil {
log.Fatalf("Connect failed: %s\n", err.Error())
return
}
log.Println("Connected to redis-server.")
// DEL hello
log.Printf("DEL hello\n")
client.Command(nil, "DEL", "hello")
// SET hello 1
log.Printf("SET hello 1\n")
client.Command(nil, "SET", "hello", 1)
// INCR hello
log.Printf("INCR hello\n")
client.Command(nil, "INCR", "hello")
// GET hello
var i int
log.Printf("GET hello\n")
err = client.Command(&i, "GET", "hello")
if err != nil {
log.Fatalf("Could not GET: %s\n", err.Error())
return
}
log.Printf("> hello = %d\n", i)
client.Quit()
}