private <K, V> ComputingCache<K, V> buildCache(String name, ComputingCache.Function<K, V> loader, ComputingCache.Listener<K> listener) { Long expirationTimeout = configuration.getLongPropertyValue( EngineConfigurationKey.TEMPLATE_CACHE_EXPIRATION_TIMEOUT); if (expirationTimeout > 0) { LOGGER.info("{} cache expiration timeout set: {} seconds", name, expirationTimeout); expirationTimeout = expirationTimeout * 1000L; } else { expirationTimeout = null; } return configuration.getComputingCacheFactory().create( MustacheEngine.COMPUTING_CACHE_CONSUMER_ID, loader, expirationTimeout, null, listener); }
/** * * @param configuration * @return <code>true</code> if it's possible to cache the template in a * segment, i.e. if the cache is enabled, no expiration timeout is * set and debug mode is not enabled, <code>false</code> otherwise */ static boolean isTemplateCachingAllowed(Configuration configuration) { return !configuration.getBooleanPropertyValue(DEBUG_MODE) && configuration.getBooleanPropertyValue(TEMPLATE_CACHE_ENABLED) && configuration.getLongPropertyValue( TEMPLATE_CACHE_EXPIRATION_TIMEOUT) <= 0; }
@Override public void init() { long memberCacheMaxSize = configuration .getLongPropertyValue(MEMBER_CACHE_MAX_SIZE_KEY); LOGGER.debug("Initialized [memberCacheMaxSize: {}]", memberCacheMaxSize); if (memberCacheMaxSize > 0) { memberCache = configuration.getComputingCacheFactory().create( COMPUTING_CACHE_CONSUMER_ID, ReflectionResolver::findWrapper, null, memberCacheMaxSize, null); } hintFallbackEnabled = configuration .getBooleanPropertyValue(HINT_FALLBACK_ENABLED_KEY); }
@Override public void init() { super.init(); this.methodCache = configuration.getComputingCacheFactory().create( InvokeHelper.class.getName(), new MethodComputingFunction(), null, configuration.getLongPropertyValue(METHOD_CACHE_MAX_SIZE_KEY), null); }
public void init() { super.init(); this.fragments = configuration.getComputingCacheFactory().create( CacheHelper.class.getName(), key -> { Fragment fragment = new Fragment(); fragment.update(getContent(key.getOptions()), key.getOptions().getHash().get(GUARD)); key.cleanupAfterCompute(); return fragment; }, null, configuration.getLongPropertyValue(FRAGMENT_CACHE_MAX_SIZE_KEY), null); }