public RedisConnector(string host, int port, int concurrency, int bufferSize) { _concurrency = concurrency; _bufferSize = bufferSize; _endpoint = new DnsEndPoint(host, port); _encoding = new RedisEncoding(); _transferPool = new Lazy <SocketAsyncPool>(SocketAsyncPoolFactory); _readQueue = new ConcurrentQueue <IRedisAsyncCommandToken>(); _writeQueue = new ConcurrentQueue <IRedisAsyncCommandToken>(); _readLock = new object(); _writeLock = new object(); _writer = new RedisWriter(_encoding); _connectArgs = new SocketAsyncEventArgs { RemoteEndPoint = _endpoint }; _connectArgs.Completed += OnSocketCompleted; }
public MockConnector(string host, int port, params byte[][] mockResponses) { _host = host; _port = port; _encoding = new RedisEncoding(); _written = new MemoryStream(); _responses = new MemoryStream(); _writer = new RedisWriter(_encoding); _reader = new RedisReader(_encoding, _responses); _messages = new ConcurrentQueue <Tuple <long, int> >(); _pipeline = new RedisPipeline(_written, _encoding, _reader); for (int i = 0; i < mockResponses.Length; i++) { _responses.Write(mockResponses[i], 0, mockResponses[i].Length); } _responses.Position = 0; }