com.redis.spring.batch.writer.operation.SaddAll Maven / Gradle / Ivy
package com.redis.spring.batch.writer.operation;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisSetAsyncCommands;
public class SaddAll extends AbstractOperation {
private Function> values;
public void setValues(Function> values) {
this.values = values;
}
@SuppressWarnings("unchecked")
@Override
public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
Collection collection = values(item);
if (!collection.isEmpty()) {
futures.add(((RedisSetAsyncCommands) commands).sadd(key(item), (V[]) collection.toArray()));
}
}
private Collection values(T item) {
return values.apply(item);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy