Best way to store data in plugins using plugin:SetSetting

So recently I’ve been making a plugin that need store data that persists across sessions. The plugins context is not necessary here though (Maybe it is?)

My question is whether should I implement a “main” data table and read and write on it, and save it entirely. Or, I should directly use SetSetting with no strings attached, just save the data.

Here is an example of both implementations:
Here is the main data table version:

--Get the main data table
local cache = plugin:GetSetting(MainKey)

--Set some data in cache...
cache[index] = value

--Save the cache
plugin:SetSetting(MainKey, cache)

And here is the direct version:

--Just save the data
plugin:SetSetting(index, value)

Now, the reason I am asking this is that I read that race conditions can corrupt data in settings files, and also some edge cases (though i am not sure what these edge cases are). So I thought the first way would be better and avoid these problems, though this might impact performance and also is it necessary at all, will it even fix anything in any way? Maybe there is a better way I don’t know about or the the first implementation doesn’t fix anything and is just a waste of resources… I don’t know!

You can share how you store your data in your plugins too, I am new to this so I am not experienced lol.

Help is appreciated!