Getting multiple keys with one datastore call

Hello I am trying to create a clan system in a game, i am storing player owned clans in a datastore and then get them. But i wanted to create a page where you can see all the active clans, the problem is the datastore limits. I can’t just call 50+ getasnycs back to back, so i thought of looking at methods to get them with one call like in ordered datastores, but ordered datastores only accept a single value. I have also thought of combining all the keys and having a single key that stores all the clan data, but i am risking reaching the 4 mb limit.

I looked at documentary but could not find anything helpful. Is there anything i overlooked?

1 Like

You should have one datastore handle storing all of the lookup data (typically IDs) for each guild. You can also provide extra information like name and a logo, if you want that to all appear immediately. Just know that, the larger your data per guild, the less space you’ll have in a single datasatore. Every time somebody creates a guild, have it save to that main datastore.

Then, when a player opens up a guild page in the list, the server can then send a get request for that guild specifically. The server can also cache the results for a certain length of time, that way it doesn’t keep calling get until the data is deemed old and outdated.

1 Like

Thanks for replying. Yes, i already implemented a caching system that automatically removes itself after not being indexed for a certain time. Your solution seems like the one making most sense, even though this means i’ll have to change things, and the potential issue of having a single key that is mutated by multiple servers simultaneously. It seems like the only way, other than using an external database.

I wish roblox implemented a way to get multiple keys with one async call.

1 Like

Well, you can implement a lock system. Roblox is extremely behind in this regard, as they promised that they would be improving the datastore system, but have yet to do so. Until they do, you’ll have to handle that sort of system yourself. External databases are, of course, always an option, if you don’t mind paying for them.

I believe there is a way to call multiple keys at once, but I also believe that it’s still technically multiple calls (one for each). I can’t seem to find it at the moment, but I’ll edit this reply if I find it later. I think it might be limited to DataStore:RemoveAsync() as it takes a tuple of what I assume would be key names. I was trying to find a particular post that I saw about this a while back, but I can’t seem to find it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.