org.springframework.batch.item.redis.KeyDumpItemWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-batch-redis Show documentation
Show all versions of spring-batch-redis Show documentation
Spring Batch reader and writer implementations for Redis
package org.springframework.batch.item.redis;
import io.lettuce.core.RedisClient;
import io.lettuce.core.api.StatefulConnection;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.cluster.RedisClusterClient;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.batch.item.redis.support.CommandBuilder;
import org.springframework.batch.item.redis.support.KeyValue;
import org.springframework.batch.item.redis.support.operation.Restore;
import java.util.function.Function;
import java.util.function.Supplier;
public class KeyDumpItemWriter extends OperationItemWriter> {
public KeyDumpItemWriter(Supplier> statefulConnectionSupplier, GenericObjectPoolConfig> poolConfig, Function, BaseRedisAsyncCommands> async) {
super(statefulConnectionSupplier, poolConfig, async, restoreOperation());
}
private static RedisOperation> restoreOperation() {
return new Restore<>(KeyValue::getKey, KeyValue::getValue, KeyValue::getAbsoluteTTL);
}
public static KeyDumpItemWriterBuilder client(RedisClient client) {
return new KeyDumpItemWriterBuilder(client);
}
public static KeyDumpItemWriterBuilder client(RedisClusterClient client) {
return new KeyDumpItemWriterBuilder(client);
}
public static class KeyDumpItemWriterBuilder extends CommandBuilder {
public KeyDumpItemWriterBuilder(RedisClusterClient client) {
super(client);
}
public KeyDumpItemWriterBuilder(RedisClient client) {
super(client);
}
public KeyDumpItemWriter build() {
return new KeyDumpItemWriter(connectionSupplier, poolConfig, async);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy