Keeping in touch with college professors advice?

I developed a few close student-professor relationships as an undergrad, that I really want me to write letters of rec for me for graduate school. I am over 8 hours from my campus, so seeing them during this upcoming semester’s office hours isn’t an option. I also plan to apply in a year or two for a family choice. It might also take me a couple tries to get into this program that I’m applying to. How can I keep in touch with professors in order for them to remember me?