"总是" means always and "永远" means forever.
They can be both used as adverbs of degree, for example:
"他总是忘记随手关灯" - "He always forgets to turn off the lights conveniently.
"有些人可能永远保持单身" - "Some people may stay single forever.
"永远" has a higher degree than "总是".
And, "永远" can be also used as a noun: "我希望能陪伴你直到永远" - "I wish to keep your company till forever."