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

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

There is a newer version: 3.1.1
Show 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;
	
	@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;
	}
	
	@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));
		}
	}

	public long getId() {
		return id;
	}

	public long getTimeStamp() {
		return timeStamp;
	}

	public long getExecutionTime() {
		return executionTime;
	}

	public List getArgs() {
		return args;
	}
}