How to see all keys for a PrivateTempStore? The Drupal class PrivateTempStore allows for setting and getting key-value pairs within a temporary data store. The class includes the $storage property which then has a getAll() method for retrieving all items in the store. However, this is protected, and so cannot be used by an instantiated PrivateTempStore object.
Is it possible, given a PrivateTempStore object, to retrieve a list of all keys currently used in the store?
No, with the current PrivateTempStore you don't have access to the list of keys. You're welcome to create your own TempStore class if you want different functionality, but I don't see why that is needed here.
The whole point of PrivateTempStore is to stash temporary data for a user, under a given key. If you don't know the key, then you have no knowledge of the type or structure of the data stored there, so in general you won't know how to use it. If your intention is to store a collection of data of a known type (stored in an associative array, for example) so that you can iterate over it later, then store the array itself under a known key, don't store each array element separately. Then you can retrieve the array later from the known key and do a foreach over each element of the array.