Rice is easy, mix in some DE powder and a O2 absorber. then seal. Same for beans.
Oatmeal and flour will only last a couple years but the same method as above can be used. yeast is a living organism, so keep it cool dark place. Even then it only lasts a couple years.
It’s the sealing part that I’m wondering about. Some people are talking about using mylar bags inside plastic buckets, which sounds...spendy.