com.redis.spring.batch.writer.operation.Sadd Maven / Gradle / Ivy
The newest version!
package com.redis.spring.batch.writer.operation;
import java.util.function.Function;
import org.springframework.batch.item.Chunk;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisSetAsyncCommands;
public class Sadd extends AbstractKeyWriteOperation {
private Function valueFunction;
public Sadd(Function keyFunction, Function valueFunction) {
super(keyFunction);
this.valueFunction = valueFunction;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void execute(BaseRedisAsyncCommands commands, T item, K key, Chunk> outputs) {
V value = valueFunction.apply(item);
outputs.add((RedisFuture) ((RedisSetAsyncCommands) commands).sadd(key, value));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy