I did it several years ago on AA (very cheap J class sale). Arrived from MIA about 0530, took the detour to flight connections, cleared security, and headed to the gate for my 0730 departure. Elapsed time: roughly 10 minutes.
The LIM security people were unfazed and had a good laugh (crazy American, flying from MIA and heading right back on the next flight!).
The gate agents, on the other hand, were completely flustered when I asked them to check me in and print my business class boarding pass. After talking to practically everyone employed by AA in Lima, the station manager was finally satisfied that I wasn't a security risk and printed my BP and wished me a nice flight. Just like in most international airports outside the USA, a turnaournd without entering the country is possible.
Nowadays, with online checkin possible for international flights, it should be a snap.