|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using System.Configuration;
-
- namespace Learun.Cache.Redis
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.03.03
- /// 描 述:redis配置信息
- /// </summary>
- public sealed class RedisConfigInfo : ConfigurationSection
- {
- /// <summary>
- /// 获取配置信息
- /// </summary>
- /// <returns></returns>
- public static RedisConfigInfo GetConfig()
- {
- return GetConfig("redisconfig");
- }
- /// <summary>
- /// 获取配置信息
- /// </summary>
- /// <param name="sectionName">xml节点名称</param>
- /// <returns></returns>
- public static RedisConfigInfo GetConfig(string sectionName)
- {
- RedisConfigInfo section = (RedisConfigInfo)ConfigurationManager.GetSection(sectionName);
- if (section == null)
- throw new ConfigurationErrorsException("Section " + sectionName + " is not found.");
- return section;
- }
- /// <summary>
- /// 可写的Redis链接地址
- /// </summary>
- [ConfigurationProperty("WriteServerList", IsRequired = false)]
- public string WriteServerList
- {
- get
- {
- return (string)base["WriteServerList"];
- }
- set
- {
- base["WriteServerList"] = value;
- }
- }
- /// <summary>
- /// 可读的Redis链接地址
- /// </summary>
- [ConfigurationProperty("ReadServerList", IsRequired = false)]
- public string ReadServerList
- {
- get
- {
- return (string)base["ReadServerList"];
- }
- set
- {
- base["ReadServerList"] = value;
- }
- }
- /// <summary>
- /// 最大写链接数
- /// </summary>
- [ConfigurationProperty("MaxWritePoolSize", IsRequired = false, DefaultValue = 5)]
- public int MaxWritePoolSize
- {
- get
- {
- int _maxWritePoolSize = (int)base["MaxWritePoolSize"];
- return _maxWritePoolSize > 0 ? _maxWritePoolSize : 5;
- }
- set
- {
- base["MaxWritePoolSize"] = value;
- }
- }
- /// <summary>
- /// 最大读链接数
- /// </summary>
- [ConfigurationProperty("MaxReadPoolSize", IsRequired = false, DefaultValue = 5)]
- public int MaxReadPoolSize
- {
- get
- {
- int _maxReadPoolSize = (int)base["MaxReadPoolSize"];
- return _maxReadPoolSize > 0 ? _maxReadPoolSize : 5;
- }
- set
- {
- base["MaxReadPoolSize"] = value;
- }
- }
- /// <summary>
- /// 自动重启
- /// </summary>
- [ConfigurationProperty("AutoStart", IsRequired = false, DefaultValue = true)]
- public bool AutoStart
- {
- get
- {
- return (bool)base["AutoStart"];
- }
- set
- {
- base["AutoStart"] = value;
- }
- }
- /// <summary>
- /// 本地缓存到期时间,单位:秒
- /// </summary>
- [ConfigurationProperty("LocalCacheTime", IsRequired = false, DefaultValue = 36000)]
- public int LocalCacheTime
- {
- get
- {
- return (int)base["LocalCacheTime"];
- }
- set
- {
- base["LocalCacheTime"] = value;
- }
- }
- /// <summary>
- /// 是否记录日志,该设置仅用于排查redis运行时出现的问题,如redis工作正常,请关闭该项
- /// </summary>
- [ConfigurationProperty("RecordeLog", IsRequired = false, DefaultValue = false)]
- public bool RecordeLog
- {
- get
- {
- return (bool)base["RecordeLog"];
- }
- set
- {
- base["RecordeLog"] = value;
- }
- }
- /// <summary>
- /// 默认开始db
- /// </summary>
- [ConfigurationProperty("DefaultDb", IsRequired = false)]
- public long DefaultDb
- {
- get
- {
- return (long)base["DefaultDb"];
- }
- set
- {
- base["DefaultDb"] = value;
- }
- }
-
- }
- }
|