Created
August 16, 2021 13:20
-
-
Save r14152/4a62c1ad5d30aa59ef814cd00adfd5c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/go-redis/redis/v8" | |
) | |
var ( | |
ctx = context.Background() | |
rdb *redis.Client | |
) | |
func init() { | |
var err error | |
rdb = redis.NewClient(&redis.Options{ | |
Addr: "localhost:6379", | |
Password: "", // no password set | |
DB: 0, // use default DB | |
}) | |
} | |
func checkConnectionStatus() { | |
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) | |
} | |
func main() { | |
fmt.Println("Redis Setup Done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment