/// <summary>
 /// 清除用户权限信息缓存
 /// </summary>
 public static void Clear(IPersistBroker broker)
 {
     UserPrivliege.Clear();
     ServiceContainer.ResolveAll <IRole>().Each(item =>
     {
         (item as BasicRole).Broker = broker;
         item.ClearCache();
         MemoryCacheUtil.RemoveCacheItem(item.GetRoleKey);
         MemoryCacheUtil.Set(item.GetRoleKey, new RolePrivilegeModel()
         {
             Role = item.GetSysRole(), Privileges = item.GetRolePrivilege()
         }, 3600 * 12);
     });
 }
Example #2
0
        /// <summary>
        /// 刷新Token
        /// </summary>
        public static AccessTokenResponse RefreshToken()
        {
            var result      = WeChatApi.GetAccessToken(_appid, _secret);
            var accessToken = new AccessTokenResponse()
            {
                AccessToken = result.AccessToken,
                Expire      = result.Expire
            };

            MemoryCacheUtil.RemoveCacheItem("AccessToken");
            MemoryCacheUtil.Set("AccessToken", accessToken);
            var logger = LogFactory.GetLogger("wechat");

            logger.Debug("获取微信access_token成功:" + accessToken.AccessToken);
            return(accessToken);
        }
Example #3
0
 /// <summary>
 /// 清除角色缓存
 /// </summary>
 public void ClearCache()
 {
     MemoryCacheUtil.RemoveCacheItem($"{PRIVILEGE_PREFIX}_{RoleName}");
     MemoryCacheUtil.RemoveCacheItem($"{ROLE_PREFIX}_{RoleName}");
 }