AreaCacheService.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using YiSha.Business.Cache.IService;
  4. using YiSha.Cache.Factory;
  5. using YiSha.Entity.SystemManage;
  6. using YiSha.IService.SystemManage;
  7. namespace YiSha.Business.Cache.Service
  8. {
  9. public class AreaCacheService : IAreaCacheService<AreaEntity>
  10. {
  11. private IAreaService _areaService;
  12. public AreaCacheService(IAreaService areaService)
  13. {
  14. _areaService = areaService;
  15. }
  16. public string CacheKey => this.GetType().Name;
  17. public async Task<List<AreaEntity>> GetList()
  18. {
  19. var cacheList = CacheFactory.Cache.GetCache<List<AreaEntity>>(CacheKey);
  20. if (cacheList == null)
  21. {
  22. var result = await _areaService.GetListPartial(null);
  23. CacheFactory.Cache.SetCache(CacheKey, result);
  24. return result;
  25. }
  26. else
  27. {
  28. return cacheList;
  29. }
  30. }
  31. public bool Remove()
  32. {
  33. return CacheFactory.Cache.RemoveCache(CacheKey);
  34. }
  35. }
  36. }