com.redis.spring.batch.writer.operation.Geoadd Maven / Gradle / Ivy
The newest version!
package com.redis.spring.batch.writer.operation;
import java.util.function.Function;
import org.springframework.batch.item.Chunk;
import io.lettuce.core.GeoAddArgs;
import io.lettuce.core.GeoValue;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisGeoAsyncCommands;
public class Geoadd extends AbstractKeyWriteOperation {
private final Function> valueFunction;
private Function argsFunction = t -> null;
public Geoadd(Function keyFunction, Function> valueFunction) {
super(keyFunction);
this.valueFunction = valueFunction;
}
public void setArgs(GeoAddArgs args) {
this.argsFunction = t -> args;
}
public void setArgsFunction(Function args) {
this.argsFunction = args;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void execute(BaseRedisAsyncCommands commands, T item, K key, Chunk> outputs) {
GeoAddArgs args = argsFunction.apply(item);
GeoValue value = valueFunction.apply(item);
outputs.add((RedisFuture) ((RedisGeoAsyncCommands) commands).geoadd(key, args, value));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy