diff --git a/handlers/data/data.go b/handlers/data/data.go index 9e925b7..1f1b501 100644 --- a/handlers/data/data.go +++ b/handlers/data/data.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "instafix/utils" + "math/rand" "strconv" "strings" "time" @@ -129,7 +130,8 @@ func (i *InstaData) GetData(postID string) error { // Write expire to DB expire := make([]byte, 8) - binary.LittleEndian.PutUint64(expire, uint64(time.Now().Add(24*time.Hour).UnixNano())) + randNum := rand.Intn(9999-1000) + 1000 + binary.LittleEndian.PutUint64(expire, uint64(time.Now().Add(24*time.Hour).UnixNano()+int64(randNum))) if err := batch.Set(append([]byte("exp-"), expire...), utils.S2B(postID), pebble.Sync); err != nil { log.Error().Str("postID", postID).Err(err).Msg("Failed to save data to cache") return err