Exemplo n.º 1
0
 public static void SetCache(string key, string data, int expire = 0)
 {
     command.Exec(new List <string> {
         "SET", key, data
     }, new List <string>());
     if (expire > 0)
     {
         command.Exec(new List <string> {
             "EXPIRE", key, expire.ToString()
         }, new List <string>());
     }
 }
Exemplo n.º 2
0
        public Task <object[]> ExecAsync()
        {
            RedisObjects cmd = RedisCommand.Exec();

            Active = false;
            _activity.Dispose();
            return(_connection.CallAsync(ReadTransaction, cmd.Command, cmd.Arguments));
        }
Exemplo n.º 3
0
        public object[] Exec()
        {
            RedisObjects command = RedisCommand.Exec();

            Active = false;
            _activity.Dispose();
            return(_connection.Call(ReadTransaction, command.Command, command.Arguments));
        }
Exemplo n.º 4
0
 public void SetCommandWithError()
 {
     using (var connection = new ConnectionMock("set foo 1\r\n3\r\n", "-ERR Get off\r\n"))
     {
         var          f       = new CommandFactory(new NormalCommandExecutor(connection));
         RedisCommand command = f.Set("foo", "3");
         command.Exec();
     }
 }
Exemplo n.º 5
0
 public void SetCommandWithNormalResult()
 {
     using (var connection = new ConnectionMock("SET foo 1_3_", "+OK\r\n"))
     {
         var          f       = new CommandFactory(new NormalCommandExecutor(connection));
         RedisCommand command = f.Set("foo", "3");
         command.Exec();
         connection.Verify();
     }
 }
Exemplo n.º 6
0
        object[] ReadTransaction(Stream input)
        {
            if (!_captureResults)
            {
                RedisObjects command = RedisCommand.Exec();
                command.Parser(input);
                return(null);
            }

            RedisReader.ExpectType(input, RedisMessage.MultiBulk);
            long count = RedisReader.ReadInt(input, false);

            if (count == -1)
            {
                return(null);
            }

            object[] output = new object[_parsers.Count];
            for (int i = 0; i < output.Length; i++)
            {
                output[i] = _connection.Read(_parsers.Dequeue());
            }
            return(output);
        }