[feature] basic redis implementation

This commit is contained in:
Abdellah El Morabit 2025-10-30 12:14:56 +01:00
parent 1f2648d50a
commit f763117422

View File

@ -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)
}