I’d like to create a system that allows me to print off the UserID of every player that has ever played the game. However, I’m not sure how to accomplish this.
I’ve considered adding the player’s UserID to a datastore when they join and using ListKeysAsync() to get the info, however this has a large issue: The datastore will run out of storage. Datastores can only store 4 MB of info. Considering that one character is 8 bytes, and the average userID is 10 characters, this would mean only 50,000 players could join before the datastore would run out of storage.
So, my question is:
How can I create a system that stores the UserID of every player that has ever joined the game?
just make a simple DataStore and save each any value to it like timestamps such as tick() if you need to calculate when they first joined or last time they joined, as for the limit of 4 mb its per key not per datastore.
Like others said, you misunderstood the info size limit. It’s for one key in the datastore, so you could just save tables of user IDs. How will you prepare for those tables reaching 4MB (hundreds of thousands of ids if I’m correct) it’s up to you. Maybe something like saving those tables in your own pages (“UserIds1”, “UserIds2”, etc) or something like that.
Create a new key per player, and use listkeysasync.
You will be more likely to hit rate limits with this approach though, but it would be more reliable than attempting to update a key with a table of user IDs which might be accessed on multiple servers unless you want to implement session locking.