Caffeine
.newBuilder()
.maximumSize(500)
.refreshAfterWrite(CACHE_REFRESH_TIME_IN_SECONDS, TimeUnit.SECONDS)
.recordStats(() -> new CaffeineStatsCounter(counter, gauge, "header"))
.expireAfter(new ExpirableCacheEntryExpiry<ExperimentSetCacheKey, ExperimentSetResponse>())
.build(new MemcacheCacheLoader<ExperimentSetCacheKey, ExperimentSetResponse>(memcachedClient, "search") {
@Override
public Optional<ExperimentSetResponse> fetchFromSource(ExperimentSetCacheKey key) {
return getExperimentSetByContentIdFromSource(
key.getId(),
key.getToken(),
key.getNumberOfItems());
}
@Override
public String getCacheKey(final ExperimentSetCacheKey key) {
return String.format("%s-key", key.getSwid());
}
@Override
public int getCacheExpirationInSeconds(Optional<ExperimentSetResponse> source) {
return CACHE_EXPIRATION_TIME_IN_SECONDS;
}
@Override
public int getCacheRefreshEligibleInSeconds(Optional<ExperimentSetResponse> source) {
return CACHE_REFRESH_TIME_IN_SECONDS;
}
});```
-
Notifications
You must be signed in to change notification settings - Fork 0
stevelaw/caffeine-remote-cache
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published