use of com.github.benmanes.caffeine.cache.Scheduler in project promregator by promregator.
the class CFAccessorCacheCaffeine method setupCaches.
@PostConstruct
public void setupCaches() {
log.info(String.format("Cache refresh timings: org cache: %ds, space cache: %ds, app cache: %ds, app summary cache: %ds", this.refreshCacheOrgLevelInSeconds, this.refreshCacheSpaceLevelInSeconds, this.refreshCacheApplicationLevelInSeconds, this.refreshCacheApplicationLevelInSeconds));
log.info(String.format("Cache expiry timings: org cache: %ds, space cache: %ds, app cache: %ds, app summary cache: %ds", this.expiryCacheOrgLevelInSeconds, this.expiryCacheSpaceLevelInSeconds, this.expiryCacheApplicationLevelInSeconds, this.expiryCacheApplicationLevelInSeconds));
Scheduler caffeineScheduler = Scheduler.forScheduledExecutorService(new ScheduledThreadPoolExecutor(1));
this.orgCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheOrgLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheOrgLevelInSeconds, TimeUnit.SECONDS).scheduler(caffeineScheduler).recordStats().buildAsync(new OrgCacheLoader());
this.internalMetrics.addCaffeineCache("orgCache", this.orgCache);
this.allOrgIdCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheOrgLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheOrgLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new AllOrgIdCacheLoader());
this.internalMetrics.addCaffeineCache("allOrgCache", this.allOrgIdCache);
this.spaceCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheSpaceLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheSpaceLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new SpaceCacheLoader());
this.internalMetrics.addCaffeineCache("spaceCache", this.spaceCache);
this.spaceIdInOrgCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheSpaceLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheSpaceLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new SpaceIdInOrgCacheLoader());
this.internalMetrics.addCaffeineCache("spaceInOrgCache", this.spaceIdInOrgCache);
this.appsInSpaceCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheApplicationLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheApplicationLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new AppsInSpaceCacheLoader());
this.internalMetrics.addCaffeineCache("appsInSpace", this.appsInSpaceCache);
this.spaceSummaryCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheApplicationLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheApplicationLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new SpaceSummaryCacheLoader());
this.internalMetrics.addCaffeineCache("spaceSummary", this.spaceSummaryCache);
this.domainsInOrgCache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheDomainLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheDomainLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new DomainCacheLoader());
this.internalMetrics.addCaffeineCache("domain", this.domainsInOrgCache);
this.appsInSpaceV3Cache = Caffeine.newBuilder().expireAfterAccess(this.expiryCacheApplicationLevelInSeconds, TimeUnit.SECONDS).refreshAfterWrite(this.refreshCacheApplicationLevelInSeconds, TimeUnit.SECONDS).recordStats().scheduler(caffeineScheduler).buildAsync(new AppsInSpaceV3CacheLoader());
this.internalMetrics.addCaffeineCache("appsInSpaceV3", this.appsInSpaceV3Cache);
}
Aggregations