/// <summary> /// 设置缓存 /// </summary> /// <param name="key">cache_key</param> /// <param name="something">content if null : remove cache</param> /// <returns></returns> private void SetCache(string key, object something = null) { if (key != null) { if (something == null) { //删除缓存 DistributedCacheManager.Remove(key); } else { //根据key获取缓存 var content = DistributedCacheManager.Get(key); if (content != null) { //删除缓存 DistributedCacheManager.Remove(key); } //设置缓存 DistributedCacheManager.Set(key, something, 10); } } return; }
public static void AfterInserted(IInsertedEntry <SysMenu, DbContext> entry) { using (var service = AspectCoreContainer.Resolve <ISysMenuRepository>()) { if (string.IsNullOrEmpty(entry.Entity.ParentId)) { entry.Entity.MenuPath = entry.Entity.Id; } else { var parentMenu = service.GetSingle(entry.Entity.ParentId); if (string.IsNullOrEmpty(parentMenu?.MenuPath)) { entry.Entity.MenuPath = entry.Entity.Id; } else { entry.Entity.MenuPath = parentMenu.MenuPath + "," + entry.Entity.Id; } } service.Update(entry.Entity, false, "MenuPath"); DistributedCacheManager.Remove("Redis_Cache_SysMenu");//����ɹ�����������Ը��� } }