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

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

package com.redis.spring.batch.writer;

import java.util.function.Function;

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

public class Set extends AbstractKeyValueOperation {

	private static final SetArgs DEFAULT_ARGS = new SetArgs();

	private Function argsFunction = t -> DEFAULT_ARGS;

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

	public void setArgs(SetArgs args) {
		this.argsFunction = t -> args;
	}

	public void setArgsFunction(Function function) {
		this.argsFunction = function;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected RedisFuture execute(BaseRedisAsyncCommands commands, T item, K key, V value) {
		SetArgs args = argsFunction.apply(item);
		return ((RedisStringAsyncCommands) commands).set(key, value, args);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy