Hello, I would like to know how I can make a good Datastore that saves player’s data efficiently, and you can access and increment easily.
Hi, When doing something you have never done before, always look at how other people implemented it. Datastores are the idea that we can store data persistently on either players or some kind of other data like dates and times.
Let’s start by asking the question: “What are we storing”? We are storing data. Most of the time Strings, or numbers. “How can we make that more efficient?”. Well we can compress the data with lossless
compression algorithms these are things like, Base64, Lz4, Base10, Base16.
Any kind of data compression algorithm that is lossless
which means when it is compressed, it does not loose any of the data that was encoded. For example, When using the internet; Images are first encoded into Base64 then are decoded in your browser. The idea is the image is intact, it did not loose any data, hereby Base64 is lossless
.
How does this apply to data efficiency? Roblox Datastores can only hold up to a certain character limit, and when data is compressed it reads faster. This is why it is important to compress data before it is stored, this applies to strings
, numbers
and any kind of JSON.
Example: If we were going to store a dictionary to a datastore, this would obviously require alot of compression. Certain algorithms have their downsides and upsides. For example: Lz4 is the fastest algorithm (Afaik). We would encode each word and phrase in some kind of algorithm and then store it.
The following video goes into more depth and implementation on datastore efficiency: