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

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

There is a newer version: 4.0.7
Show newest version
package com.redis.spring.batch.writer.operation;

import java.util.List;
import java.util.function.Function;

import io.lettuce.core.RedisFuture;
import io.lettuce.core.ScoredValue;
import io.lettuce.core.ZAddArgs;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisSortedSetAsyncCommands;

public class Zadd extends AbstractOperation {

    private Function> value;

    private Function args = t -> null;

    public void setArgs(Function args) {
        this.args = args;
    }

    public void setValue(Function> value) {
        this.value = value;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
        futures.add(((RedisSortedSetAsyncCommands) commands).zadd(key(item), args(item), value(item)));
    }

    private ScoredValue value(T item) {
        return value.apply(item);
    }

    private ZAddArgs args(T item) {
        return args.apply(item);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy