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

com.redis.spring.batch.writer.JsonSet Maven / Gradle / Ivy

package com.redis.spring.batch.writer;

import java.util.function.Function;

import com.redis.lettucemod.api.async.RedisJSONAsyncCommands;

import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;

public class JsonSet extends AbstractKeyValueOperation {

	public static final String ROOT_PATH = "$";

	private Function pathFunction = t -> ROOT_PATH;

	public JsonSet(Function keyFunction, Function valueFunction) {
		super(keyFunction, valueFunction);
	}

	public void setPath(String path) {
		this.pathFunction = t -> path;
	}

	public void setPathFunction(Function path) {
		this.pathFunction = path;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected RedisFuture execute(BaseRedisAsyncCommands commands, T item, K key, V value) {
		String path = pathFunction.apply(item);
		return ((RedisJSONAsyncCommands) commands).jsonSet(key, path, value);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy