How to use DataStore2 - Data Store caching and data loss prevention

@LucasTutoriaisSaimo Just realized what you meant by 1.1 backups (I thought you were referring to some module named DataStore1.1, there’s been a few of those that have been sent to me).

Yes, it will be supported once I start to work on DataStore2 again, which will be when my next project needs data storing. I have no ETA on when that will be.

1 Like

Oh yeah, DataStore 1.1 is the new DataStore update in beta. It includes features like:

  1. Backups (that last 30 days)

  2. Metadata, you can set meta data. Whatever you want;

  3. You can list keys in a DataStore;

  4. You can list DATASTORES themselves;

  5. You can list versions (backups);

  6. Also linking UserIds, which Roblox Staff said along the lines of “UserIds will in the future, support automatic data deletion if needed.” For like GPDR and stuff? I don’t remember the name of that action or whatever. But yeah, if a player demands their data be deleted from Data Stores, their plan is to automate this process using UserId key linking.

and a bit more.

I don’t think this is private info, as the functions are all like kind of slightly talked about already in the wiki-a so?

It’s kind of a OrderedBackups solution integrated into actual datastores.
I’ve used it, I got in the beta, and because of that I actually found that it’s not as expensive as making pointers to data in OrderedDataStores; It’s integrated. It basically uses a similar method as the DataStore2 Ordered Backups method. It keeps a bunch of backups, just gets the most recent.

Given that the Ordered Backups method is expensive anyway, these backups are basically not as expensive to integrate, or as hard.

It does seem whatsover, that older datastores, made before the 1.1 days, will NOT support these backups right away. They claim, that these will be added some time after it’s released or in-mid beta. Probably in mid-beta.

Would hope to have it sometime, as I need to have saving for stuff for the server. As for when the server shutdown, there is things such as guilds/servers/other stuff that can only be saved on the server. Would love to see this sometime in the future.

DataStore2 is open to contributions if you would like to make a pull request for it. I don’t implement features I have no use for.

Okay! I will experiment with the module until I get it to work with server datastores.

Also one more question, since some players report losing stats upon teleportation, I wonder if this is a good approach on saving before a teleport.

  1. A Save RemoteEvent that calls :SaveAll() to save all stats
  2. The teleportation script waits for the ConfirmSave to be fired, using :Wait()
  3. A ConfirmSave RemoteEvent gets fired when :AfterSave() has been called. This is where the confusion is. Which of the keys do I associate :AfterSave() with since I got 5 keys under the MasterKey.
  4. The teleportation script then proceeds to the teleport.

However, some players seem to get data loss issues despite this measure and in some cases, the key where :AfterSave() is associated with gets saved while the other 4 doesn’t. The main question is if this is an appropriate approach on saving before teleporting?

Calling SaveAll too often will throttle you. This is a bad idea, leave saving logic entirely to the server.

Any of them–it’s a weird part of the API.

Yes.

1 Like

Kk thanks! I’ll just have to think about it then. Also, despite this approach, some people still report some data loss for other keys that don’t have the AfterSave method. Would putting a wait(), not the method but the built-in function, fix the issue than teleporting the player at an instant after ConfirmSave, (fired by AfterSave), was fired?

I don’t think you should ever use wait(). I don’t understand your question.

1 Like

How would I go about doing a ordered data store for players xp?

I got the datastore working already. I have the value xp combined into “DATA” with all the other players data. Is their a way to make a global leaderboard with that or how would I go about that? If this question has already been answered just point me in the right direction please.

Don’t you have to return the UserData in the SetDataTable()

Read the documentation, your answer is there.

1 Like

You should not use autosaving methods, instead update values as they change. DataStore2 is perfect for not worrying about autosave methods, also it is not efficient enough to autosave with a timer.

1 Like

Great module.
I heard there was some duplication bug, did it get fixed already? Something with session locking.

How bout if you’re dealing with teleportation. That’s where saving issues are the biggest problem.

Zombie Strike just saves everyone’s data before they teleport off, works perfectly fine for us.

2 Likes

so the good way its calling a save() before teleporting to another place?

Yeah I guess so, however it might call that twice since the player ALSO leaves? I would go for it, if I were you. It probably shoudn’t throttle with the same key warning if you’re using the OrderedBackups method.

The Current DataStore2 script, unedited, removes functionality of Soft Shutdown scripts.

I’ve looked into the Code and it sets the player parent to nil, so .AncestryChanged gets fired.
The problem with that is, Guis get destroyed, Player can’t be selected. I had to remove that line.

1 Like

This might be another reason to discourage OrderedBackups.

Ow.