From f7631174221ffe6b15229c253ea0fd4c25f10d39 Mon Sep 17 00:00:00 2001 From: nasr Date: Thu, 30 Oct 2025 12:14:56 +0100 Subject: [PATCH] [feature] basic redis implementation --- internal/cache/redis.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/cache/redis.go b/internal/cache/redis.go index 2380897..7b47554 100644 --- a/internal/cache/redis.go +++ b/internal/cache/redis.go @@ -2,12 +2,15 @@ package cache import ( + "context" + "fmt" + "github.com/redis/go-redis/v9" ) func Init() *redis.Client { client := redis.NewClient(&redis.Options{ - Addr: "localhost:8050", + Addr: "localhost:6379", Password: "", // No password set DB: 0, // Use default DB Protocol: 2, // Connection protocol @@ -15,3 +18,18 @@ func Init() *redis.Client { return client } + +func StoreLocal(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) +}