Skip to content

Instantly share code, notes, and snippets.

@samuelcatalano-zz
Created August 18, 2020 16:45
Show Gist options
  • Save samuelcatalano-zz/1b0fe35213e91152c9ea220710a01776 to your computer and use it in GitHub Desktop.
Save samuelcatalano-zz/1b0fe35213e91152c9ea220710a01776 to your computer and use it in GitHub Desktop.
public static Cache<Integer, List<CountryPublicHolidays>> countryPublicHolidaysCache;
static {
countryPublicHolidaysCache = CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(20, TimeUnit.MINUTES)
.build();
}
var cachedCountryPublicHolidays = countryPublicHolidaysCache.getIfPresent(currentYear);
countryPublicHolidaysCache.put(currentYear, Optional.ofNullable(countryPublicHolidays).orElse(Collections.emptyList()));
return countryPublicHolidaysCache.getIfPresent(currentYear);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment