Package net.minestom.server.storage
Interface StorageSystem
- All Known Implementing Classes:
FileStorageSystem
public interface StorageSystem
Represents a way of storing data by key/value.
The location does not have to be a file or folder path. It is the 'identifier' of the data location.
-
Method Summary
Modifier and Type Method Description void
close()
Called when the location is closed, generally during server shutdown.void
delete(java.lang.String key)
Deletes the specified key from the database.boolean
exists(java.lang.String location)
Gets if the location exists.byte[]
get(java.lang.String key)
Gets the data associated to a key.void
open(java.lang.String location, StorageOptions storageOptions)
Called when aStorageLocation
is opened with thisStorageSystem
.void
set(java.lang.String key, byte[] data)
Sets the specified data to the defined key.
-
Method Details
-
exists
boolean exists(@NotNull java.lang.String location)Gets if the location exists.- Parameters:
location
- the location- Returns:
- true if the location exists
-
open
Called when aStorageLocation
is opened with thisStorageSystem
.- Parameters:
location
- the location namestorageOptions
- theStorageOptions
-
get
@Nullable byte[] get(@NotNull java.lang.String key)Gets the data associated to a key.- Parameters:
key
- the key to retrieve- Returns:
- the retrieved data, null if the data doesn't exist
-
set
void set(@NotNull java.lang.String key, byte[] data)Sets the specified data to the defined key.- Parameters:
key
- the key of the datadata
- the data
-
delete
void delete(@NotNull java.lang.String key)Deletes the specified key from the database.- Parameters:
key
- the key to delete
-
close
void close()Called when the location is closed, generally during server shutdown.
-