You do need to be in the country for 5 years as a spouse before applying for UK citizenship. And then comes the silly part; the citizenship test! During that 5 years qualifying period, there are strict limits on the amount of time you can be outside the UK. I don't remember the periods/amounts of time that will stop your 5 year wait but, roughly speaking, they look at your time out of the UK and decide "that looks OK, probably holiday" or "that is a long time out, we suspect you may have been living or working outside the UK for that period".
I know as I brought my foreign wife to the UK.
I feel sorry for people who want to bring a foreign wife/fiancee to the UK nowadays as the rules are bloody horrible compared the way they once were.