示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 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);
        }
示例#6
0
 public void SetAsync(byte[] bytes, Task <bool> task)
 {
     _currentTaskBuffer.Append(task);
     _sender.WriteAsync(bytes);
     //ReleaseSend();
 }