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


#184

Are you going to switch from os.time() to incremental version numbers soon?


#185

Yes.


#186

Incremental key saving has been pushed to the prod script. Tell me if you have any issues.


#187

For anyone dealing with GDPR, I believe this script I whipped up will work. Put this in your command bar then use clear(userId, name) (also in the command bar) to clear someone’s data.

If you use combined data stores, the name will be your master key. Otherwise, it’s your normal name.

local DataStoreService = game:GetService("DataStoreService")

function clear(userId, name)
	local orderedDataStore = DataStoreService:GetOrderedDataStore(name .. "/" .. userId)
	local dataStore = DataStoreService:GetDataStore(name .. "/" .. userId)

	while true do
		local pages = orderedDataStore:GetSortedAsync(false, 100)
		local data = pages:GetCurrentPage()
		for _, pair in pairs(data) do
			print(("key: %d"):format(pair.key))
			dataStore:RemoveAsync(pair.key)
			orderedDataStore:RemoveAsync(pair.key)
		end
		if pages.IsFinished then
			print(("finished (%d: %s)"):format(userId, name))
			return
		end
	end
end