12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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<UserLevelSet> GetList()
- {
- string key = "UserLevelSet";
- List<UserLevelSet> list = new List<UserLevelSet>();
- if (RedisDbconn.Instance.Exists(key))
- {
- list = RedisDbconn.Instance.GetList<UserLevelSet>(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<UserLevelSet> newlist = new List<UserLevelSet>();
- 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
- }
- }
|