Last active
August 14, 2022 17:07
-
-
Save kirillshevch/0e798d5ebeb71e454612a09a43053cbc to your computer and use it in GitHub Desktop.
This file contains 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" | |
) | |
func main() { | |
var ctx = context.Background() | |
rdb := redis.NewClient(&redis.Options{}) | |
err := rdb.Set(ctx, "key", "value", 0).Err() | |
if err != nil { | |
panic(err) | |
} | |
val, err := rdb.Get(ctx, "key").Result() | |
if err == redis.Nil { | |
fmt.Println("key does not exist") | |
} else if err != nil { | |
panic(err) | |
} else { | |
fmt.Println(val) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment