How is the connection handled inside the DataStore object?

This is my guess as to how DataStore works. When you obtain a data store like this, DataStoreService:GetDataStore(“Stats”, scope) and each GetAsync() request is an individual connection to the database and disconnects after each request. In this case I won’t have to worry about cleaning up the data store and keep the reference to it indefinitely. Is this how data store works? Basically I don’t ever have to worry about cleaning things up after each database query?

You don’t have to worry about cleaning up the references, I don’t believe it’s implemented in the way you describe either. In general you don’t have to worry about implementation details like these unless the wiki points out that you should be doing something in a specific way with the respective API.

Yeah I just wanted to double check. Because I am planning on keeping the reference to the DataStore I get from GetDataStore(“Stats”, scope) potentially indefinitely. Kept looking to see in wiki if I shouldn’t do that. If I don’t have to worry then I will go ahead and hold reference for it inside an object where I have no clue when that will be garbage collected.

Keeping GetDataStore(“Stats”, scope) in a variable should be fine forever, should have no worry about that.

I don’t think roblox would have direct DB connections at all, based on errors returned sometimes, datastores definitely use Http requests each time, because sometimes errors will show as like Http 429 rate limit, or along those lines.

Thanks for the clear up! That was what I wanted to find out and confirm with more experienced dev.