123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- 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 MenuCacheService : IMenuCacheService<MenuEntity>
- {
- private IMenuService _menuService;
- public MenuCacheService(IMenuService menuService)
- {
- _menuService = menuService;
- }
- public string CacheKey => this.GetType().Name;
- public async Task<List<MenuEntity>> GetList()
- {
- var cacheList = CacheFactory.Cache.GetCache<List<MenuEntity>>(CacheKey);
- if (cacheList == null)
- {
- var list = await _menuService.GetListPartial(null);
- CacheFactory.Cache.SetCache(CacheKey, list);
- return list;
- }
- else
- {
- return cacheList;
- }
- }
- public bool Remove()
- {
- return CacheFactory.Cache.RemoveCache(CacheKey);
- }
- }
- }
|