Best method for storing data

Hello everyone,
I have made a module for my game that does save file related stuff.

It loads the players data when they join [the data is a table with all their stuff in it], then there is operations in the module [Get, Set, and Increment] for handling that data when the player is in the game.
(For example, if I had a table like this:

{ test = { a = 5 } }

and I used :Get(UserId, 'Test/a'), it would return 5.

So all of that works fine, the real problem is how to store it during the session.
Currently, I have tried these methods:

StringValues with JSON

Everytime a player joins, a stringvalue is created under the module. Whenever a GET is called, it decodes the JSON value inside the stringvalue and then returns that.
This worked fine, however it was quite slow; and stringvalues have a max of 200k characters.

Folders with Value Instances

Instead of JSON, this utilizes a different module and converts the player’s save table into a Folder with values inside of it. This also worked ok- it was pretty fast; but it got pretty laggy when overwriting stuff (setting tables inside the file would have to recreate that entire folder. keep in mind im doing many operations per second here.)

Storing Tables Inside the Module

This would have been a perfect solution (storing the save files in the module as Module.Files), as it is fast and not laggy. HOWEVER, usually the file just disappears out of the module when I use it from a different script or Network.

Can someone please help me find a good solution? Also, I have to keep this style of storing/editing files. My entire game is already built around it.

Thanks,
doctorpepper126 :slight_smile:

what are your goals with this?

the best way to store it in your game is, of course, in a table if you want to interact with it
and in a buffer if you want to save it.

it’s better, safer and simpler to use pre-made libraries that have been solving such issues for years. to name a few, the old time classic, ProfileService, then the Promise-type implementation of it called DataKeep. Alternative to ProfileService would be either Lapis or DocumentService.
you can find more information about all of them using the hyperlinks.

And again, it all depends on your goal.

  • Performance?
    buffers with --!native flag. You can technically modify most of the upper
    mentioned libraries to do that.
  • Reliability?
    Any of the mentioned libraries. They all have their own pros and cons.
  • Readability?
    Who needs to read this other than you? If you’re working on a team, decide
    on principles and rules of your code, then work together with it.