view.go 905 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package ugc
  2. import (
  3. "context"
  4. arccli "go-common/app/service/main/archive/api"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. )
  8. // viewCache distinguishes the archive's license status,
  9. // if it's ok, we call it's RPC and save the result in MC cache to accelerate the view page loading
  10. func (s *Service) viewCache(aid int64) {
  11. if aid == 0 {
  12. return
  13. }
  14. var (
  15. c = context.Background()
  16. err error
  17. arg = &arccli.ViewRequest{Aid: aid}
  18. v *arccli.ViewReply
  19. )
  20. if v, err = s.arcClient.View(c, arg); err != nil {
  21. if ecode.Cause(err) == ecode.NothingFound {
  22. log.Warn("s.arcRPC.View3(%v) error(%v)", arg, err)
  23. err = nil
  24. return
  25. }
  26. log.Error("s.arcRPC.View3(%v) error(%v)", arg, err)
  27. return
  28. }
  29. if err = s.arcDao.UpArcCache(c, v.Arc); err != nil {
  30. log.Error("viewCache %+v", err)
  31. return
  32. }
  33. if s.arcDao.UpViewCache(c, v); err != nil {
  34. log.Error("viewCache %+v", err)
  35. }
  36. }