Using only one instance of redis

This commit is contained in:
Atridad Lahiji 2023-12-27 15:05:26 -07:00
parent 0ff1d594ad
commit 7350c4f0d0
No known key found for this signature in database

View file

@ -11,6 +11,12 @@ import (
var redis_host = os.Getenv("REDIS_HOST")
var redis_password = os.Getenv("REDIS_PASSWORD")
var rdb = redis.NewClient(&redis.Options{
Addr: redis_host,
Password: redis_password,
DB: 0,
})
func SetCache(key string, value string, ttlMinutes int) bool {
println("Setting the Cache")
rdb := redis.NewClient(&redis.Options{
@ -32,11 +38,7 @@ func SetCache(key string, value string, ttlMinutes int) bool {
func GetCache(key string) string {
println("Fetching From Cache")
rdb := redis.NewClient(&redis.Options{
Addr: redis_host,
Password: redis_password,
DB: 0,
})
if rdb == nil {
panic("Failed to create Redis client")
}