Sometimes, in Southern California, one gets used to the rhythms of the bugs there, there are moths in bags of rice, or beans, or any sort of legume, or grain.
So then, the grocery errand changes.
Purchase rice, beans, rye, in bulk or in bags.
Purchase ceramic, glass, or whatever jars or containers at the dollar store.
Bring them home and put them in the freezer.
After a day or so, transfer the chilled rice into, beans, rye, into jars that seal.
This can also affect spices.