mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: use soft reference in cache to optimize memory usage #291
This commit is contained in:
parent
c3eefeb626
commit
6bcd6e0be3
@ -38,6 +38,7 @@ public class InstanceMetadataService implements InitializingBean {
|
|||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
instanceId2JobInfoCache = CacheBuilder.newBuilder()
|
instanceId2JobInfoCache = CacheBuilder.newBuilder()
|
||||||
|
.softValues()
|
||||||
.concurrencyLevel(CACHE_CONCURRENCY_LEVEL)
|
.concurrencyLevel(CACHE_CONCURRENCY_LEVEL)
|
||||||
.maximumSize(instanceMetadataCacheSize)
|
.maximumSize(instanceMetadataCacheSize)
|
||||||
.build();
|
.build();
|
||||||
|
@ -39,19 +39,23 @@ public class CacheService {
|
|||||||
|
|
||||||
public CacheService() {
|
public CacheService() {
|
||||||
jobId2JobNameCache = CacheBuilder.newBuilder()
|
jobId2JobNameCache = CacheBuilder.newBuilder()
|
||||||
|
.softValues()
|
||||||
.expireAfterWrite(Duration.ofMinutes(1))
|
.expireAfterWrite(Duration.ofMinutes(1))
|
||||||
.maximumSize(512)
|
.maximumSize(512)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
workflowId2WorkflowNameCache = CacheBuilder.newBuilder()
|
workflowId2WorkflowNameCache = CacheBuilder.newBuilder()
|
||||||
|
.softValues()
|
||||||
.expireAfterWrite(Duration.ofMinutes(1))
|
.expireAfterWrite(Duration.ofMinutes(1))
|
||||||
.maximumSize(512)
|
.maximumSize(512)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
instanceId2AppId = CacheBuilder.newBuilder()
|
instanceId2AppId = CacheBuilder.newBuilder()
|
||||||
|
.softValues()
|
||||||
.maximumSize(1024)
|
.maximumSize(1024)
|
||||||
.build();
|
.build();
|
||||||
jobId2AppId = CacheBuilder.newBuilder()
|
jobId2AppId = CacheBuilder.newBuilder()
|
||||||
|
.softValues()
|
||||||
.maximumSize(1024)
|
.maximumSize(1024)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class DingTalkAlarmService implements Alarmable {
|
|||||||
}
|
}
|
||||||
this.agentId = Long.valueOf(agentId);
|
this.agentId = Long.valueOf(agentId);
|
||||||
dingTalkUtils = new DingTalkUtils(appKey, appSecret);
|
dingTalkUtils = new DingTalkUtils(appKey, appSecret);
|
||||||
mobile2UserIdCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).build();
|
mobile2UserIdCache = CacheBuilder.newBuilder().softValues().maximumSize(CACHE_SIZE).build();
|
||||||
log.info("[DingTalkAlarmService] init DingTalkAlarmService successfully!");
|
log.info("[DingTalkAlarmService] init DingTalkAlarmService successfully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ public class LRUCache<K, V> {
|
|||||||
|
|
||||||
public LRUCache(int cacheSize) {
|
public LRUCache(int cacheSize) {
|
||||||
innerCache = CacheBuilder.newBuilder()
|
innerCache = CacheBuilder.newBuilder()
|
||||||
|
.softValues()
|
||||||
.concurrencyLevel(2)
|
.concurrencyLevel(2)
|
||||||
.maximumSize(cacheSize)
|
.maximumSize(cacheSize)
|
||||||
.build();
|
.build();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user