RedissonConfig.java
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.viontech.fanxing.commons.config;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.spring.data.connection.RedissonConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.FileInputStream;
import java.io.IOException;
/**
* .
*
* @author 谢明辉
* @date 2021/7/5
*/
@Configuration
public class RedissonConfig {
@Bean
public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) {
return new RedissonConnectionFactory(redisson);
}
@Bean(destroyMethod = "shutdown")
public RedissonClient redisson(@Value("${vion.redisson.path}") String path) throws IOException {
try (FileInputStream inputStream = new FileInputStream(path)) {
Config config = Config.fromYAML(inputStream);
config.setLockWatchdogTimeout(12000);
return Redisson.create(config);
}
}
}