Class PostgresStorageProvider<K,V>

java.lang.Object
dev.crafty.core.storage.AbstractStorageProvider<K,V>
dev.crafty.core.storage.providers.PostgresStorageProvider<K,V>
All Implemented Interfaces:
StorageProvider<K,V>

public class PostgresStorageProvider<K,V> extends AbstractStorageProvider<K,V>
  • Constructor Details

    • PostgresStorageProvider

      public PostgresStorageProvider(Class<V> valueType, String tableName, String connectionUrl, String username, String password)
  • Method Details

    • initialize

      public CompletableFuture<Void> initialize()
      Description copied from interface: StorageProvider
      Initializes the storage provider. This method should be called before using the provider.
      Specified by:
      initialize in interface StorageProvider<K,V>
      Overrides:
      initialize in class AbstractStorageProvider<K,V>
      Returns:
      A CompletableFuture that completes when initialization is done
    • save

      public CompletableFuture<Void> save(K key, V value)
      Description copied from interface: StorageProvider
      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

      public CompletableFuture<Optional<V>> get(K key)
      Description copied from interface: StorageProvider
      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

      public CompletableFuture<Collection<V>> getAll()
      Description copied from interface: StorageProvider
      Retrieves all objects from the storage.
      Returns:
      A CompletableFuture that completes with a collection of all objects
    • delete

      public CompletableFuture<Void> delete(K key)
      Description copied from interface: StorageProvider
      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
    • close

      public CompletableFuture<Void> close()
      Description copied from interface: StorageProvider
      Closes the storage provider and releases any resources. This method should be called when the provider is no longer needed.
      Specified by:
      close in interface StorageProvider<K,V>
      Overrides:
      close in class AbstractStorageProvider<K,V>
      Returns:
      A CompletableFuture that completes when the provider is closed