CacheProperties.java
2.12 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.infoloop.tianting.cache;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 缓存配置属性
*/
@Data
@ConfigurationProperties(prefix = "cache")
public class CacheProperties {
/**
* 是否启用缓存
*/
private boolean enabled = true;
/**
* 默认缓存过期时间(秒)
*/
private int defaultTtl = 300;
/**
* Caffeine本地缓存配置
*/
private CaffeineProperties caffeine = new CaffeineProperties();
/**
* Redis缓存配置
*/
private RedisProperties redis = new RedisProperties();
/**
* 监控配置
*/
private MetricsProperties metrics = new MetricsProperties();
@Data
public static class CaffeineProperties {
/**
* 初始容量
*/
private int initialCapacity = 100;
/**
* 最大容量
*/
private int maximumSize = 10000;
/**
* 写入后过期时间(秒)
*/
private int expireAfterWrite = 60;
/**
* 访问后过期时间(秒),0表示不启用
*/
private int expireAfterAccess = 0;
/**
* 是否记录统计信息
*/
private boolean recordStats = true;
}
@Data
public static class RedisProperties {
/**
* 是否启用Redis缓存
*/
private boolean enabled = true;
/**
* Redis主机
*/
private String host = "localhost";
/**
* Redis端口
*/
private int port = 6379;
/**
* Redis密码
*/
private String password;
/**
* Redis数据库索引
*/
private int database = 1;
/**
* 连接超时时间(毫秒)
*/
private int timeout = 2000;
}
@Data
public static class MetricsProperties {
/**
* 是否启用监控
*/
private boolean enabled = true;
/**
* 监控步长
*/
private String step = "1m";
}
}