MemCachedConfigInfo.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. namespace CB.Cache.MemCached
  3. {
  4. /// <summary>
  5. /// Cache配置模型
  6. /// </summary>
  7. public class MemCachedConfigInfo
  8. {
  9. /// <summary>
  10. /// 服务器列表
  11. /// </summary>
  12. public string[] ServerList { get; set; }
  13. public string PoolName
  14. {
  15. set { _poolname = value; }
  16. get { return string.IsNullOrEmpty(_poolname) ? "Sam.CB.Cache.MemCahed" : _poolname; }
  17. }
  18. private string _poolname;
  19. /// <summary>
  20. /// 初始化链接数
  21. /// </summary>
  22. public int InitConnections
  23. {
  24. get { return _initconnections > 0 ? _initconnections : 3; }
  25. set { _initconnections = value; }
  26. }
  27. private int _initconnections;
  28. /// <summary>
  29. /// 最少链接数
  30. /// </summary>
  31. public int MinConnections
  32. {
  33. get { return _minconnection > 0 ? _minconnection : 3; }
  34. set { _minconnection = value; }
  35. }
  36. private int _minconnection;
  37. /// <summary>
  38. /// 最大连接数
  39. /// </summary>
  40. public int MaxConnections
  41. {
  42. get { return _maxconnections > 0 ? _maxconnections : 5; }
  43. set { _maxconnections = value; }
  44. }
  45. private int _maxconnections;
  46. /// <summary>
  47. /// Socket链接超时时间
  48. /// </summary>
  49. public int SocketConnectTimeout
  50. {
  51. get { return _socketconnecttimeout > 1000 ? _socketconnecttimeout : 1000; }
  52. set { _socketconnecttimeout = value; }
  53. }
  54. private int _socketconnecttimeout;
  55. /// <summary>
  56. /// socket超时时间
  57. /// </summary>
  58. public int SocketTimeout
  59. {
  60. get { return _sockettimeout > 1000 ? _sockettimeout : 3000; }
  61. set { _sockettimeout = value; }
  62. }
  63. private int _sockettimeout;
  64. /// <summary>
  65. /// 维护线程休息时间
  66. /// </summary>
  67. public int MaintenanceSleep
  68. {
  69. get { return _maintenancesleep > 0 ? _maintenancesleep : 30; }
  70. set { _maintenancesleep = value; }
  71. }
  72. private int _maintenancesleep;
  73. /// <summary>
  74. /// 链接失败后是否重启,详情参见http://baike.baidu.com/view/1084309.htm
  75. /// </summary>
  76. public bool FailOver
  77. {
  78. get { return _failover; }
  79. set { _failover = value; }
  80. }
  81. private bool _failover;
  82. /// <summary>
  83. /// 是否用nagle算法启动socket
  84. /// </summary>
  85. public bool Nagle
  86. {
  87. get { return _nagle; }
  88. set { _nagle = value; }
  89. }
  90. private bool _nagle;
  91. }
  92. }