I have a spring based server which has a request method which when invoked by an user should return one out of number of entries in the database at random. But they should be non repeated for a user in a session (like non repeating questions in a quiz.) Each entry is identified by a unique entry number. (from 1 to n) I have managed to have sessions by having the same HttpContext for a user across requests.
I was thinking of doing something like Java generating non-repeating random numbers by having an array field in the controller which is shuffled during every call of the method and the first array element to be used as the entry number for the entry to be fetched from the db. However, this may have implications if multiple users are connected to the controller at the same time. I was wondering of what is a good way to design this. I can share the code of my controller if required.
Aucun commentaire:
Enregistrer un commentaire