com.redis.spring.batch.writer.operation.AbstractPushAll Maven / Gradle / Ivy
The newest version!
package com.redis.spring.batch.writer.operation;
import java.util.Collection;
import java.util.function.Function;
import org.springframework.batch.item.Chunk;
import org.springframework.util.CollectionUtils;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisListAsyncCommands;
public abstract class AbstractPushAll extends AbstractKeyWriteOperation {
private final Function> valuesFunction;
protected AbstractPushAll(Function keyFunction, Function> valuesFunction) {
super(keyFunction);
this.valuesFunction = valuesFunction;
}
@SuppressWarnings("unchecked")
@Override
protected void execute(BaseRedisAsyncCommands commands, T item, K key, Chunk> outputs) {
Collection values = valuesFunction.apply(item);
if (!CollectionUtils.isEmpty(values)) {
RedisListAsyncCommands listCommands = (RedisListAsyncCommands) commands;
V[] array = (V[]) values.toArray();
outputs.add(doPush(listCommands, key, array));
}
}
protected abstract RedisFuture
© 2015 - 2024 Weber Informatics LLC | Privacy Policy