public RedisConnectionPoolMember(RedisSocket socket, int dbIndex, RedisConnectionSettings settings) { DbIndex = dbIndex; Socket = socket; m_Settings = settings; PooledTime = DateTime.UtcNow; }
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); }
protected override IRedisConnection NewConnection(RedisConnectionSettings settings) { return(new RedisDbConnection(Name, RedisRole.Any, settings, null, (connection, socket) => { socket.DisposeSocket(); }, RedisConstants.UninitializedDbIndex, null, true)); }
protected RedisCommandExecuter(RedisConnectionSettings settings) { if (settings == null) { throw new RedisFatalException(new ArgumentNullException("settings"), RedisErrorCode.MissingParameter); } m_Settings = settings; Action initializer = () => { InitExecuter(); }; initializer(); }
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(); }
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); }
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); }
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) { } }
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) { }
internal RedisSocketContext(RedisSocket socket, RedisConnectionSettings settings) { m_Socket = socket; m_Settings = settings ?? RedisConnectionSettings.Default; }
protected virtual IRedisConnection NewConnection(RedisConnectionSettings settings) { return(null); }
public RedisSingleConnectionProvider(string name, RedisConnectionSettings settings) : base(name, settings) { }