After reading through the implementation, I have a few concerns.
-
Save() does not wrap ‘SetAsync’ in a pcall, so any errors as a result of self.dataStore:SetAsync, or self.orderedDataStore:SetAsync will cause a leak in the DataStoreCache for ‘playerLeaving’, and will also break out of the autosave while loop, disabling auto-save for this player for the remainder of their session.
-
It doesn’t seem like self.beforeInitialGet should be a list - instead it should just be a single registered callback, as currently, only the result of the last iterated callback in self.beforeInitialGet list will be assigned to self.value. Similarly, only the result of the last callback in self.beforeSave will be used as the saved value in DataStore:Save(). Since the order of table iteration is undefined, this is problematic.
-
Most of the useful error/critical messages are only logged via ‘warn’. On a large game with many servers these reports will go almost entirely unseen. It would be useful to add an API for the user to provide an error callback that would be invoked in these cases so that the user could log these errors (to the Analytics/Logging platform of choice).
Let me know if something in my comments is a result of misunderstanding. Other than that, nice work on the module!