task_mc.go 591 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. gmc "go-common/library/cache/memcache"
  6. "go-common/library/log"
  7. )
  8. // IsConsumerOn .
  9. func (d *Dao) IsConsumerOn(c context.Context, bizid, flowid int, uid int64) (isOn bool, err error) {
  10. conn := d.mc.Get(c)
  11. defer conn.Close()
  12. key := mcKey(bizid, flowid, uid)
  13. if _, err = conn.Get(key); err != nil {
  14. if err == gmc.ErrNotFound {
  15. err = nil
  16. } else {
  17. log.Error("IsConsumerOn error(%v)", err)
  18. }
  19. return
  20. }
  21. isOn = true
  22. return
  23. }
  24. func mcKey(bizid, flowid int, uid int64) string {
  25. return fmt.Sprintf("aegis%d_%d_%d", bizid, flowid, uid)
  26. }