Some developers keep their job for too little, as if they have commitment issues.
Some keep their job for too long, as if they're afraid to leave their safety zone.
What is the optimal number of years a developer should keep a job?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.
There is no real set minimum or maximum time frame that is optimal. It is different for every person, and every job.
My advice, however, is to stay for as long as benefits you as well as your employer. That is to say, that you are in an environment that allows you to continue to develop your craft and learn new languages/paradigms/technologies.