initial inventory service

This commit is contained in:
matst80
2025-11-04 12:48:41 +01:00
parent 42e38504a3
commit c67ebd7a5f
7 changed files with 237 additions and 2 deletions

41
cmd/inventory/main.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"context"
"fmt"
"github.com/redis/go-redis/v9"
"github.com/redis/go-redis/v9/maintnotifications"
)
func main() {
var ctx = context.Background()
rdb := redis.NewClient(&redis.Options{
Addr: "10.10.3.18:6379",
Password: "slaskredis", // no password set
DB: 0, // use default DB
MaintNotificationsConfig: &maintnotifications.Config{
Mode: maintnotifications.ModeDisabled,
},
})
err := rdb.Set(ctx, "key", "value", 0).Err()
if err != nil {
panic(err)
}
val, err := rdb.Get(ctx, "key").Result()
if err != nil {
panic(err)
}
fmt.Println("key", val)
val2, err := rdb.Get(ctx, "key2").Result()
if err == redis.Nil {
fmt.Println("key2 does not exist")
} else if err != nil {
panic(err)
} else {
fmt.Println("key2", val2)
}
}