// GET api/<controller> public HttpResponseMessage Get() { LocalCacheProvider cacheProvider = new LocalCacheProvider(); string cacheKey = "Fx.Manage.AppController.ApplicationList"; string result = cacheProvider.GetCache <string>(cacheKey); if (string.IsNullOrEmpty(result)) { List <SysApplicationEntity> appList = logic.GetSysApplicationList().ToList <SysApplicationEntity>(); List <AppReponseDTO> list = new List <AppReponseDTO>(); foreach (SysApplicationEntity item in appList) { list.Add(new AppReponseDTO() { AppId = item.AppId, AppEName = item.AppEName, AppName = item.AppName, AppTypeId = item.AppTypeId, Status = item.Status, SubSystemId = item.SubSystemId }); } JavaScriptSerializer serializer = new JavaScriptSerializer(); result = serializer.Serialize(list); if (!string.IsNullOrEmpty(result)) { cacheProvider.SetCache <string>(cacheKey, result, DateTime.Now.AddHours(1)); } } return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }
public void TestInit() { _cache = new LocalCacheProvider(); _user = new User { DoubleValue = 999 }; _key = "a"; }
public async Task SetActiveTime(TimeSpan timeFrom, TimeSpan timeTo) { var configuration = await LocalCacheProvider.GetAsync <ITTVConfiguration>(ITTVConfigurationPath) ?? new ITTVConfiguration(); configuration.SetActiveTime(timeFrom, timeTo); await LocalCacheProvider.PutAsync(ITTVConfigurationPath, configuration); await _kinectTvHubHandler.SettingsUpdated(); }
public async Task SetDisplayMessage(string displayMessage) { var configuration = await LocalCacheProvider.GetAsync <ITTVConfiguration>(ITTVConfigurationPath) ?? new ITTVConfiguration(); configuration.SetDisplayMessage(displayMessage); await LocalCacheProvider.PutAsync(ITTVConfigurationPath, configuration); await _kinectTvHubHandler.SettingsUpdated(); }
public async Task <ApiFullScheduleResponse> GetFullSchedule(string group) { var timeUpdated = _settings.CacheUpdateInterval; Func <Task <ApiFullScheduleResponse> > dataSource = () => _mireaApiClient.GetFullScheduleForGroup(group); var schedule = await LocalCacheProvider.GetAsync(LocalCacheHelper.GroupScheduleCacheKey(group), dataSource, timeUpdated); return(schedule); }
public async Task <ApiGroups> GetGroups() { var timeUpdated = _settings.CacheUpdateInterval; Func <Task <ApiGroups> > dataSource = () => _mireaApiClient.GetAllGroups(); var groups = await LocalCacheProvider.GetAsync(LocalCacheHelper.GroupsCacheKey, dataSource, timeUpdated); return(groups); }
public async Task <ApiNewsItem[]> GetNews(TimeSpan?expireDateTime = default) { var timeUpdated = expireDateTime ?? _settings.CacheUpdateInterval; Func <Task <ApiNewsItem[]> > dataSource = () => _mireaApiClient.GetNews(); var news = await LocalCacheProvider.GetAsync(LocalCacheHelper.NewsCacheKey, dataSource, timeUpdated); return(news); }
public static List <System_ModuleAuthorize> GetCache() { var cache = LocalCacheProvider.Get <List <System_ModuleAuthorize> >(CacheKey); if (cache != null) { return(cache); } return(null); }
public void SetTest() { var cache = new LocalCacheProvider(); cache.Set("Name", "fuwei"); cache.Set("Name1", "fuwei"); cache.Set("Name2", "fuwei"); var name = cache.Get("Name"); var keys = cache.KeyList; cache.Remove("Name"); cache.Remove("Name"); cache.ClearAll(); }
/// <summary> /// 通过模块ID获取对应的授权信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static System_ModuleAuthorize GetSecret(string id) { var data = GetCache(); if (data == null) { var list = ModuleAuthorizeProvider.GetBaseList(ServerId); LocalCacheProvider.Set(CacheKey, list); return(list.SingleOrDefault(p => p.ModuleID == id)); } else { return(data.SingleOrDefault(p => p.ModuleID == id)); } }
public ContentResult MetricsKey() { LocalCacheProvider cacheProvider = new LocalCacheProvider(); string cacheKey = "Fx.Manage.Dashboard.MetricsKey"; string result = cacheProvider.GetCache <string>(cacheKey); if (string.IsNullOrEmpty(result)) { JavaScriptSerializer serializer = new JavaScriptSerializer(); List <MetricsKey> list = logic.GetMetricsKeys(); List <string> keys = new List <string>(); foreach (MetricsKey key in list) { keys.Add(key.Key); } result = serializer.Serialize(keys); if (!string.IsNullOrEmpty(result)) { cacheProvider.SetCache <string>(cacheKey, result, DateTime.Now.AddDays(1)); } } return(Content(result)); }
public async Task <ITTVConfiguration> GetTvConfiguration() => await LocalCacheProvider.GetAsync <ITTVConfiguration>(ITTVConfigurationPath) ?? new ITTVConfiguration();