com.redis.spring.batch.writer.operation.Hset Maven / Gradle / Ivy
package com.redis.spring.batch.writer.operation;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisHashAsyncCommands;
public class Hset extends AbstractOperation {
private Function> map;
public void setMap(Function> map) {
this.map = map;
}
@SuppressWarnings("unchecked")
@Override
public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
Map value = map.apply(item);
if (value != null && !value.isEmpty()) {
K key = key(item);
futures.add(((RedisHashAsyncCommands) commands).hset(key, value));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy