Data Caching 2 - An alternative way to store player data - Fast and Easy

Link to the module:
[MODULE] Data Caching 2 - Creator Store

DataCaching2

Hey guys! I made a pretty solid module that I kinda want to show off here, hope you enjoy :3

What is Data Caching 2?
Data Caching 2 is a module which allows you to temporarily store ANY kind of data to the module. It is to read, set and change the data.

Now, you might have noticed that the module is called Data Caching 2.
This is because it is heavily, HEAVILY inspired of Kampfkarren’s Data Store 2

How is this related to ‘Data Store 2’
NOTE: I do not have anything to do with DataStore2, I simply based this module on it.
DataStore2 is an exceptionally great way to store data to the DataStoreService permanently, but what if you could store it temporarily? Thats where this module comes in:

Why you should use DataCaching2

Use: Data Caching - Most people do it with Instances such as “NumberValues”. This, however, is far from efficient and can cause lag in extreme cases. DataCaching2 utilizes tables instead.

Feature-rich: DataCaching2 is a light module. Even so, it posseses many useful features, including callbacks and quick value increasing.

Adapability: DataCaching2’s functions and methods are called basically the same as those from DataStore2, allowing for quick adaptability. Even if you’ve never even heard of DataStore2, the syntax is easy to learn.

Code Snippets: The lack of code snippets torments many DataStore2 users. I deliberately made sure that Roblox Studios would understand the code in a way that allows it to add code Snippets.

What to keep in mind?

Not perfected

I didn’t experience any issues whilst testing, but I’m sure this module doesn’t even compare to DataStore2 in terms of quality. Expect errors.

Minimal error handling (specifically: pcalls).

The whole point of this module is to speed up caching, so I purposely avoided adding somewhat-unefficient pcalls. Therefore these temporary caches should not contain permanent user data, as it might be lost.

Example usage:

-- Server script in ServerScriptService --
local DC2 = require(game:GetService("ServerScriptService").Modules.DataCaching2)
local DS2 = require(game:GetService("ServerScriptService").Modules.DataStore2)
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
    local PlayedBefore = DS2("PlayedBefore", plr):Get(false)
    if PlayedBefore == false then
        local FirstPlaytime = DC2("FirstPlaytime", plr)
        FirstPlaytime:SetCallback(function()
             print(FirstPlaytime:Get(0))
         end)
        repeat task.wait(1)
            FirstPlaytime:Increment(1)
        until not plr
    -- do something with this data --
    end
end)

If you like this module, consider following me on roblox :slight_smile:

1 Like