dashboard.go 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/ep/merlin/model"
  5. "go-common/library/cache/memcache"
  6. )
  7. //QueryMachineUsageSummaryFromCache Machine Usage Summary In Cache.
  8. func (d *Dao) QueryMachineUsageSummaryFromCache(c context.Context, pqadmrs []*model.PaasQueryAndDelMachineRequest) (pmds []*model.PaasMachineDetail, err error) {
  9. var (
  10. conn = d.mc.Get(c)
  11. item *memcache.Item
  12. )
  13. defer conn.Close()
  14. for _, pqadmr := range pqadmrs {
  15. pmd := &model.PaasMachineDetail{}
  16. if item, err = conn.Get(pqadmr.Name); err == nil {
  17. if err = conn.Scan(item, &pmd); err == nil {
  18. pmds = append(pmds, pmd)
  19. continue
  20. }
  21. }
  22. if pmd, err = d.QueryPaasMachine(c, pqadmr); err != nil {
  23. continue
  24. }
  25. pmds = append(pmds, pmd)
  26. item = &memcache.Item{Key: pqadmr.Name, Object: pmd, Flags: memcache.FlagJSON, Expiration: d.expire}
  27. d.tokenCacheSave(c, item)
  28. }
  29. return
  30. }