Created
July 4, 2022 07:33
-
-
Save Masum-Osman/380f2a6fba8d323bd7e600e87846d0b5 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
func SetValue(key string, value string) (string, error) { | |
var ctx = context.Background() | |
err := RedisClient.SAdd(ctx, key, value).Err() | |
if err != nil { | |
log.Fatalf("Failed to Set value: %v", err) | |
} | |
shouldExpireOn := time.Now().Add(time.Second * 604000) | |
expireKeyValue := RedisClient.ExpireAt(ctx, key, shouldExpireOn) | |
retrunValue, err := expireKeyValue.Result() | |
if err != nil { | |
return "nil", err | |
} | |
if !retrunValue { | |
return "failed to set expire time", err | |
} | |
return "success", nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment