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

org.springframework.batch.item.redis.KeyDumpItemReader Maven / Gradle / Ivy

There is a newer version: 2.16.0
Show newest version
package org.springframework.batch.item.redis;

import io.lettuce.core.RedisClient;
import io.lettuce.core.cluster.RedisClusterClient;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.redis.support.*;

import java.time.Duration;

public class KeyDumpItemReader extends KeyValueItemReader> {

    public KeyDumpItemReader(ItemReader keyReader, KeyDumpValueReader valueReader, int threads, int chunkSize, int queueCapacity, Duration queuePollTimeout) {
        super(keyReader, valueReader, threads, chunkSize, queueCapacity, queuePollTimeout);
    }

    public static KeyDumpItemReaderBuilder client(RedisClient client) {
        return new KeyDumpItemReaderBuilder(client, KeyDumpValueReader.client(client).build());
    }

    public static KeyDumpItemReaderBuilder client(RedisClusterClient client) {
        return new KeyDumpItemReaderBuilder(client, KeyDumpValueReader.client(client).build());
    }

    public static class KeyDumpItemReaderBuilder extends KeyValueItemReaderBuilder, KeyDumpValueReader, KeyDumpItemReaderBuilder> {

        public KeyDumpItemReaderBuilder(RedisClient client, KeyDumpValueReader valueReader) {
            super(client, valueReader);
        }

        public KeyDumpItemReaderBuilder(RedisClusterClient client, KeyDumpValueReader valueReader) {
            super(client, valueReader);
        }

        public KeyDumpItemReader build() {
            return new KeyDumpItemReader(keyReader(), valueReader, threads, chunkSize, queueCapacity, queuePollTimeout);
        }

        public LiveKeyDumpItemReaderBuilder live() {
            if (client instanceof RedisClusterClient) {
                return new LiveKeyDumpItemReaderBuilder((RedisClusterClient) client, valueReader);
            }
            return new LiveKeyDumpItemReaderBuilder((RedisClient) client, valueReader);
        }

    }

    public static class LiveKeyDumpItemReaderBuilder extends LiveKeyValueItemReaderBuilder, KeyDumpValueReader, LiveKeyDumpItemReaderBuilder> {


        public LiveKeyDumpItemReaderBuilder(RedisClient client, KeyDumpValueReader valueReader) {
            super(client, valueReader);
        }

        protected LiveKeyDumpItemReaderBuilder(RedisClusterClient client, KeyDumpValueReader valueReader) {
            super(client, valueReader);
        }

        public LiveKeyValueItemReader> build() {
            return new LiveKeyValueItemReader<>(keyReader(), valueReader, threads, chunkSize, queueCapacity, queuePollTimeout, flushingInterval, idleTimeout);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy