123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System.Configuration;
- namespace CB.Cache.Redis
- {
- /// <inheritdoc />
- /// <summary>
- /// Redis配置
- /// </summary>
- public sealed class RedisConfigInfo : ConfigurationSection
- {
- public static RedisConfigInfo GetConfig()
- {
- RedisConfigInfo section = (RedisConfigInfo)ConfigurationManager.GetSection("redisconfig");
- 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;
- }
- }
- }
- }
|