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

com.github.damianwajser.configuration.RedisScriptsConfiguration Maven / Gradle / Ivy

package com.github.damianwajser.configuration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.core.script.RedisScript;
import org.springframework.scripting.support.ResourceScriptSource;

import java.util.ArrayList;

@Configuration
@ConditionalOnProperty(name = "spring.commons.cache.enabled", havingValue = "true")
public class RedisScriptsConfiguration {
	@Bean(name = "scriptCheckAndSetHash")
	public RedisScript scriptCheckAndSetHash() {
		DefaultRedisScript redisScript = new DefaultRedisScript<>();
		redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("checkAndSetHash.lua")));
		redisScript.setResultType(ArrayList.class);

		return redisScript;
	}

	@Bean(name = "scriptCheckAndSetHashKeys")
	public RedisScript scriptCheckAndSetHashKeys() {
		DefaultRedisScript redisScript = new DefaultRedisScript<>();
		redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("checkAndSetHashKeys.lua")));
		redisScript.setResultType(ArrayList.class);

		return redisScript;
	}

	@Bean(name = "scriptCheckAndIncrementHash")
	public RedisScript scriptCheckAndIncrementHash() {
		DefaultRedisScript redisScript = new DefaultRedisScript<>();
		redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("checkAndIncrementHash.lua")));
		redisScript.setResultType(ArrayList.class);

		return redisScript;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy