Class MySqlDriver<K,D>
- Since:
- 0.1.2
-
Nested Class Summary
-
Field Summary
Fields inherited from class co.crystaldev.alpinecore.framework.storage.driver.AlpineDriver
plugin
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
D> @NotNull MySqlDriver.Builder<K, D> builder()
Helper method to return a new builder instance.boolean
deleteEntry
(K key) Delete data under a given key.@NotNull Collection<D>
Retrieve all stored values in the data storage.@NotNull Collection<D>
getAllEntries
(@Nullable Consumer<Exception> exceptionConsumer) Retrieve all stored values in the data storage.boolean
Check if a key has any saved data.boolean
persistEntries
(@NotNull Map<K, D> entries) Save multiple data entries under their respective keys.boolean
persistEntry
(K key, D data) Save data under a given key.retrieveEntry
(K key) Retrieve data for a given key.void
shutdown()
Shut down the data storage system.
-
Method Details
-
persistEntry
Description copied from class:AlpineDriver
Save data under a given key.Any exceptions generated by this method are swallowed.
- Specified by:
persistEntry
in classAlpineDriver<K,
D> - Parameters:
key
- The keydata
- The data to save- Returns:
- Whether the operation was successful
-
persistEntries
Description copied from class:AlpineDriver
Save multiple data entries under their respective keys.This method allows you to save multiple data entries at once by providing a map of key-value pairs. It iterates through the map and calls the
AlpineDriver.persistEntry(Object, Object)
method for each entry. Any exceptions generated during the saving process are swallowed for individual entries.- Overrides:
persistEntries
in classAlpineDriver<K,
D> - Parameters:
entries
- A map containing key-value pairs to be saved.
-
deleteEntry
Description copied from class:AlpineDriver
Delete data under a given key.- Specified by:
deleteEntry
in classAlpineDriver<K,
D> - Parameters:
key
- The key- Returns:
- Whether the operation was successful
-
hasEntry
Description copied from class:AlpineDriver
Check if a key has any saved data.Any exceptions generated by this method are swallowed.
- Specified by:
hasEntry
in classAlpineDriver<K,
D> - Parameters:
key
- The key- Returns:
- Whether there is an entry for they key
-
retrieveEntry
Description copied from class:AlpineDriver
Retrieve data for a given key.Due to limitations of the caching layer, this method must never return null.
Always use
AlpineDriver.hasEntry(Object)
before attempting to retrieve an entry.Any exceptions generated by this method are NOT swallowed.
- Specified by:
retrieveEntry
in classAlpineDriver<K,
D> - Parameters:
key
- The key- Returns:
- The data associated with the key
- Throws:
Exception
-
getAllEntries
Description copied from class:AlpineDriver
Retrieve all stored values in the data storage.This method retrieves all values stored in the data storage and returns them as a collection. It is a blocking task, and it may take some time to complete depending on the size of the data storage. If the data storage is empty, an empty collection is returned.
Any exceptions generated by this method are NOT swallowed.
- Specified by:
getAllEntries
in classAlpineDriver<K,
D> - Returns:
- A collection containing all stored values.
- Throws:
Exception
- If an exception occurs while retrieving the values.
-
getAllEntries
@NotNull public @NotNull Collection<D> getAllEntries(@Nullable @Nullable Consumer<Exception> exceptionConsumer) Description copied from class:AlpineDriver
Retrieve all stored values in the data storage.This method retrieves all values stored in the data storage and returns them as a collection. It is a blocking task, and it may take some time to complete depending on the size of the data storage. If the data storage is empty, an empty collection is returned.
- Specified by:
getAllEntries
in classAlpineDriver<K,
D> - Parameters:
exceptionConsumer
- A function for handling errors.- Returns:
- A collection containing all stored values.
-
shutdown
public void shutdown()Description copied from class:AlpineDriver
Shut down the data storage system.This method gracefully shuts down the data storage system, ensuring that all pending write operations are completed and any resources held by the storage system are properly released.
- Overrides:
shutdown
in classAlpineDriver<K,
D>
-
builder
Helper method to return a new builder instance.- Returns:
- New builder for this class
- See Also:
-