Skip to content

Instantly share code, notes, and snippets.

@souvikhaldar
Last active October 25, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souvikhaldar/7c3b12af5291d41bbc8a37f8a43a84d4 to your computer and use it in GitHub Desktop.
Save souvikhaldar/7c3b12af5291d41bbc8a37f8a43a84d4 to your computer and use it in GitHub Desktop.
Retrieving the value from Redis using key in golang
// 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