Future is the class in JDK that gives ability to get result somehow in the future. During the interval application can perform another task that how parallelism can give immediate benefit without deep refactoring of application.

Here is the example of GET operation with future:

GkvsFuture<Record> future = Gkvs.Client.get(KEY).async();
// do something else
Record record = future.getUnchecked(); // blocking code 

And MULTI_GET example:

GkvsFuture<Iterable<Record>> records = Gkvs.Client.multiGet(LOAD_KEYS).async();

// do something else

for (Record rec : records.getUnchecked()) {
  System.out.println(rec.key().get());
}

GkvsFuture also supports classical get() function with all checked exceptions in the list.

Additionally GkvsFuture has ability to register a listener and get notification when data will be available.

Listener example:

final AtomicBoolean triggered = new AtomicBoolean(false);
GkvsFuture<Record> future = Gkvs.Client.get(KEY).async();

future.addListener(new Runnable() {

  @Override
  public void run() {
    triggered.set(true);
  }
			
});
Record rec = future.getUnchecked();

gkvs

gkvs