MeterListCache.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using LeaRun.Application.Busines.PipeNetworkManage;
  7. using LeaRun.Cache.Factory;
  8. using LeaRun.Application.Entity.PipeNetworkManage;
  9. namespace LeaRun.Application.Cache
  10. {
  11. /// <summary>
  12. /// 设备信息缓存
  13. /// </summary>
  14. public class MeterListCache
  15. {
  16. private MeterBLL meterBll = new MeterBLL();
  17. /// <summary>
  18. /// 设备信息
  19. /// </summary>
  20. /// <returns></returns>
  21. public IEnumerable<MeterEntity> GetMeterList()
  22. {
  23. var cacheList = CacheFactory.Cache().GetCache<IEnumerable<MeterEntity>>(meterBll.cacheKey);
  24. if (cacheList == null)
  25. {
  26. var data = meterBll.GetMeters();
  27. CacheFactory.Cache().WriteCache(data, meterBll.cacheKey);
  28. return data;
  29. }
  30. else
  31. {
  32. return cacheList;
  33. }
  34. }
  35. }
  36. }