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

redis.clients.util.Slowlog Maven / Gradle / Ivy

Go to download

A java client for github.com/antirez/redis, a fork of github.com/xetorthio/jedis

The newest version!
package redis.clients.util;

import java.util.ArrayList;
import java.util.List;

public class Slowlog {
  private final long id;
  private final long timeStamp;
  private final long executionTime;
  private final List args;
  private static final String COMMA = ",";

  @SuppressWarnings("unchecked")
  private Slowlog(List properties) {
    super();
    this.id = (Long) properties.get(0);
    this.timeStamp = (Long) properties.get(1);
    this.executionTime = (Long) properties.get(2);

    List bargs = (List) properties.get(3);
    this.args = new ArrayList(bargs.size());

    for (byte[] barg : bargs) {
      this.args.add(SafeEncoder.encode(barg));
    }
  }

  @SuppressWarnings("unchecked")
  public static List from(List nestedMultiBulkReply) {
    List logs = new ArrayList(nestedMultiBulkReply.size());
    for (Object obj : nestedMultiBulkReply) {
      List properties = (List) obj;
      logs.add(new Slowlog(properties));
    }

    return logs;
  }
  
  public long getId() {
    return id;
  }

  public long getTimeStamp() {
    return timeStamp;
  }

  public long getExecutionTime() {
    return executionTime;
  }

  public List getArgs() {
    return args;
  }

  @Override
  public String toString() {
    return new StringBuilder().append(id).append(COMMA).append(timeStamp).append(COMMA)
        .append(executionTime).append(COMMA).append(args).toString();
  }
}