コード例 #1
0
 public RedisConnectionPoolMember(RedisSocket socket, int dbIndex, RedisConnectionSettings settings)
 {
     DbIndex    = dbIndex;
     Socket     = socket;
     m_Settings = settings;
     PooledTime = DateTime.UtcNow;
 }
コード例 #2
0
ファイル: RedisSocket.cs プロジェクト: ocdogan/Sweet.Redis
 internal bool SelectDB(RedisConnectionSettings settings, int dbIndex)
 {
     if (dbIndex >= RedisConstants.MinDbIndex && dbIndex <= RedisConstants.MaxDbIndex)
     {
         var result = false;
         try
         {
             if (this.IsConnected())
             {
                 using (var cmd = new RedisCommand(dbIndex, RedisCommandList.Select, RedisCommandType.SendAndReceive, dbIndex.ToBytes()))
                 {
                     result = cmd.ExpectOK(new RedisSocketContext(this, settings), false);
                     if (result)
                     {
                         SetDb(dbIndex);
                     }
                 }
             }
         }
         catch (Exception)
         { }
         return(result);
     }
     return(true);
 }
コード例 #3
0
 protected override IRedisConnection NewConnection(RedisConnectionSettings settings)
 {
     return(new RedisDbConnection(Name, RedisRole.Any, settings,
                                  null,
                                  (connection, socket) =>
     {
         socket.DisposeSocket();
     },
                                  RedisConstants.UninitializedDbIndex, null, true));
 }
コード例 #4
0
        protected RedisCommandExecuter(RedisConnectionSettings settings)
        {
            if (settings == null)
            {
                throw new RedisFatalException(new ArgumentNullException("settings"), RedisErrorCode.MissingParameter);
            }

            m_Settings = settings;

            Action initializer = () => { InitExecuter(); };

            initializer();
        }
コード例 #5
0
        protected RedisResponseReader(RedisConnectionSettings settings)
        {
            m_Settings = settings ?? RedisConnectionSettings.Default;

            var bufferSize = settings.ReadBufferSize;

            bufferSize = (bufferSize <= 0) ? DefaultBufferSize : Math.Min(MaxBufferSize, Math.Max(MinBufferSize, bufferSize));

            m_BufferSize = bufferSize;
            m_Buffer     = new byte[m_BufferSize];

            CaclulateReceiveTimeout();
        }
コード例 #6
0
 internal RedisDbConnection(string name, RedisRole expectedRole, RedisConnectionSettings settings,
                            Action <RedisConnection, RedisSocket> onCreateSocket, Action <RedisConnection, RedisSocket> onReleaseSocket,
                            int dbIndex, RedisSocket socket = null, bool connectImmediately = false)
     : base(name, expectedRole, settings, onCreateSocket, onReleaseSocket, socket, false)
 {
     m_DbIndex = Math.Min(Math.Max(dbIndex, RedisConstants.UninitializedDbIndex), RedisConstants.MaxDbIndex);
     try
     {
         if (connectImmediately)
         {
             ConnectInternal();
         }
     }
     catch (Exception)
     { }
     SelectDB(m_DbIndex);
 }
コード例 #7
0
        protected RedisConnectionProvider(string name, RedisConnectionSettings settings,
                                          Func <int, RedisConnectionLimiter> connectionLimiter = null)
            : base(settings)
        {
            name   = (name ?? String.Empty).Trim();
            m_Name = !name.IsEmpty() ? name :
                     String.Format("{0}, {1}", GetType().Name, Id.ToString());

            if (connectionLimiter == null)
            {
                connectionLimiter = NewConnectionLimiter;
            }

            var maxConnectionCount = Math.Max(RedisConstants.MinConnectionCount, GetMaxConnectionCount());

            m_ConnectionLimiter = connectionLimiter(maxConnectionCount) ??
                                  new RedisConnectionLimiter(maxConnectionCount);
        }
コード例 #8
0
        internal RedisConnection(string name,
                                 RedisRole expectedRole, RedisConnectionSettings settings,
                                 Action <RedisConnection, RedisSocket> onCreateSocket,
                                 Action <RedisConnection, RedisSocket> onReleaseSocket,
                                 RedisSocket socket = null, bool connectImmediately = false)
        {
            if (settings == null)
            {
                throw new RedisFatalException(new ArgumentNullException("settings"));
            }

            if (onReleaseSocket == null)
            {
                throw new RedisFatalException(new ArgumentNullException("onReleaseSocket"));
            }

            RedisConnectionStats.IncrInUseConnections();

            m_ExpectedRole  = expectedRole;
            m_Settings      = settings ?? RedisConnectionSettings.Default;
            m_CreateAction  = onCreateSocket;
            m_ReleaseAction = onReleaseSocket;
            m_Name          = !name.IsEmpty() ? name : (GetType().Name + ", " + m_Id.ToString());

            if ((socket != null) && socket.Connected)
            {
                m_Socket = socket;
                m_State  = (int)RedisConnectionState.Connected;
            }

            try
            {
                if (connectImmediately)
                {
                    ConnectInternal();
                }
            }
            catch (Exception)
            { }
        }
コード例 #9
0
 internal RedisBidirectionalConnection(string name, RedisRole expectedRole, RedisConnectionSettings settings,
                                       Action <RedisConnection, RedisSocket> onCreateSocket, Action <RedisConnection, RedisSocket> onReleaseSocket,
                                       RedisSocket socket = null, bool connectImmediately = false)
     : base(name, expectedRole, settings, onCreateSocket, onReleaseSocket, socket, connectImmediately)
 {
 }
コード例 #10
0
 internal RedisSocketContext(RedisSocket socket, RedisConnectionSettings settings)
 {
     m_Socket   = socket;
     m_Settings = settings ?? RedisConnectionSettings.Default;
 }
コード例 #11
0
 protected virtual IRedisConnection NewConnection(RedisConnectionSettings settings)
 {
     return(null);
 }
コード例 #12
0
 public RedisSingleConnectionProvider(string name, RedisConnectionSettings settings)
     : base(name, settings)
 {
 }