Well, that really depends on what you want to do and see in Lima! But generally, I'd say spending 3-4 days there should give you enough time to explore the city and get a taste of its culture and cuisine.