Package io.streamnative.oxia.client.api
Interface AsyncOxiaClient
- All Superinterfaces:
AutoCloseable
Asynchronous client for the Oxia service.
-
Method Summary
Modifier and TypeMethodDescription@NonNull CompletableFuture<Boolean>Unconditionally deletes the record associated with the key if the record exists.@NonNull CompletableFuture<Boolean>delete(String key, Set<DeleteOption> options) Conditionally deletes the record associated with the key if the record exists, and the server's versionId of the record is as specified, at the instant when the delete is applied.@NonNull CompletableFuture<Void>deleteRange(String startKeyInclusive, String endKeyExclusive) Deletes any records with keys within the specified range.@NonNull CompletableFuture<Void>deleteRange(String startKeyInclusive, String endKeyExclusive, Set<DeleteRangeOption> options) Deletes any records with keys within the specified range.@NonNull CompletableFuture<GetResult>Returns the record associated with the specified key.@NonNull CompletableFuture<GetResult>Returns the record associated with the specified key.@NonNull CompletableFuture<List<String>>Lists any existing keys within the specified range.@NonNull CompletableFuture<List<String>>list(String startKeyInclusive, String endKeyExclusive, Set<ListOption> options) Lists any existing keys within the specified range.voidnotifications(@NonNull Consumer<Notification> notificationCallback) Registers a callback to receive Oxiarecord change notifications.@NonNull CompletableFuture<PutResult>Conditionally associates a value with a key if the server's versionId of the record is as specified, at the instant when the put is applied.@NonNull CompletableFuture<PutResult>Conditionally associates a value with a key if the server's versionId of the record is as specified, at the instant when the put is applied.voidrangeScan(@NonNull String startKeyInclusive, @NonNull String endKeyExclusive, @NonNull RangeScanConsumer consumer) Scan any existing records within the specified range of keys.voidrangeScan(@NonNull String startKeyInclusive, @NonNull String endKeyExclusive, @NonNull RangeScanConsumer consumer, @NonNull Set<RangeScanOption> options) Scan any existing records within the specified range of keys.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
put
@NonNull @NonNull CompletableFuture<PutResult> put(String key, byte[] value, Set<PutOption> options) Conditionally associates a value with a key if the server's versionId of the record is as specified, at the instant when the put is applied. The put will not be applied if the server's versionId of the record does not match the expectation set in the call. If you wish the put to succeed only if the key does not already exist on the server, then pass thePutOption.IfRecordDoesNotExistvalue.- Parameters:
key- The key with which the value should be associated.value- The value to associate with the key.options- Setoptionsfor the put.- Returns:
- The result of the put at the specified key. Supplied via a future that returns the
PutResult. The future will complete exceptionally with anUnexpectedVersionIdExceptionif the versionId at the server did not that match supplied in the call.
-
put
Conditionally associates a value with a key if the server's versionId of the record is as specified, at the instant when the put is applied. The put will not be applied if the server's versionId of the record does not match the expectation set in the call.- Parameters:
key- The key with which the value should be associated.value- The value to associate with the key.- Returns:
- The result of the put at the specified key. Supplied via a future that returns the
PutResult.
-
delete
Conditionally deletes the record associated with the key if the record exists, and the server's versionId of the record is as specified, at the instant when the delete is applied. The delete will not be applied if the server's versionId of the record does not match the expectation set in the call.- Parameters:
key- Deletes the record with the specified key.options- Setoptionsfor the delete.- Returns:
- A future that completes when the delete call has returned. The future can return a flag
that will be true if the key was actually present on the server, false otherwise. The
future will complete exceptionally with an
UnexpectedVersionIdExceptionthe versionId at the server did not that match supplied in the call.
-
delete
Unconditionally deletes the record associated with the key if the record exists.- Parameters:
key- Deletes the record with the specified key.- Returns:
- A future that completes when the delete call has returned. The future can return a flag that will be true if the key was actually present on the server, false otherwise.
-
deleteRange
@NonNull @NonNull CompletableFuture<Void> deleteRange(String startKeyInclusive, String endKeyExclusive) Deletes any records with keys within the specified range. For more information on how keys are sorted, check the relevant section in the Oxia documentation.- Parameters:
startKeyInclusive- The key that declares start of the range, and is included from the range.endKeyExclusive- The key that declares the end of the range, and is excluded from the range.- Returns:
- A future that completes when the delete call has returned.
-
deleteRange
@NonNull @NonNull CompletableFuture<Void> deleteRange(String startKeyInclusive, String endKeyExclusive, Set<DeleteRangeOption> options) Deletes any records with keys within the specified range. For more information on how keys are sorted, check the relevant section in the Oxia documentation.- Parameters:
startKeyInclusive- The key that declares start of the range, and is included from the range.endKeyExclusive- The key that declares the end of the range, and is excluded from the range.- Returns:
- A future that completes when the delete call has returned.
-
get
Returns the record associated with the specified key. The returned value includes the value, and other metadata.- Parameters:
key- The key associated with the record to be fetched.- Returns:
- The value associated with the supplied key, or
nullif the key did not exist. Supplied via a future returning aGetResult.
-
get
Returns the record associated with the specified key. The returned value includes the value, and other metadata. -
list
@NonNull @NonNull CompletableFuture<List<String>> list(String startKeyInclusive, String endKeyExclusive) Lists any existing keys within the specified range. For more information on how keys are sorted, check the relevant section in the Oxia documentation.- Parameters:
startKeyInclusive- The key that declares start of the range, and is included from the range.endKeyExclusive- The key that declares the end of the range, and is excluded from the range.- Returns:
- The list of keys that exist within the specified range or an empty list if there were none. Supplied via a future.
-
list
@NonNull @NonNull CompletableFuture<List<String>> list(String startKeyInclusive, String endKeyExclusive, Set<ListOption> options) Lists any existing keys within the specified range. For more information on how keys are sorted, check the relevant section in the Oxia documentation.- Parameters:
startKeyInclusive- The key that declares start of the range, and is included from the range.endKeyExclusive- The key that declares the end of the range, and is excluded from the range.- Returns:
- The list of keys that exist within the specified range or an empty list if there were none. Supplied via a future.
-
rangeScan
void rangeScan(@NonNull @NonNull String startKeyInclusive, @NonNull @NonNull String endKeyExclusive, @NonNull @NonNull RangeScanConsumer consumer) Scan any existing records within the specified range of keys.- Parameters:
startKeyInclusive- The key that declares start of the range, and is included from the range.endKeyExclusive- The key that declares the end of the range, and is excluded from the range.consumer- ARangeScanConsumerthat will be invoked with the records or errors.
-
rangeScan
void rangeScan(@NonNull @NonNull String startKeyInclusive, @NonNull @NonNull String endKeyExclusive, @NonNull @NonNull RangeScanConsumer consumer, @NonNull @NonNull Set<RangeScanOption> options) Scan any existing records within the specified range of keys.- Parameters:
startKeyInclusive- The key that declares start of the range, and is included from the range.endKeyExclusive- The key that declares the end of the range, and is excluded from the range.consumer- ARangeScanConsumerthat will be invoked with the records or errors.options- the range scan options
-
notifications
Registers a callback to receive Oxiarecord change notifications. Multiple callbacks can be registered.- Parameters:
notificationCallback- A callback to receive notifications.
-