@@ -36,8 +36,10 @@ https://central.sonatype.com/artifact/com.litongjava/jfinal-plugins
36
36
37
37
```
38
38
redis.host=127.0.0.1
39
- redis.port=6379
39
+ redis.port=6789
40
40
redis.password=
41
+ redis.database=2
42
+ redis.timeout=15000
41
43
redis.cacheName=main
42
44
```
43
45
@@ -46,6 +48,7 @@ redis.cacheName=main
46
48
这个类是一个配置类,用于初始化和配置 EhCache 插件。它通过 @AConfiguration 注解标记为配置类。类中的方法 redisPlugin 通过 @ABean 注解标记为 Bean 方法,框架启动时会执行该方法并将返回值放到 bean 容器中。在这个方法中,创建了一个 Plugin 实例并启动它。destroyMethod 指定在服务关闭时将会调用该方法,关闭该插件
47
49
48
50
```
51
+ package com.litongjava.tio.boot.admin.config;
49
52
50
53
import com.litongjava.jfinal.aop.annotation.AConfiguration;
51
54
import com.litongjava.jfinal.aop.annotation.AInitialization;
@@ -63,20 +66,24 @@ public class RedisPluginConfig {
63
66
String host = EnvironmentUtils.getStr("redis.host");
64
67
Integer port = EnvironmentUtils.getInt("redis.port");
65
68
String password = EnvironmentUtils.getStr("redis.password");
69
+ int redistimeout = EnvironmentUtils.getInt("redis.timeout", 60);
70
+ int redisDatabase = EnvironmentUtils.getInt("redis.database", 0);
66
71
String cacheName = EnvironmentUtils.get("redis.cacheName");
67
72
68
73
// 创建并启动 Redis 插件
69
- RedisPlugin mainRedis = new RedisPlugin(cacheName, host, port, password);
74
+ RedisPlugin mainRedis = new RedisPlugin(cacheName, host, port, redistimeout, password, redisDatabase );
70
75
mainRedis.start();
71
76
72
77
// 测试连接
73
- Cache cache = Redis.use("main" );
78
+ Cache cache = Redis.use(cacheName );
74
79
cache.getJedis().connect();
75
80
76
81
TioBootServer.me().addDestroyMethod(mainRedis::stop);
77
82
return mainRedis;
78
83
}
79
84
}
85
+
86
+
80
87
```
81
88
82
89
### 控制器
0 commit comments