Fix: duplicate short key

This commit is contained in:
CareyWong 2020-03-29 01:48:44 +08:00
parent 3f5b8ac05d
commit 1f239cc0c2

View File

@ -153,8 +153,8 @@ func longToShort(longUrl string, ttl int) string {
for i := 0; i < 3; i++ {
shortKey = generate(6)
_existsLongUrl, _ := redis.String(redisClient.Do("get", longUrl))
if _existsLongUrl != "" {
_existsLongUrl, _ := redis.String(redisClient.Do("get", shortKey))
if _existsLongUrl == "" {
break
}
}