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>()); } }
public Task <object[]> ExecAsync() { RedisObjects cmd = RedisCommand.Exec(); Active = false; _activity.Dispose(); return(_connection.CallAsync(ReadTransaction, cmd.Command, cmd.Arguments)); }
public object[] Exec() { RedisObjects command = RedisCommand.Exec(); Active = false; _activity.Dispose(); return(_connection.Call(ReadTransaction, command.Command, command.Arguments)); }
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(); } }
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(); } }
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); }