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

com.redis.spring.batch.writer.operation.JsonDel 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 com.redis.lettucemod.api.async.RedisJSONAsyncCommands;

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

public class JsonDel extends AbstractKeyWriteOperation {

	private Function pathFunction = t -> JsonSet.ROOT_PATH;

	public JsonDel(Function keyFunction) {
		super(keyFunction);
	}

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

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

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected void execute(BaseRedisAsyncCommands commands, T item, K key, Chunk> outputs) {
		String path = pathFunction.apply(item);
		outputs.add((RedisFuture) ((RedisJSONAsyncCommands) commands).jsonDel(key, path));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy