Пример #1
0
        public static async void AfterInsertedAsync(IInsertedEntry <SysMenu, DbContext> entry)
        {
            using (var service = AspectCoreContainer.Resolve <ISysMenuRepository>())
            {
                var parentMenu = await service.GetSingleAsync(entry.Entity.ParentId);

                entry.Entity.MenuPath  = (parentMenu?.MenuPath ?? "0") + "," + entry.Entity.Id;
                entry.Entity.SortIndex = entry.Entity.Id;
                service.Update(entry.Entity, false, "MenuPath", "SortIndex");
                await DistributedCacheManager.RemoveAsync("Redis_Cache_SysMenu");//插入成功后清除缓存以更新
            }
        }
 public UserRepositories(IDbContextCore dbContext) : base(dbContext)
 {
     //插入成功后触发
     Triggers <User> .Inserted += async entry =>
     {
         await DistributedCacheManager.RemoveAsync("Redis_Cache_User");//插入成功后清除缓存以更新
     };
     //修改时触发
     Triggers <User> .Updating += async entry =>
     {
         await DistributedCacheManager.RemoveAsync("Redis_Cache_User");//插入成功后清除缓存以更新
     };
 }
 public async Task RemoveCurrent()
 {
     await DistributedCacheManager.RemoveAsync(_operatorCacheKey);
 }