The most important factors to consider for making sure your coffee stays fresher for longer are humidity (moisture) and air.
Coffee beans must be stored in an air tight container to keep them fresh. If you intend to keep for a long period, then you can freeze them in the air tight container.
Please read the paragraph in my article for storing coffee beans in a freezer on my article titled How long should coffee beans be stored?
Unlike their roasted cousins, green beans need to breathe when stored. So store them in a paper bag or a jute bag – NOT plastic. And when stored properly, your green beans will stay fresh for 18 months, but no longer than 2 years.
Once they are ground, roasted beans need to be used almost immediately as they lose freshness very quickly.