Class CachedStorageProvider<K,V>
java.lang.Object
dev.crafty.core.storage.providers.CachedStorageProvider<K,V>
- All Implemented Interfaces:
StorageProvider<K,V>
-
Constructor Summary
ConstructorsConstructorDescriptionCachedStorageProvider(StorageProvider<K, V> delegate) CachedStorageProvider(StorageProvider<K, V> delegate, com.github.benmanes.caffeine.cache.Caffeine<Object, Object> cacheBuilder, com.github.benmanes.caffeine.cache.Caffeine<Object, Object> collectionCacheBuilder) -
Method Summary
Modifier and TypeMethodDescriptionclose()Closes the storage provider and releases any resources.Deletes an object from the storage.Checks if an object exists in the storage.Retrieves an object from the storage.getAll()Retrieves all objects from the storage.Initializes the storage provider.Saves an object to the storage.
-
Constructor Details
-
CachedStorageProvider
-
CachedStorageProvider
-
-
Method Details
-
save
Description copied from interface:StorageProviderSaves an object to the storage.- Specified by:
savein interfaceStorageProvider<K,V> - Parameters:
key- The key to identify the objectvalue- The object to save- Returns:
- A CompletableFuture that completes when the operation is done
-
get
Description copied from interface:StorageProviderRetrieves an object from the storage.- Specified by:
getin interfaceStorageProvider<K,V> - Parameters:
key- The key of the object to retrieve- Returns:
- A CompletableFuture that completes with the retrieved object, or empty if not found
-
getAll
Description copied from interface:StorageProviderRetrieves all objects from the storage.- Specified by:
getAllin interfaceStorageProvider<K,V> - Returns:
- A CompletableFuture that completes with a collection of all objects
-
delete
Description copied from interface:StorageProviderDeletes an object from the storage.- Specified by:
deletein interfaceStorageProvider<K,V> - Parameters:
key- The key of the object to delete- Returns:
- A CompletableFuture that completes when the operation is done
-
exists
Description copied from interface:StorageProviderChecks if an object exists in the storage.- Specified by:
existsin interfaceStorageProvider<K,V> - Parameters:
key- The key to check- Returns:
- A CompletableFuture that completes with true if the object exists, false otherwise
-
initialize
Description copied from interface:StorageProviderInitializes the storage provider. This method should be called before using the provider.- Specified by:
initializein interfaceStorageProvider<K,V> - Returns:
- A CompletableFuture that completes when initialization is done
-
close
Description copied from interface:StorageProviderCloses the storage provider and releases any resources. This method should be called when the provider is no longer needed.- Specified by:
closein interfaceStorageProvider<K,V> - Returns:
- A CompletableFuture that completes when the provider is closed
-