1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using YiSha.Business.Cache.IService;
- using YiSha.Cache.Factory;
- using YiSha.Entity.SystemManage;
- using YiSha.IService.SystemManage;
- namespace YiSha.Business.Cache.Service
- {
- public class AreaCacheService : IAreaCacheService<AreaEntity>
- {
- private IAreaService _areaService;
- public AreaCacheService(IAreaService areaService)
- {
- _areaService = areaService;
- }
- public string CacheKey => this.GetType().Name;
- public async Task<List<AreaEntity>> GetList()
- {
- var cacheList = CacheFactory.Cache.GetCache<List<AreaEntity>>(CacheKey);
- if (cacheList == null)
- {
- var result = await _areaService.GetListPartial(null);
- CacheFactory.Cache.SetCache(CacheKey, result);
- return result;
- }
- else
- {
- return cacheList;
- }
- }
- public bool Remove()
- {
- return CacheFactory.Cache.RemoveCache(CacheKey);
- }
- }
- }
|