- I want to know if it’s possible to create global datastore using profileService
If not then how to create global datastore - I dont know how to if possible
What do you mean “Global Data Store”? Do you mean a global leaderboard?
I’ve never used ProfileService, so I don’t know whether it’s possible with that. If you do want to make a global leaderboard, you can use an OrderedDataStore
.
by global datastore I mean datastore that is not bounded to player, and since Profile-Service have session locking, I wonder if it’ll error (on other servers) if there more than 1 server’s
Are you using roblox’s datastore or some custom datastore modules (Like Datastore2)
ProfileStore:LoadProfileAsync()
accepts 2 arguments: the profileKey
(obviously), and a callback.
The callback function must return either “Repeat”, “ForceLoad”, “Steal”, or “Cancel”.
In your case, if you need to bypass a session lock, “Steal” and “ForceLoad” can be used.
The difference between those two by the way, is:
- “ForceLoad” will keep trying to load the profile in by waiting/prompting a session lock to expire.
- “Steal” just ignores all that and loads the data in regardless of state, and forcibly overrides the session lock with a new one.
That being said, bypassing a session lock should be an exception, not a standard.
It’s your responsibility to Release
Profiles when you are done with them, meaning under normal use you shouldn’t be needing to bypass locks often.
A good valid reason behind a session lock bypass is if a server shuts down and is unable to release Profiles on time (in other words, a non-existent session has a lock on a Profile).
This doesn’t sound like what you’re doing here, so I advise caution.
so that will work if 2 players at time do “something” to write data on global datastore (I want to make a thing to see how much of X existing in whole game)
also what’s better Suphi’s datastore or ProfileService
But basically I can use it for bypassing session-lock just for Global (server) datastore
You can, but again, that’s not what Profiles are meant for. I can’t tell you if this is a sound way either.
If you need to create a shared resource pool, consider DataStore:UpdateAsync()
and MessagingService
.
If I use “ForceLoad” will it be bad? like if there will be idk like 10 servers with players? also idk how to use MessagingService for this
If you’re expecting that much changes,
Then yes. It’s a bad idea.
It’s also a bad idea to use MessagingService in you case.
Consider MemoryStoreService instead, which is faster to access across servers, and has more forgiving limits.
and I dont know how to use MemoryStoreService either.
Also I want to know how it’ll be bad, like lag or something
I will make it like
-
Every 1-10 minutes, server will update amount of things exists in ReplicatedStorage (For client to access them, I can make it through remote function but it gonna be bad I think)
-
When Client gets X it updates its amount on global datastore but not server because it updates automatically every 1-10 minutes. And to change global Profile I need for it to not be locked since cuz of that I will not be able to get it and change its data
Bypassing a session lock is not just slow, it runs the risk of hitting a datastore limit.
Do it often enough, and you might end up having a Profile straightup error, which is the worst thing that can happen to a Profile.
You should probably forget about using Profiles in your case, because this was not what ProfileService is meant for.
Resources to get you started on MemoryStoreService:
Memory store is like datastores but for cross-server?
If so would i be able to make global lobby system (Just asking, if I would be able I dont think I would make it since I still don’t know how these works)
Also I found this: Memory Store Service tutorial
MemoryStores and DataStores function about the same; the key differences are:
- MemoryStores data have a shelf life - they’ll expire after some time (think days).
- MemoryStores are faster to access and write to.
- MemoryStores also have higher limits.
Please read that tutorial, and the page I linked you to earlier. It should explain your problem enough.
- MemoryStores data have a shelf life - they’ll expire after some time (think days).
How to store amount of item existing in game then if it’ll expire after few days, Or I dont understand something
You can have a server be in charge of autosaving the data within the MemoryStore into a DataStore.
so I can save data in datastore and then share it through servers with memory store?
More or less, yes.
The idea here is that whenever that data is required, it is immediately pulled from the MemoryStore that is holding that data.
Same goes for saving changes - you save it into that MemoryStore.
Once in a while, a server will “commit”/save that data into a DataStore.
If a server starts up and finds that that data doesn’t exist in a MemoryStore (meaning it’s expired), it’ll turn to the DataStore instead.
Think of the datastore as a backup for your data, if you will.
Also, MemoryStore data refreshes when it is overwritten, and the maximum shelf life for them is 45 days.
Plenty of time and leeway to do your things, I believe.