Last active
October 25, 2018 11:55
-
-
Save souvikhaldar/7c3b12af5291d41bbc8a37f8a43a84d4 to your computer and use it in GitHub Desktop.
Retrieving the value from Redis using key in golang
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
// GetValue the value corresponding to a given key | |
func GetValue(key string) (string, error) { | |
value, arghhh := redisClient.Get(key).Result() | |
if arghhh != nil { | |
return "", arghhh | |
} | |
return value, nil | |
} | |
originalNum, e := GetValue(otp.SmsNonce) | |
if e != nil { | |
c.JSON(403, oopsies.RecordError(oopsies.RedisGet,"Error in getting num",e.Error())) | |
return | |
} | |
originalOtp, e := GetValue(originalNum) | |
if e != nil { | |
c.JSON(403, oopsies.RecordError(oopsies.RedisGet,"Error in getting OTP",e.Error())) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment