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

io.odpf.depot.redis.client.response.RedisStandaloneResponse Maven / Gradle / Ivy

There is a newer version: 0.3.8
Show newest version
package io.odpf.depot.redis.client.response;

import lombok.Getter;
import redis.clients.jedis.Response;
import redis.clients.jedis.exceptions.JedisException;

public class RedisStandaloneResponse implements RedisResponse {
    private final Response response;
    private final Response ttlResponse;
    private final String command;
    @Getter
    private String message;
    @Getter
    private boolean failed = true;

    public RedisStandaloneResponse(String command, Response response, Response ttlResponse) {
        this.command = command;
        this.response = response;
        this.ttlResponse = ttlResponse;
    }

    public RedisStandaloneResponse process() {
        try {
            Object cmd = response.get();
            Object ttl = ttlResponse != null ? (((long) ttlResponse.get()) == 0L ? "NOT UPDATED" : "UPDATED") : "NoOp";
            message = String.format("%s: %s, TTL: %s", command, cmd, ttl);
            failed = false;
        } catch (JedisException e) {
            message = e.getMessage();
            failed = true;
        }
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy