modules.go 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/tv/model"
  5. "go-common/library/cache/memcache"
  6. )
  7. //ModulePublish is used for module status MC key
  8. const ModulePublish = "ModulePublish"
  9. //SetModPub is used for set module publish status to MC
  10. func (d *Dao) SetModPub(c context.Context, pageID string, p model.ModPub) (err error) {
  11. conn := d.mc.Get(c)
  12. defer conn.Close()
  13. itemJSON := &memcache.Item{
  14. Key: ModulePublish + pageID,
  15. Object: p,
  16. Flags: memcache.FlagJSON,
  17. Expiration: 0,
  18. }
  19. if err = conn.Set(itemJSON); err != nil {
  20. return
  21. }
  22. return
  23. }
  24. //GetModPub is used for getting module publish status
  25. func (d *Dao) GetModPub(c context.Context, pageID string) (p model.ModPub, err error) {
  26. var (
  27. conn memcache.Conn
  28. item *memcache.Item
  29. )
  30. conn = d.mc.Get(c)
  31. defer conn.Close()
  32. k := ModulePublish + pageID
  33. if item, err = conn.Get(k); err != nil {
  34. return
  35. }
  36. if err = conn.Scan(item, &p); err != nil {
  37. return
  38. }
  39. return
  40. }