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
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
instanceId2JobInfoCache = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.concurrencyLevel(CACHE_CONCURRENCY_LEVEL)
|
||||
.maximumSize(instanceMetadataCacheSize)
|
||||
.build();
|
||||
|
@ -39,19 +39,23 @@ public class CacheService {
|
||||
|
||||
public CacheService() {
|
||||
jobId2JobNameCache = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.expireAfterWrite(Duration.ofMinutes(1))
|
||||
.maximumSize(512)
|
||||
.build();
|
||||
|
||||
workflowId2WorkflowNameCache = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.expireAfterWrite(Duration.ofMinutes(1))
|
||||
.maximumSize(512)
|
||||
.build();
|
||||
|
||||
instanceId2AppId = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.maximumSize(1024)
|
||||
.build();
|
||||
jobId2AppId = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.maximumSize(1024)
|
||||
.build();
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class DingTalkAlarmService implements Alarmable {
|
||||
}
|
||||
this.agentId = Long.valueOf(agentId);
|
||||
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!");
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ public class LRUCache<K, V> {
|
||||
|
||||
public LRUCache(int cacheSize) {
|
||||
innerCache = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.concurrencyLevel(2)
|
||||
.maximumSize(cacheSize)
|
||||
.build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user