aboutsummaryrefslogtreecommitdiffstats
path: root/internal/cache/redis.go
blob: fec0ba9960ee1f38fcfdbe249ed14afbcd709c5c (plain) (blame)
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
// Package cache contains the redis setup for caching device resources
package cache

import (
	"context"
	"fmt"

	"synf/internal/api/data/models"

	"github.com/redis/go-redis/v9"
)

func Init() *redis.Client {
	client := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // No password set
		DB:       0,  // Use default DB
		Protocol: 2,  // Connection protocol
	})

	return client
}

func Test(client *redis.Client) {
	ctx := context.Background()
	err := client.Set(ctx, "temperature", "44", 0).Err()
	if err != nil {
		panic(err)
	}

	val, err := client.Get(ctx, "temperature").Result()
	if err != nil {
		panic(err)
	}

	fmt.Println(val)
}

func (cpu *models.Cpu) Store() {
}