Personal preference isn’t criticism. ListenToUpdate
is an event and events are listened to via Connect
mainly, its the standard way.
Hello, it seems the new update broke the autosave system because I think its how SessionLockFree was checked before it’s supposed to be assigned properly after handling data session lock by the queue API call and yes this is the latest RBX model of this module im using (v1.60)
-- Auto saving ( "QuickNetwork" module Line 280)
coroutine.wrap(function()
while data.MetaData.Loaded and data.MetaData.SessionLockFree and Settings.AutoSave and data.MetaData.Updated do
HeartbeatWait(Settings.AutoSaveInterval) -- Yield first to prevent data from auto saving immediately
data:Save()
end
end)()
-- Line 115
local function HandleDataSessionLock(dataNetwork, key, backup)
while true do
local data, sessionLocked = Queue.QueueAPICall({dataNetwork, key, _, backup}, Utility.Load)
if not sessionLocked and typeof(data) ~= "table" then
-- Data couldn’t be loaded
break
elseif not sessionLocked then
data.MetaData.SessionLockFree = true --<<<--
return data
end
end
end
A simple fix would be checking it every autosave interval instead of making it a conditioned loop
coroutine.wrap(function()
local metadata = data.MetaData
while true do
HeartbeatWait(Settings.AutoSaveInterval)
if metadata.Loaded and metadata.SessionLockFree and metadata.Updated and Settings.AutoSave then
data:Save()
end
end
end)()
glad i tried to help!
How are you sure that the auto save isn’t working? It’s done after the data has passed through session lock handling.
Wait, sorry i dont think its about session lock handling but because updated is false by default then the autosave wont work
while data.MetaData.Loaded and data.MetaData.SessionLockFree and Settings.AutoSave and data.MetaData.Updated do
HeartbeatWait(Settings.AutoSaveInterval) -- Yield first to prevent data from auto saving immediately
data:Save()
end
-- thought updated will be true when player makes data changed the loop is conditioned already
Yup you are right here, I never noticed the condition of the while loop. I’ll drop a quick fix soon.
The model is still broken it seems, I was trying to migrate from Datastore2 to your module but it’s simply isn’t working currently
What isn’t working? Stating that wouldn’t let me know what is the issue.
I grab the module from the model I even copy paste the code example you given but it doesn’t work (and by doesn’t work I mean that it doesn’t save)
Edit: pretty sure I had it set so it saves on studio server shutdown too btw
The Roblox model was not updated, I’ve updated it now. Also make sure to test in game since the server shuts down on Studio, which in cases, PlayerRemoving
doesn’t fire.
Excellent! This might just be the storing mechanism in my next game!
So I keep getting the error "Cannot save data as it was previously session locked.
This happens when I put the data in a module table in order to have multiple scripts have access to it.
local DEFAULT_DATA_TEMPLATE = {
Strength = 0
}
--Variables
local Players = game.Players
local ServerStorage = game.ServerStorage
local PublicDataStorage = require(ServerStorage.PublicDataStorage)
local QuickNetwork = require(ServerStorage.QuickNetwork)
local DataNetwork = QuickNetwork.GetDataNetwork("DataNetwork", DEFAULT_DATA_TEMPLATE)
--Handle Data Corruption
DataNetwork.DataCorruptionSignal:Connect(function(key, errormessage)
return "LoadBackup"
end)
--Functions
local function PlayerAdded(player)
local data = DataNetwork:LoadDataAsync(player.UserId)
--Fill missing variables
data:Reconcile()
PublicDataStorage.Data[player.UserId] = data
end
local function PlayerLeave(player)
local data = PublicDataStorage.Data[player.UserId]
if data then
data:Clear()
end
end
--Connections
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(PlayerLeave)
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(PlayerAdded)(player)
end
EDIT: I turned on BindToShutdown and SaveOnShutdownInStudio
Players.PlayerAdded:Connect(PlayerAdded)
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(PlayerAdded)(player)
end
Players.PlayerRemoving:Connect(PlayerLeave)
I think this might be the problem.
That did not fix it but thanks anyways
[5/4/2021]: QuickNetwork Update [v1.70]
QuickNetwork now comes with its own updated script which updates the module automatically every 3 seconds, make sure to place that script in ServerScriptService.
-
Fixed the while loop condition where data loaded wouldn’t be auto saved.
-
Fixed a bug where data would error after
Data:Clear
was completed. -
Other small edge case bug fixes.
-
Data:Reconcile
now supports nested table, same withData:SetTable
. -
Data:CombineDataStoresAsync
andData:CombineKeysAsync
now will only update the data if new keys were added. -
Data auto saved now outputs that the data was auto saved, not “saved”. This is just for better logging purposes.
-
New method,
DataNetwork:GetCachedData(key)
, which returns the cached data. -
Removed unnecessary methods like
DataNetwork:Destroy
.
Update your module here:
I updated QuickNetwork yesterday, and it contained many bug fixes. So first, make sure you update the module. The error that you’re seeing comes when you try to save data that was session locked, this is nothing really to worry about.
I experienced none of my data saving. I didn’t change anything in the Script either. The only thing different was I updated the Module.
I’m having the exact same problem. I downloaded the module (version 1.70), installed it how the documentation instructed so, and copy and pasted the example code into a script and ran it in-game. I waited about a minute to rejoin the game, and the cash amount always returned 15 cash. I’m actively looking for where the problem can arise, to no avail. I’ll update you guys if I find a solution.
EDIT: I did notice that it still states it is auto-saving, but throwing “attempt to index nil with BoundToClear” on Utility, Line 85.
Yes, I downloaded after the 1.70 quick update. And I am testing this in-game, since I’m very weary of saving live data in Studio.
What errors are you getting? Can you show the output? I’m seeing no problems on my end, nor any errors.
Most likely you messed up the source: