mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-08-06 04:23:29 +00:00
refactor: use sample code from Aiven
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
VALKEY_URL=valkey://default@127.0.0.1:6379
|
||||
VALKEY_URI=valkey://default@127.0.0.1:6379
|
||||
|
||||
+4
-9
@@ -17,20 +17,15 @@ func main() {
|
||||
log.Println("Warning: .env file not found")
|
||||
}
|
||||
|
||||
valkeyUrl, isExist := os.LookupEnv("VALKEY_URL")
|
||||
valkeyURI, isExist := os.LookupEnv("VALKEY_URI")
|
||||
if !isExist {
|
||||
log.Fatal("Warning: VALKEY_URL not set!")
|
||||
log.Fatal("Warning: VALKEY_URI not set!")
|
||||
return
|
||||
}
|
||||
|
||||
opt, err := valkey.ParseURL(valkeyUrl)
|
||||
client, err := valkey.NewClient(valkey.ClientOption{InitAddress: []string{valkeyURI}})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
client, err := valkey.NewClient(opt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
Reference in New Issue
Block a user