package org.apache.seatunnel.connectors.seatunnel.preview.config;

import io.lettuce.core.api.sync.RedisCommands;
import lombok.NonNull;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class RedisSingleClient implements RedisClient{

    private final RedisCommands<String, String> redisCommands;

    public RedisSingleClient(@NonNull RedisCommands<String, String> redisCommands) {
        this.redisCommands = redisCommands;
    }

    @Override
    public String set(final String key, final String value) {
        return redisCommands.set(key, value);
    }

    @Override
    public String get(final String key) {
        return redisCommands.get(key);
    }

    @Override
    public boolean hset(final String key, final String field, final String value) {
        return redisCommands.hset(key, field, value);
    }

    @Override
    public Map<String, String> hgetAll(final String key) {
        return redisCommands.hgetall(key);
    }

    @Override
    public long lpush(final String key, final String... strings) {
        return redisCommands.lpush(key, strings);
    }

    @Override
    public List<String> lrange(final String key, final long start, final long stop) {
        return redisCommands.lrange(key, start, stop);
    }

    @Override
    public long sadd(final String key, final String... members) {
        return redisCommands.sadd(key, members);
    }

    @Override
    public Set<String> smembers(final String key) {
        return redisCommands.smembers(key);
    }

    @Override
    public long zadd(final String key, final double score, final String member) {
        return redisCommands.zadd(key, score, member);
    }

    @Override
    public List<String> zrange(final String key, final long start, final long stop) {
        return redisCommands.zrange(key, start, stop);
    }

    @Override
    public void close() {
    }

    @Override
    public void expire(String key, Duration duration) {
        redisCommands.expire(key, duration.getSeconds());
    }
}
