You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RedisConfigInfo.cs 4.5 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using System.Configuration;
  2. namespace Learun.Cache.Redis
  3. {
  4. /// <summary>
  5. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  6. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  7. /// 创建人:陈彬彬
  8. /// 日 期:2017.03.03
  9. /// 描 述:redis配置信息
  10. /// </summary>
  11. public sealed class RedisConfigInfo : ConfigurationSection
  12. {
  13. /// <summary>
  14. /// 获取配置信息
  15. /// </summary>
  16. /// <returns></returns>
  17. public static RedisConfigInfo GetConfig()
  18. {
  19. return GetConfig("redisconfig");
  20. }
  21. /// <summary>
  22. /// 获取配置信息
  23. /// </summary>
  24. /// <param name="sectionName">xml节点名称</param>
  25. /// <returns></returns>
  26. public static RedisConfigInfo GetConfig(string sectionName)
  27. {
  28. RedisConfigInfo section = (RedisConfigInfo)ConfigurationManager.GetSection(sectionName);
  29. if (section == null)
  30. throw new ConfigurationErrorsException("Section " + sectionName + " is not found.");
  31. return section;
  32. }
  33. /// <summary>
  34. /// 可写的Redis链接地址
  35. /// </summary>
  36. [ConfigurationProperty("WriteServerList", IsRequired = false)]
  37. public string WriteServerList
  38. {
  39. get
  40. {
  41. return (string)base["WriteServerList"];
  42. }
  43. set
  44. {
  45. base["WriteServerList"] = value;
  46. }
  47. }
  48. /// <summary>
  49. /// 可读的Redis链接地址
  50. /// </summary>
  51. [ConfigurationProperty("ReadServerList", IsRequired = false)]
  52. public string ReadServerList
  53. {
  54. get
  55. {
  56. return (string)base["ReadServerList"];
  57. }
  58. set
  59. {
  60. base["ReadServerList"] = value;
  61. }
  62. }
  63. /// <summary>
  64. /// 最大写链接数
  65. /// </summary>
  66. [ConfigurationProperty("MaxWritePoolSize", IsRequired = false, DefaultValue = 5)]
  67. public int MaxWritePoolSize
  68. {
  69. get
  70. {
  71. int _maxWritePoolSize = (int)base["MaxWritePoolSize"];
  72. return _maxWritePoolSize > 0 ? _maxWritePoolSize : 5;
  73. }
  74. set
  75. {
  76. base["MaxWritePoolSize"] = value;
  77. }
  78. }
  79. /// <summary>
  80. /// 最大读链接数
  81. /// </summary>
  82. [ConfigurationProperty("MaxReadPoolSize", IsRequired = false, DefaultValue = 5)]
  83. public int MaxReadPoolSize
  84. {
  85. get
  86. {
  87. int _maxReadPoolSize = (int)base["MaxReadPoolSize"];
  88. return _maxReadPoolSize > 0 ? _maxReadPoolSize : 5;
  89. }
  90. set
  91. {
  92. base["MaxReadPoolSize"] = value;
  93. }
  94. }
  95. /// <summary>
  96. /// 自动重启
  97. /// </summary>
  98. [ConfigurationProperty("AutoStart", IsRequired = false, DefaultValue = true)]
  99. public bool AutoStart
  100. {
  101. get
  102. {
  103. return (bool)base["AutoStart"];
  104. }
  105. set
  106. {
  107. base["AutoStart"] = value;
  108. }
  109. }
  110. /// <summary>
  111. /// 本地缓存到期时间,单位:秒
  112. /// </summary>
  113. [ConfigurationProperty("LocalCacheTime", IsRequired = false, DefaultValue = 36000)]
  114. public int LocalCacheTime
  115. {
  116. get
  117. {
  118. return (int)base["LocalCacheTime"];
  119. }
  120. set
  121. {
  122. base["LocalCacheTime"] = value;
  123. }
  124. }
  125. /// <summary>
  126. /// 是否记录日志,该设置仅用于排查redis运行时出现的问题,如redis工作正常,请关闭该项
  127. /// </summary>
  128. [ConfigurationProperty("RecordeLog", IsRequired = false, DefaultValue = false)]
  129. public bool RecordeLog
  130. {
  131. get
  132. {
  133. return (bool)base["RecordeLog"];
  134. }
  135. set
  136. {
  137. base["RecordeLog"] = value;
  138. }
  139. }
  140. /// <summary>
  141. /// 默认开始db
  142. /// </summary>
  143. [ConfigurationProperty("DefaultDb", IsRequired = false)]
  144. public long DefaultDb
  145. {
  146. get
  147. {
  148. return (long)base["DefaultDb"];
  149. }
  150. set
  151. {
  152. base["DefaultDb"] = value;
  153. }
  154. }
  155. }
  156. }