Aerospike Client for Kotlin wraps the Java client callback-based asynchronous methods and provides an idiomatic Kotlin API using coroutines and Flow
.
The AerospikeAsyncClient
takes the Java AerospikeClient
as a constructor parameter and exposes it via the asJava()
method.
Make sure to set the ClientPolicy.eventLoops when creating the Java client.
dependencies {
implementation("io.github.reugn:aerospike-client-kotlin:<version>")
}
./gradlew build
@Test
fun `Perform operations on a key`(): Unit = runBlocking {
val record = asyncClient.operate(
null, keys[0],
Operation.put(Bin(intBin, 100)),
Operation.get()
)
assertEquals(100, record?.getInt(intBin))
}
@Test
fun `Query all`(): Unit = runBlocking {
val queryStatement = QueryStatement(namespace, setName = set)
val flow = asyncClient.query(null, queryStatement)
val recordsNumber = flow.toList().size
assertEquals(keysSize, recordsNumber)
}
Licensed under the Apache 2.0 License.