Stay forever...if you're a UK resident and living in Spain, if you're getting paid "offshore" then you don't need to worry.
If on the other hand you're working for a Spanish company and getting paid by them, then I don't know, except it could get more complicated.