Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c56545

Browse filesBrowse files
committed
Add JedisConfig code
1 parent 0a6255e commit 1c56545
Copy full SHA for 1c56545

File tree

Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
package cn.lijunkui.config;
22

3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.boot.context.properties.ConfigurationProperties;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
import redis.clients.jedis.JedisPool;
8+
import redis.clients.jedis.JedisPoolConfig;
9+
10+
@Configuration
311
public class JedisConfig {
12+
13+
@Value("${redis.host}")
14+
String host;
15+
@Value("${redis.port}")
16+
int port;
17+
@Value("${redis.timeout}")
18+
int timeout;
19+
20+
@Bean
21+
@ConfigurationProperties("redis")
22+
public JedisPoolConfig jedisPoolConfig() {
23+
return new JedisPoolConfig();
24+
}
25+
26+
@Bean(destroyMethod = "close")
27+
public JedisPool jedisPool() {
28+
JedisPool jedisPool = new JedisPool(jedisPoolConfig(), host, port, timeout*1000);
29+
return jedisPool;
30+
}
431
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.