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:StorageProvider
Saves an object to the storage.- Specified by:
save
in 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:StorageProvider
Retrieves an object from the storage.- Specified by:
get
in 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:StorageProvider
Retrieves all objects from the storage.- Specified by:
getAll
in interfaceStorageProvider<K,
V> - Returns:
- A CompletableFuture that completes with a collection of all objects
-
delete
Description copied from interface:StorageProvider
Deletes an object from the storage.- Specified by:
delete
in 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:StorageProvider
Checks if an object exists in the storage.- Specified by:
exists
in 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:StorageProvider
Initializes the storage provider. This method should be called before using the provider.- Specified by:
initialize
in interfaceStorageProvider<K,
V> - Returns:
- A CompletableFuture that completes when initialization is done
-
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 interfaceStorageProvider<K,
V> - Returns:
- A CompletableFuture that completes when the provider is closed
-