using System; using System.Collections.Generic; using System.Linq; using MySystem.MainModels; namespace MySystem { public class UserLevelSetDbconn { public readonly static UserLevelSetDbconn Instance = new UserLevelSetDbconn(); #region 获取列表 public List GetList() { string key = "UserLevelSet"; List list = new List(); if (RedisDbconn.Instance.Exists(key)) { list = RedisDbconn.Instance.GetList(key); if (list.Count > 0) { return list; } } WebCMSEntities db = new WebCMSEntities(); var mysqllist = db.UserLevelSet.OrderBy(m => m.Id).ToList(); if (mysqllist.Count > 0) { List newlist = new List(); foreach (var sub in mysqllist) { newlist.Add(sub); } RedisDbconn.Instance.Clear(key); foreach (UserLevelSet sub in newlist) { RedisDbconn.Instance.AddRightList(key, sub); } RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400)); } db.Dispose(); return list; } #endregion } }