public ActionResult Login(LoginVM vm) { if (vm.Code == string.Empty || vm.Code != (string)MemoryCacheTime.GetCacheValue(ImageCodeHelper.CacheKey + vm.UUId)) { return(View(CreateVM <LoginVM>())); } var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = ""; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } return(Redirect(HttpUtility.UrlDecode(url))); } }
public static byte[] ImageCodeToByte(string uuid) { string code = RandomHelper.GetRandomCode(4); string key = CacheKey + uuid; MemoryCacheTime.SetChacheValue(key, code, 300); byte[] bytes = CreateImage(code); return(bytes); }
public override async Task OnExcuting(IInvocation invocation) { string key = GetCacheKey(invocation); if (isLocal) { invocation.ReturnValue = MemoryCacheTime.GetCacheValue(key); } else { var cahceVaule = IocContainer.Container.Get <ICache>().StringGet(key); if (!cahceVaule.IsNullOrEmpty()) { invocation.ReturnValue = cahceVaule.ToModel(invocation.MethodInvocationTarget.ReturnType); } } Debug.WriteLine("缓存执行前"); }
public override async Task OnExit(IInvocation invocation) { string key = GetCacheKey(invocation); if (isLocal) { if (isSliding) { MemoryCacheTime.SetSlidingChacheValue(key, invocation.ReturnValue, ExpiresAtSecond); } else { MemoryCacheTime.SetChacheValue(key, invocation.ReturnValue, ExpiresAtSecond); } } else { //redis IocContainer.Container.Get <ICache>().StringSet(key, invocation.ReturnValue.ToJson(), TimeSpan.FromSeconds(ExpiresAtSecond)); } Debug.WriteLine("缓存执行后"); }