It is not permissible to store anything that people are in need of, as this is called monopoly. The Prophet (peace be upon him) said,
“None but a sinner monopolizes (commodities).”
and Ibn Majah)
This practice can cause harm to Muslims. However, if the commodity is not so much needed by people, it becomes permissible to store it until the time of need comes. Then it is made available for people to save them from trouble and for need. Consequently, the period of storage, whether long or short, depends on people's need of the stored commodity.