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

com.redis.spring.batch.writer.operation.TsAdd Maven / Gradle / Ivy

There is a newer version: 4.0.7
Show newest version
package com.redis.spring.batch.writer.operation;

import java.util.List;
import java.util.function.Function;

import com.redis.lettucemod.api.async.RedisTimeSeriesAsyncCommands;
import com.redis.lettucemod.timeseries.AddOptions;
import com.redis.lettucemod.timeseries.Sample;

import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;

public class TsAdd extends AbstractOperation {

    private Function sample;

    private Function> options = t -> null;

    public void setSample(Function sample) {
        this.sample = sample;
    }

    public void setOptions(AddOptions options) {
        setOptions(t -> options);
    }

    public void setOptions(Function> options) {
        this.options = options;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
        futures.add(((RedisTimeSeriesAsyncCommands) commands).tsAdd(key(item), sample(item), options(item)));
    }

    private AddOptions options(T item) {
        return options.apply(item);
    }

    private Sample sample(T item) {
        return sample.apply(item);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy