RedisConfigInfo.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System.Configuration;
  2. namespace CB.Cache.Redis
  3. {
  4. /// <inheritdoc />
  5. /// <summary>
  6. /// Redis配置
  7. /// </summary>
  8. public sealed class RedisConfigInfo : ConfigurationSection
  9. {
  10. public static RedisConfigInfo GetConfig()
  11. {
  12. RedisConfigInfo section = (RedisConfigInfo)ConfigurationManager.GetSection("redisconfig");
  13. return section;
  14. }
  15. /// <summary>
  16. /// 可写的Redis链接地址
  17. /// </summary>
  18. [ConfigurationProperty("WriteServerList", IsRequired = false)]
  19. public string WriteServerList
  20. {
  21. get
  22. {
  23. return (string)base["WriteServerList"];
  24. }
  25. set
  26. {
  27. base["WriteServerList"] = value;
  28. }
  29. }
  30. /// <summary>
  31. /// 可读的Redis链接地址
  32. /// </summary>
  33. [ConfigurationProperty("ReadServerList", IsRequired = false)]
  34. public string ReadServerList
  35. {
  36. get
  37. {
  38. return (string)base["ReadServerList"];
  39. }
  40. set
  41. {
  42. base["ReadServerList"] = value;
  43. }
  44. }
  45. /// <summary>
  46. /// 最大写链接数
  47. /// </summary>
  48. [ConfigurationProperty("MaxWritePoolSize", IsRequired = false, DefaultValue = 5)]
  49. public int MaxWritePoolSize
  50. {
  51. get
  52. {
  53. int maxWritePoolSize = (int)base["MaxWritePoolSize"];
  54. return maxWritePoolSize > 0 ? maxWritePoolSize : 5;
  55. }
  56. set
  57. {
  58. base["MaxWritePoolSize"] = value;
  59. }
  60. }
  61. /// <summary>
  62. /// 最大读链接数
  63. /// </summary>
  64. [ConfigurationProperty("MaxReadPoolSize", IsRequired = false, DefaultValue = 5)]
  65. public int MaxReadPoolSize
  66. {
  67. get
  68. {
  69. int maxReadPoolSize = (int)base["MaxReadPoolSize"];
  70. return maxReadPoolSize > 0 ? maxReadPoolSize : 5;
  71. }
  72. set
  73. {
  74. base["MaxReadPoolSize"] = value;
  75. }
  76. }
  77. /// <summary>
  78. /// 自动重启
  79. /// </summary>
  80. [ConfigurationProperty("AutoStart", IsRequired = false, DefaultValue = true)]
  81. public bool AutoStart
  82. {
  83. get
  84. {
  85. return (bool)base["AutoStart"];
  86. }
  87. set
  88. {
  89. base["AutoStart"] = value;
  90. }
  91. }
  92. /// <summary>
  93. /// 本地缓存到期时间,单位:秒
  94. /// </summary>
  95. [ConfigurationProperty("LocalCacheTime", IsRequired = false, DefaultValue = 36000)]
  96. public int LocalCacheTime
  97. {
  98. get
  99. {
  100. return (int)base["LocalCacheTime"];
  101. }
  102. set
  103. {
  104. base["LocalCacheTime"] = value;
  105. }
  106. }
  107. /// <summary>
  108. /// 是否记录日志,该设置仅用于排查redis运行时出现的问题,如redis工作正常,请关闭该项
  109. /// </summary>
  110. [ConfigurationProperty("RecordeLog", IsRequired = false, DefaultValue = false)]
  111. public bool RecordeLog
  112. {
  113. get
  114. {
  115. return (bool)base["RecordeLog"];
  116. }
  117. set
  118. {
  119. base["RecordeLog"] = value;
  120. }
  121. }
  122. }
  123. }