Modern factory-made ammunition will last a long, long time, given cool, dry storage conditions.
However, when it has been loaded into a pistol, the story changes somewhat.
If the cartridges, or some of the cartridges, in a magazine have been cycled through the action (chambered), there is a possibility that doing so has pushed the cartridges' bullets a little deeper into their cases. If this is repeated sufficiently, the result of firing the cartridges may be excessive pressure and the remote chance of doing serious damage to gun or hand.
Therefore, it is best to occasionally fire-off the magazine-full of cartridges, some of which have been chambered more than once. Doing so should afford you some good practice time, and will assure you that your weapon and its ammunition continues to function well.