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

com.redis.spring.batch.writer.operation.AbstractPushAllOperation Maven / Gradle / Ivy

There is a newer version: 4.0.7
Show newest version
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.RedisListAsyncCommands;

public abstract class AbstractPushAllOperation extends AbstractOperation {

    private Function> values;

    public void setValues(Function> function) {
        this.values = function;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
        Collection collection = values.apply(item);
        if (collection.isEmpty()) {
            return;
        }
        RedisListAsyncCommands listCommands = (RedisListAsyncCommands) commands;
        futures.add(doPush(listCommands, key(item), (V[]) collection.toArray()));
    }

    protected abstract RedisFuture doPush(RedisListAsyncCommands commands, K key, V[] values);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy