Interface UserPersistentStorage
- All Known Implementing Classes:
SQLUserPersistentStorage
public interface UserPersistentStorage
Interface for user persistent storage
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the database and the database connectionvoid
deleteUser
(LifestealerUser user) Deletes a user from the database.Returns a prettified name of the databasevoid
init()
Initializes the database (for example, connecting and creating necessary tables)Loads a user from the database.void
saveAllUsers
(List<LifestealerUser> users) void
saveUser
(LifestealerUser user) Saves a user to the database.
-
Method Details
-
getDatabaseName
String getDatabaseName()Returns a prettified name of the database- Returns:
- the database name
-
init
Initializes the database (for example, connecting and creating necessary tables)- Throws:
Exception
- if an error occurs
-
close
Closes the database and the database connection- Throws:
Exception
- if an error occurs
-
loadUser
Loads a user from the database. This operation is blocking. UseLifestealerUserManager.getOrLoadUser(UUID)
if you want to get the user if it is already loaded or load it from the database if it is not loaded.- Parameters:
uuid
- the uuid of the user to load- Returns:
- the loaded user or null if the user is not saved in the database
- Throws:
Exception
- if an error occurs while loading the user
-
loadAllUsers
- Throws:
Exception
-
saveUser
Saves a user to the database. This operation is blocking. UseLifestealerUserManager.saveUserAsync(LifestealerUser)
if you want to save the user asynchronously.- Parameters:
user
- the user to save- Throws:
Exception
- if an error occurs while saving the user
-
saveAllUsers
- Throws:
Exception
-
deleteUser
Deletes a user from the database. This is used to delete a user from the database if they have no difference from the default values when saving throughLifestealerUserManager
- Parameters:
user
- the user to delete- Throws:
Exception
- if an error occurs while deleting the user
-