public ConsumerInfo GetConsumerInfo(string consumerId) { var key = "ConsumerInfo_" + consumerId; ConsumerInfo result = null; if (RedisCacheHelper.Exists(key)) { result = RedisCacheHelper.GetCache <ConsumerInfo>(key); } if (result == null) { var doc = dataOp.FindOneByQuery(MQConsumerInfo, Query.EQ("consumerId", consumerId)); var ip = doc.String("ip"); var queueType = doc.String("queueType"); var id = doc.String("consumerId"); var isStart = doc.Int("isStart"); var lastStartTime = doc.Date("lastStartTime"); var lastEndTime = doc.Date("lastEndTime"); var lastExecTime = doc.Date("lastExecTime"); result = new ConsumerInfo() { consumerId = id, ip = ip, isStart = isStart, lastEndTime = lastEndTime, lastExecTime = lastExecTime, lastStartTime = lastStartTime, queueType = queueType }; RedisCacheHelper.SetCache(key, result, DateTime.Now.AddDays(30)); } return(result); }
public string GetCustomerNameByJobId(string jobId) { var key = "JobIdCustomerName_" + jobId; string result = null; if (RedisCacheHelper.Exists(key)) { result = RedisCacheHelper.GetCache <string>(key); } if (string.IsNullOrEmpty(result)) { var doc = dataOp.FindOneByQuery("BackgroundJob", Query.EQ("jobId", jobId)); var code = doc.String("customerCode"); doc = dataOp.FindOneByQuery("CustomerInfo", Query.EQ("customerCode", code)); result = doc.String("name"); RedisCacheHelper.SetCache(key, result, DateTime.Now.AddDays(1)); } return(result); }