I need to create a temporary file on the file system. I have over
5000 users.
What's the best method to ensure uniqueness?
Depends on the application. You might get away with just starting at #1.
You might get away with having an array of booleans (or a table of booleans
in a database), one starting at #1 and so on. Or you might have to
generate a random number and keep retrying till you hi one that's not in
use.
It all depends on how often you need to do this, what the load is (are your
5k users concurrent?), and so on.
This can be very fast if you plan it right. If you go the random number
route, use a hige range (ie, a number between 1 and 1,000,000) so that
conflicts are very unlikely.
--
gabriel