-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache.go
More file actions
43 lines (35 loc) · 877 Bytes
/
cache.go
File metadata and controls
43 lines (35 loc) · 877 Bytes
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
package main
import (
"github.com/go-redis/redis"
"fmt"
)
func PongExample(client *redis.Client) {
pong, err := client.Ping().Result()
fmt.Println(pong, err)
}
func IncrementarContador(client *redis.Client, key string) {
client.HIncrBy(key, "contador", 1).Result()
}
func ListarGifs(client *redis.Client, fecha string) {
cmd := client.Get(fecha)
fmt.Println(cmd)
val, err := client.Get(fecha).Result()
fmt.Println(val, err)
}
func main() {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
gif := make(map[string]interface{})
gif["contenido"] = "Hola"
gif["contador"] = 0
hash, err := client.HMSet("gif", gif).Result()
fmt.Println(hash, err)
val, err := client.HIncrBy("gif", "contador", 1).Result()
fmt.Println(val, err)
//PongExample(client)
//ExampleClient(client)
//ListarGifs(client, "foo")
}