using System; using System.Collections.Generic; using System.Linq; using MySystem.MainModels; namespace MySystem { public class ConsumerOpenIdsDbconn { public readonly static ConsumerOpenIdsDbconn Instance = new ConsumerOpenIdsDbconn(); #region 获取单个字段 public ConsumerOpenIds Get(string OpenId) { string key = "ConsumerOpenIds:" + OpenId; if (RedisDbconn.Instance.Exists(key)) { ConsumerOpenIds obj = RedisDbconn.Instance.Get(key); if (obj != null) { return obj; } } WebCMSEntities db = new WebCMSEntities(); ConsumerOpenIds order = db.ConsumerOpenIds.FirstOrDefault(m => m.OpenId == OpenId); if (order != null) { RedisDbconn.Instance.Set(key, order); RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400)); } return order; } #endregion } }