porder.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package archive
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/model/archive"
  5. "go-common/library/log"
  6. )
  7. // Porder fn
  8. func (s *Service) Porder(c context.Context, aid int64) (pd *archive.Porder, err error) {
  9. log.Warn("Porder with aid (%+v)", aid)
  10. cache := true
  11. if pd, err = s.arc.POrderCache(c, aid); err != nil {
  12. err = nil
  13. cache = false
  14. } else if pd != nil {
  15. s.pCacheHit.Incr("porder_cache")
  16. return
  17. }
  18. s.pCacheMiss.Incr("porder_cache")
  19. if pd, err = s.arc.Porder(c, aid); err != nil {
  20. log.Error("s.porder.Porder aid(%d) err(%v)", aid, err)
  21. return
  22. }
  23. if cache {
  24. s.addCache(func() {
  25. if pd == nil {
  26. pd = &archive.Porder{}
  27. }
  28. s.arc.AddPOrderCache(context.Background(), aid, pd)
  29. })
  30. }
  31. return
  32. }
  33. // FlowJudge fn
  34. func (s *Service) FlowJudge(c context.Context, business, groupID int64, oids []int64) (hitOids []int64, err error) {
  35. if hitOids, err = s.arc.FlowJudge(c, business, groupID, oids); err != nil {
  36. log.Error("s.porder.FlowJudge business(%d) groupID(%d) err(%v)", business, groupID, err)
  37. return
  38. }
  39. return
  40. }