How long a cake will stay in fridge will depend on its ingredients, what’s in it and if it is covered to abstain from drying out or getting mold. Cakes can stay in a refrigerator for 2–5 days and that should not be an issue. Most sorts of cakes are safe to eat for as long as four days in refrigerator if they were protected.
When storing your cake in refrigerator, It would be good to put it in plastic holders or wrap them with a foil paper. One thing you should know however is that cake can’t be put away in the fridge for many days. It is not like meat or vegetables.
If you keep a cake in Fridge with buttercream or ganache garnish in it, it will be good for 3-4 days. Cakes with custard, cream, cheese etc. will last for 1-2 days.
In the event that your cake has cream cheese frosting, then refrigerate for 1-2 days at most. Allow it to cool to room temperature before you serve.
Fruit cakes preserved in marzipan and icing will stay fresh longer. You should not refrigerate cakes with sugar paste, fondant or food coloring.