Class AbstractStorageProvider<K,V>

java.lang.Object
dev.crafty.core.storage.AbstractStorageProvider<K,V>
All Implemented Interfaces:
StorageProvider<K,V>
Direct Known Subclasses:
MongoDbStorageProvider, MySqlStorageProvider, PostgresStorageProvider, YamlStorageProvider

public abstract class AbstractStorageProvider<K,V> extends Object implements StorageProvider<K,V>
  • Field Details

    • valueType

      protected final Class<V> valueType
  • Constructor Details

    • AbstractStorageProvider

      protected AbstractStorageProvider(Class<V> valueType)
  • Method Details

    • serializeKey

      protected String serializeKey(K key)
    • exists

      public CompletableFuture<Boolean> exists(K key)
      Description copied from interface: StorageProvider
      Checks if an object exists in the storage.
      Specified by:
      exists in interface StorageProvider<K,V>
      Parameters:
      key - The key to check
      Returns:
      A CompletableFuture that completes with true if the object exists, false otherwise
    • 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>
      Returns:
      A CompletableFuture that completes when initialization 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>
      Returns:
      A CompletableFuture that completes when the provider is closed