Created
August 2, 2018 12:16
-
-
Save romanitalian/9d7652e703487ea7241ca45c6ae4343c 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 ( | |
"fmt" | |
"time" | |
"github.com/go-redis/redis" | |
) | |
var RedisClient *redis.Client | |
func init() { | |
RedisHost = "host.ru:6379" | |
RedisPass = "" | |
RedisDb = 0 | |
} | |
func main() { | |
RedisClient = redis.NewClient(&redis.Options{ | |
Addr: RedisHost, | |
Password: RedisPass, | |
DB: RedisDb, | |
}) | |
someCondition := true | |
val := "" | |
if someCondition{ | |
cacheKey := "0123456" | |
val, _ := RedisClient.Get(cacheKey).Result() | |
if val = "" { | |
var = "foo" | |
} | |
RedisClient.Set(cacheKey, val, 5*time.Minute) | |
} | |
fmt.Println(someCondition) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment