Class FileSessionDriver
java.lang.Object
de.craftsblock.craftsnet.api.session.drivers.builtin.FileSessionDriver
- All Implemented Interfaces:
SessionDriver
A file based implementation of
SessionDriver that persists session data to disk.
This implementation stores session data in files located in the STORAGE_LOCATION directory.
Each session is saved as a file with a name based on its session ID appended with the
STORAGE_EXTENSION.
- Since:
- 3.3.5-SNAPSHOT
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes the session file corresponding to the given session ID.booleanCheck if the corresponding session file exists on the hard drive.voidLoads the session data from a file corresponding to the sessions ID.voidSaves the session data to a file corresponding to the sessions ID.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.craftsblock.craftsnet.api.session.drivers.SessionDriver
migrate
-
Field Details
-
STORAGE_LOCATION
The default directory where session files are stored.- See Also:
-
STORAGE_EXTENSION
The file extension used for session files.- See Also:
-
-
Constructor Details
-
FileSessionDriver
public FileSessionDriver()
-
-
Method Details
-
exists
Check if the corresponding session file exists on the hard drive.- Specified by:
existsin interfaceSessionDriver- Parameters:
session- TheSessioninstance to be populated with data.sessionID- The unique identifier of the session.- Returns:
- Returns
trueif the session exists in the underlying storage,falseotherwise. - Since:
- 3.4.0-SNAPSHOT
-
load
Loads the session data from a file corresponding to the sessions ID.- Specified by:
loadin interfaceSessionDriver- Parameters:
session- The session instance to populate with stored data.sessionID- The unique identifier of the session (the session's own ID is used to determine the file).- Throws:
RuntimeException- If an I/O error occurs or deserialization fails.
-
save
Saves the session data to a file corresponding to the sessions ID.- Specified by:
savein interfaceSessionDriver- Parameters:
session- The session instance containing data to be saved.sessionID- The unique identifier of the session (the session's own ID is used to determine the file).- Throws:
IOException- If an error occurs during the file write operation.
-
destroy
Deletes the session file corresponding to the given session ID.- Specified by:
destroyin interfaceSessionDriver- Parameters:
session- The session instance (not used directly in deletion).sessionID- The unique identifier of the session whose file should be deleted.
-