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

com.redis.spring.batch.writer.operation.Set 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 io.lettuce.core.RedisFuture;
import io.lettuce.core.SetArgs;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisStringAsyncCommands;

public class Set extends AbstractOperation {

    private static final SetArgs DEFAULT_ARGS = new SetArgs();

    private Function value;

    private Function args = t -> DEFAULT_ARGS;

    public void setValue(Function value) {
        this.value = value;
    }

    public void setArgs(Function args) {
        this.args = args;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
        futures.add(((RedisStringAsyncCommands) commands).set(key(item), value(item), args(item)));
    }

    private SetArgs args(T item) {
        return args.apply(item);
    }

    private V value(T item) {
        return value.apply(item);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy