Java Code Examples for org.springframework.data.redis.core.script.DefaultRedisScript#setResultType()
The following examples show how to use
org.springframework.data.redis.core.script.DefaultRedisScript#setResultType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisScriptFactory.java From rqueue with Apache License 2.0 | 6 votes |
static RedisScript getScript(ScriptType type) { Resource resource = new ClassPathResource(type.getPath()); DefaultRedisScript script = new DefaultRedisScript(); script.setLocation(resource); switch (type) { case ADD_MESSAGE: case MOVE_MESSAGE: case PUSH_MESSAGE: case MOVE_MESSAGE_LIST_TO_LIST: case MOVE_MESSAGE_LIST_TO_ZSET: case MOVE_MESSAGE_ZSET_TO_ZSET: case MOVE_MESSAGE_ZSET_TO_LIST: script.setResultType(Long.class); return script; case POP_MESSAGE: script.setResultType(RqueueMessage.class); return script; default: throw new UnknownSwitchCase(type.toString()); } }
Example 2
Source File: commons.java From SpringBootLearn with Apache License 2.0 | 5 votes |
/** * 读取限流脚本 * * @return */ @Bean public DefaultRedisScript<Number> redisluaScript() { DefaultRedisScript<Number> redisScript = new DefaultRedisScript<>(); redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("redisLimit.lua"))); //返回类型 redisScript.setResultType(Number.class); return redisScript; }
Example 3
Source File: RateLimiterAutoConfiguration.java From mica with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") private RedisScript<List<Long>> redisRateLimiterScript() { DefaultRedisScript redisScript = new DefaultRedisScript<>(); redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("META-INF/scripts/mica_rate_limiter.lua"))); redisScript.setResultType(List.class); return redisScript; }
Example 4
Source File: RedisTests.java From uexam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void redisLuaTest() { String script = "return redis.call('set',KEYS[1],ARGV[1])"; DefaultRedisScript<String> redisScript = new DefaultRedisScript<>(script); redisScript.setResultType(String.class); List<String> keys = Arrays.asList("apple"); String result = stringRedisTemplate.execute(redisScript, keys, "1"); Assert.assertEquals("OK", result); }
Example 5
Source File: RedisTests.java From uexam-mysql with GNU Affero General Public License v3.0 | 5 votes |
@Test public void redisLuaTest() { String script = "return redis.call('set',KEYS[1],ARGV[1])"; DefaultRedisScript<String> redisScript = new DefaultRedisScript<>(script); redisScript.setResultType(String.class); List<String> keys = Arrays.asList("apple"); String result = stringRedisTemplate.execute(redisScript, keys, "1"); Assert.assertEquals("OK", result); }
Example 6
Source File: ToolsCacheConfiguration.java From tools with MIT License | 5 votes |
@Bean public DefaultRedisScript<Boolean> setNxScript() { DefaultRedisScript<Boolean> defaultRedisScript = new DefaultRedisScript<>(); defaultRedisScript.setScriptText(Script.SET_NX.getScript()); defaultRedisScript.setResultType(Boolean.class); return defaultRedisScript; }
Example 7
Source File: ToolsCacheConfiguration.java From tools with MIT License | 5 votes |
@Bean public DefaultRedisScript<Boolean> setScript() { DefaultRedisScript<Boolean> defaultRedisScript = new DefaultRedisScript<>(); defaultRedisScript.setScriptText(Script.SET.getScript()); defaultRedisScript.setResultType(Boolean.class); return defaultRedisScript; }
Example 8
Source File: RedisLuaRateLimiter.java From api-boot with Apache License 2.0 | 5 votes |
/** * get Redis Script * * @return RedisScript */ RedisScript<List<Long>> getRedisScript() { DefaultRedisScript redisScript = new DefaultRedisScript<>(); redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource(QPS_LUA_PATH))); redisScript.setResultType(List.class); return redisScript; }
Example 9
Source File: RedisConfig.java From spring-boot-demo with MIT License | 5 votes |
@Bean @SuppressWarnings("unchecked") public RedisScript<Long> limitRedisScript() { DefaultRedisScript redisScript = new DefaultRedisScript<>(); redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("scripts/redis/limit.lua"))); redisScript.setResultType(Long.class); return redisScript; }
Example 10
Source File: GatewayRedisAutoConfiguration.java From spring-cloud-gateway with Apache License 2.0 | 5 votes |
@Bean @SuppressWarnings("unchecked") public RedisScript redisRequestRateLimiterScript() { DefaultRedisScript redisScript = new DefaultRedisScript<>(); redisScript.setScriptSource(new ResourceScriptSource( new ClassPathResource("META-INF/scripts/request_rate_limiter.lua"))); redisScript.setResultType(List.class); return redisScript; }
Example 11
Source File: RedisRateLimiter.java From spring-cloud-zuul-ratelimit with Apache License 2.0 | 4 votes |
private RedisScript<Long> getScript() { DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>(); redisScript.setLocation(new ClassPathResource("/scripts/ratelimit.lua")); redisScript.setResultType(Long.class); return redisScript; }