Interface StorageProvider<T,K>

Type Parameters:
T - The type of object to store
K - The type of key used to identify objects
All Known Implementing Classes:
AbstractStorageProvider, CachedStorageProvider, MongoDbStorageProvider, MySqlStorageProvider, PostgresStorageProvider, YamlStorageProvider

public interface StorageProvider<T,K>
Base interface for all storage providers. Provides methods for CRUD operations on data objects.
Since:
1.0.0
  • Method Details

    • save

      CompletableFuture<Void> save(K key, T value)
      Saves an object to the storage.
      Parameters:
      key - The key to identify the object
      value - The object to save
      Returns:
      A CompletableFuture that completes when the operation is done
    • get

      Retrieves an object from the storage.
      Parameters:
      key - The key of the object to retrieve
      Returns:
      A CompletableFuture that completes with the retrieved object, or empty if not found
    • getAll

      Retrieves all objects from the storage.
      Returns:
      A CompletableFuture that completes with a collection of all objects
    • delete

      CompletableFuture<Void> delete(K key)
      Deletes an object from the storage.
      Parameters:
      key - The key of the object to delete
      Returns:
      A CompletableFuture that completes when the operation is done
    • exists

      CompletableFuture<Boolean> exists(K key)
      Checks if an object exists in the storage.
      Parameters:
      key - The key to check
      Returns:
      A CompletableFuture that completes with true if the object exists, false otherwise
    • initialize

      CompletableFuture<Void> initialize()
      Initializes the storage provider. This method should be called before using the provider.
      Returns:
      A CompletableFuture that completes when initialization is done
    • close

      Closes the storage provider and releases any resources. This method should be called when the provider is no longer needed.
      Returns:
      A CompletableFuture that completes when the provider is closed