This has been the subject of considerable debate.
By the letter of the rules, the ring provides the benefits of 8 hours of sleep in two hours. This is not trumped by "If the character does not need to sleep...", because the character does still need to sleep. They just get all the benefits that sleep provides in less time than they would without the ring.
[Edit] I'd like to add, with a tip of the hat to Caliban, IMHO. [/Edit]
However, spellcasters all have a maximum number of spells that they can cast in a day. This limits the abuse that can be accomplished with a Ring of Sustenance.
It does open more questions, though... how long is a day? When can a caster learn more spells? Is it fixed at the same time each day? etc.
[Edit]
IMC, spellcasters with RoS's aren't allowed to exceed twice their daily spell limits for any one-day period of time. E.g., go a day without casting any spells, cast all their spells at 1:00, sleep 2 hours, prepare all their spells again, cast them all at 5:00... and now they can't cast any more spells until after 1:00 the next day. This way, you can always mark off a timeline where their spells didn't exceed daily limits, even if they bunch around the border between days. And, yes, it does get messy sometimes.
[/Edit]
-AK