![JAR search and dependency download from the Maven repository](/logo.png)
org.infinispan.server.resp.commands.generic.TIME Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-server-resp Show documentation
Show all versions of infinispan-server-resp Show documentation
Infinispan Resp Protocol Server
package org.infinispan.server.resp.commands.generic;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import org.infinispan.server.resp.Resp3Handler;
import org.infinispan.server.resp.RespCommand;
import org.infinispan.server.resp.RespRequestHandler;
import org.infinispan.server.resp.commands.Resp3Command;
import org.infinispan.server.resp.serialization.Resp3Response;
import io.netty.channel.ChannelHandlerContext;
/**
* TIME Resp Command
* time
*
* @since 15.0
*/
public class TIME extends RespCommand implements Resp3Command {
public TIME() {
super(1, 0, 0, 0);
}
@Override
public CompletionStage perform(Resp3Handler handler,
ChannelHandlerContext ctx,
List arguments) {
var now = handler.respServer().getTimeService().instant();
var nowSec = String.valueOf(now.getEpochSecond()).getBytes(StandardCharsets.US_ASCII);
var nowMicro = String.valueOf(TimeUnit.NANOSECONDS.toMicros(now.getNano())).getBytes(StandardCharsets.US_ASCII);
var stage = CompletableFuture.completedFuture(Arrays.asList(nowSec, nowMicro));
return handler.stageToReturn(stage, ctx, Resp3Response.ARRAY_BULK_STRING);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy