public ScriptCache(int maximumSize, int hoursExpiration, Function<F, ScriptResult<V>> loader,
BiConsumer<ScriptResult<V>, List<L>> notifier) {
this.loader = Objects.requireNonNull(loader);
Objects.requireNonNull(notifier);
cache = CacheBuilder.newBuilder()
.maximumSize(maximumSize)
.expireAfterAccess(hoursExpiration, TimeUnit.HOURS)
.removalListener(notification -> {
String projectFileId = (String) notification.getKey();
LOGGER.info("Project file {} cache removed ({})", projectFileId, notification.getCause());
notifier.accept((ScriptResult<V>) notification.getValue(), getListeners(projectFileId).toList());
})
.build();
}