pendant_redis.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package dao
  2. import (
  3. "context"
  4. "strconv"
  5. "go-common/library/cache/redis"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _pendantPKG = "pkg_"
  10. _pendantEquip = "pe_"
  11. )
  12. func keyPendantPKG(uid int64) string {
  13. return _pendantPKG + strconv.FormatInt(uid, 10)
  14. }
  15. func keyEquip(uid int64) string {
  16. return _pendantEquip + strconv.FormatInt(uid, 10)
  17. }
  18. // DelPKGCache del package cache
  19. func (d *Dao) DelPKGCache(c context.Context, uids []int64) (err error) {
  20. var (
  21. args = redis.Args{}
  22. conn = d.redis.Get(c)
  23. )
  24. defer conn.Close()
  25. for _, v := range uids {
  26. args = args.Add(keyPendantPKG(v))
  27. }
  28. if err = conn.Send("DEL", args...); err != nil {
  29. log.Error("conn.Send(DEL, %s) error(%v)", args, err)
  30. }
  31. return
  32. }
  33. // DelEquipsCache del batch equip cache .
  34. func (d *Dao) DelEquipsCache(c context.Context, uids []int64) (err error) {
  35. var (
  36. args = redis.Args{}
  37. conn = d.redis.Get(c)
  38. )
  39. defer conn.Close()
  40. for _, v := range uids {
  41. args = args.Add(keyEquip(v))
  42. }
  43. if err = conn.Send("DEL", args...); err != nil {
  44. log.Error("conn.Send(DEL, %s) error(%v)", args, err)
  45. }
  46. return
  47. }