using System;

namespace CB.Cache.MemCached
{
    /// <summary>
    /// Cache配置模型 
    /// </summary>
    public class MemCachedConfigInfo
    {
        /// <summary>
        /// 服务器列表
        /// </summary>
        public string[] ServerList { get; set; }

        public string PoolName
        {
            set { _poolname = value; }
            get { return string.IsNullOrEmpty(_poolname) ? "Sam.CB.Cache.MemCahed" : _poolname; }
        }
        private string _poolname;


        /// <summary>
        /// 初始化链接数
        /// </summary>
        public int InitConnections
        {
            get { return _initconnections > 0 ? _initconnections : 3; }
            set { _initconnections = value; }
        }
        private int _initconnections;




        /// <summary>
        /// 最少链接数
        /// </summary>
        public int MinConnections
        {
            get { return _minconnection > 0 ? _minconnection : 3; }
            set { _minconnection = value; }
        }
        private int _minconnection;


        /// <summary>
        /// 最大连接数
        /// </summary>
        public int MaxConnections
        {
            get { return _maxconnections > 0 ? _maxconnections : 5; }
            set { _maxconnections = value; }
        }
        private int _maxconnections;


        /// <summary>
        /// Socket链接超时时间
        /// </summary>
        public int SocketConnectTimeout
        {
            get { return _socketconnecttimeout > 1000 ? _socketconnecttimeout : 1000; }
            set { _socketconnecttimeout = value; }
        }
        private int _socketconnecttimeout;


        /// <summary>
        /// socket超时时间
        /// </summary>
        public int SocketTimeout
        {
            get { return _sockettimeout > 1000 ? _sockettimeout : 3000; }
            set { _sockettimeout = value; }
        }
        private int _sockettimeout;


        /// <summary>
        /// 维护线程休息时间
        /// </summary>
        public int MaintenanceSleep
        {
            get { return _maintenancesleep > 0 ? _maintenancesleep : 30; }
            set { _maintenancesleep = value; }
        }
        private int _maintenancesleep;


        /// <summary>
        /// 链接失败后是否重启,详情参见http://baike.baidu.com/view/1084309.htm
        /// </summary>
        public bool FailOver
        {
            get { return _failover; }
            set { _failover = value; }
        }
        private bool _failover;


        /// <summary>
        /// 是否用nagle算法启动socket
        /// </summary>
        public bool Nagle
        {
            get { return _nagle; }
            set { _nagle = value; }
        }
        private bool _nagle;
    }
}