sphsd.go 509 B

123456789101112131415161718192021
  1. package sphsd
  2. import (
  3. "active/constant"
  4. "fmt"
  5. "git.jiaxianghudong.com/webs/pkg/rds"
  6. "time"
  7. )
  8. func GetData(userId, tm string) string {
  9. data := rds.Redis.HGet(fmt.Sprintf(constant.SPHSD, tm), userId).Val()
  10. return data
  11. }
  12. func SetData(userId, tm string, endTm string) bool {
  13. rds.Redis.HSet(fmt.Sprintf(constant.SPHSD, tm), userId, "1")
  14. end, _ := time.Parse("2006-01-02 15:04:05", endTm)
  15. expireAt := end.Add(1 * time.Hour)
  16. rds.Redis.ExpireAt(fmt.Sprintf(constant.SPHSD, tm), expireAt)
  17. return true
  18. }