public Task <bool> AuthAsync(string password) { var bytes = Encoding.UTF8.GetBytes($"AUTH {password}\r\n"); var task = CreateTask(null, TaskCreationOptions.RunContinuationsAsynchronously); LockSend(); _currentTaskBuffer.Append(task); _sender.WriteAsync(bytes); ReleaseSend(); return(task); }
public override Task <bool> SetAsync(string key, string value) { var bytes = Encoding.UTF8.GetBytes($"*3\r\n$3\r\nSET\r\n${key.Length}\r\n{key}\r\n${value.Length}\r\n{value}\r\n"); var taskSource = CreateTask(null, TaskCreationOptions.RunContinuationsAsynchronously); LockSend(); _currentTaskBuffer.Append(taskSource); _sender.WriteAsync(bytes); ReleaseSend(); return(taskSource); }
private void GetTaskSpan() { if (_currentTaskBuffer.Head.Next != null) { _taskBuffer.Append(_currentTaskBuffer); _currentTaskBuffer = new SingleLinks <Task <bool> >(); } }
private void GetTaskSpan() { LockSend(); if (_currentTaskBuffer.Count != 0) { _taskBuffer.Append(_currentTaskBuffer); _currentTaskBuffer = new SingleLinks <Task <bool> >(); } ReleaseSend(); }
public override Task <bool> SetAsync(string key, string value) { var bytes = Encoding.UTF8.GetBytes($"SET {key} {value}\r\n"); var taskSource = CreateTask(); LockSend(); sendCount += 1; _currentTaskBuffer.Append(taskSource); _sender.WriteAsync(bytes); ReleaseSend(); return(taskSource); }
public void SetAsync(byte[] bytes, Task <bool> task) { _currentTaskBuffer.Append(task); _sender.WriteAsync(bytes); //ReleaseSend(); }