Esempio n. 1
0
        public string UpdateCache(Admin admin, IMemoryCache _cache)
        {
            var    key   = this.TokenKey(admin.Id);
            string value = ConvertJson.ObjToJsonString(admin);

            //查询token是否存在
            if (string.IsNullOrEmpty(_cache.Get <string>(key)))
            {
                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions();
                options.AbsoluteExpiration = DateTime.Now.AddMinutes(1);
                options.SlidingExpiration  = TimeSpan.FromMinutes(1);
                _cache.Set <string>(key, value, options);
            }
            //string token = _cache.Get<string>("token");
            return(key);
        }