public async Task PutAsync(string key, object value) { var configInfo = await _dbContext.FindAsync <SysConfigInfo>(key); if (configInfo == null) { configInfo = new SysConfigInfo { Key = key }; configInfo.Value = Object2String(value); configInfo.LastValue = Object2String(value); } else { configInfo.Value = Object2String(value); configInfo.LastValue = configInfo.Value; } configInfo.IsDeleted = false; configInfo.Version += 1; configInfo.EffectiveDt = DateTime.Now.AddMinutes(EFFECTIVEDELAY); await _dbContext.SaveChangesAsync(); }
public T GetData <T> (string key) { SysConfigInfo config = null; while (_status != "running") { if (_status == "stop") { throw new Exception("programa stoped"); } Thread.Sleep(100); } if (_configs.TryGetValue(key, out config)) { if (config == null || config.IsDeleted) { throw new Exception($"config key {key} not found"); } return(config.GetValue <T>()); } throw new Exception($"config key {key} not found"); }