You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
262 B

  1. package utils
  2. import (
  3. "math/rand"
  4. "practice_ArticleVote_Go/internal/consts"
  5. "time"
  6. )
  7. func GetCacheTTL() time.Duration {
  8. baseTTL := consts.BASE_TTL
  9. randomNumber := rand.Intn(consts.RANDOM_RANGE)
  10. return time.Duration(baseTTL+randomNumber) * time.Second
  11. }