All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tonivade.resp.command.server.PingCommand Maven / Gradle / Ivy

Go to download

Netty implementation of REdis Serialization Protocol, and a simple framework to implement command based protocols

There is a newer version: 0.24.0
Show newest version
/*
 * Copyright (c) 2015-2019, Antonio Gabriel Muñoz Conejo 
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.resp.command.server;

import static com.github.tonivade.resp.protocol.RedisToken.status;
import static com.github.tonivade.resp.protocol.RedisToken.string;

import com.github.tonivade.resp.annotation.Command;
import com.github.tonivade.resp.command.RespCommand;
import com.github.tonivade.resp.command.Request;
import com.github.tonivade.resp.protocol.RedisToken;

@Command("ping")
public class PingCommand implements RespCommand {

  public static final String PONG = "PONG";

  @Override
  public RedisToken execute(Request request) {
    if (request.getLength() > 0) {
      return string(request.getParam(0));
    } else {
      return status(PONG);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy