Tabnine Logo
org.thymeleaf.cache
Code IndexAdd Tabnine to your IDE (free)

How to use org.thymeleaf.cache

Best Java code snippets using org.thymeleaf.cache (Showing top 20 results out of 315)

origin: thymeleaf/thymeleaf

@Override
protected final ICache<ExpressionCacheKey, Object> initializeExpressionCache() {
  final int maxSize = getExpressionCacheMaxSize();
  if (maxSize == 0) {
    return null;
  }
  return new StandardCache<ExpressionCacheKey, Object>(
      getExpressionCacheName(), getExpressionCacheUseSoftReferences(), 
      getExpressionCacheInitialSize(), maxSize,
      getExpressionCacheValidityChecker(), getExpressionCacheLogger(), getExpressionCacheEnableCounters());
}

origin: thymeleaf/thymeleaf

@Override
protected final ICache<TemplateCacheKey, TemplateModel> initializeTemplateCache() {
  final int maxSize = getTemplateCacheMaxSize();
  if (maxSize == 0) {
    return null;
  }
  return new StandardCache<TemplateCacheKey, TemplateModel>(
      getTemplateCacheName(), getTemplateCacheUseSoftReferences(), 
      getTemplateCacheInitialSize(), maxSize,
      getTemplateCacheValidityChecker(), getTemplateCacheLogger(), getTemplateCacheEnableCounters());
}
origin: thymeleaf/thymeleaf

public double getHitRatio() {
  long hitCount = getHitCount();
  long getCount = getGetCount();
  if (hitCount == 0 || getCount == 0) {
    return 0;
  }
  return (double) hitCount / (double) getCount;
}
origin: thymeleaf/thymeleaf

static Object getFromCache(final IEngineConfiguration configuration, final String input, final String type) {
  final ICacheManager cacheManager = configuration.getCacheManager();
  if (cacheManager != null) {
    final ICache<ExpressionCacheKey,Object> cache = cacheManager.getExpressionCache();
    if (cache != null) {
      return cache.get(new ExpressionCacheKey(type,input));
    }
  }
  return null;
}
origin: thymeleaf/thymeleaf

static <V> void putIntoCache(final IEngineConfiguration configuration, final String input, final V value, final String type) {
  final ICacheManager cacheManager = configuration.getCacheManager();
  if (cacheManager != null) {
    final ICache<ExpressionCacheKey,Object> cache = cacheManager.getExpressionCache();
    if (cache != null) {
      cache.put(new ExpressionCacheKey(type,input), value);
    }
  }
}
origin: thymeleaf/thymeleaf

static <V> void removeFromCache(final IEngineConfiguration configuration, final String input, final String type) {
  final ICacheManager cacheManager = configuration.getCacheManager();
  if (cacheManager != null) {
    final ICache<ExpressionCacheKey,Object> cache = cacheManager.getExpressionCache();
    if (cache != null) {
      cache.clearKey(new ExpressionCacheKey(type,input));
    }
  }
}
origin: thymeleaf/thymeleaf

public void clearAllCaches() {
  final ICache<TemplateCacheKey, TemplateModel> templateCacheObj = getTemplateCache();
  if (templateCacheObj != null) {
    templateCacheObj.clear();
  }
  final ICache<ExpressionCacheKey, Object> expressionCacheObj = getExpressionCache();
  if (expressionCacheObj != null) {
    expressionCacheObj.clear();
  }
  
  final List<String> allSpecificCacheNamesObj = getAllSpecificCacheNames();
  if (allSpecificCacheNamesObj != null) {
    for (final String specificCacheName : allSpecificCacheNamesObj) {
      final ICache<?,?> specificCache = getSpecificCache(specificCacheName);
      if (specificCache != null) {
        specificCache.clear();
      }
    }
  }
  
}
origin: thymeleaf/thymeleaf

public void put(final K key, final V value) {
  incrementReportEntity(this.putCount);
  final CacheEntry<V> entry = new CacheEntry<V>(value, this.useSoftReferences);
  // newSize will be -1 if traceExecution is false
  final int newSize = this.dataContainer.put(key, entry);
  if (this.traceExecution) {
    this.logger.trace(
        "[THYMELEAF][{}][{}][CACHE_ADD][{}] Adding cache entry in cache \"{}\" for key \"{}\". New size is {}.",
        new Object[] {TemplateEngine.threadIndex(), this.name, Integer.valueOf(newSize), this.name, key, Integer.valueOf(newSize)});
    outputReportIfNeeded();
  }
}
origin: thymeleaf/thymeleaf

private static ExpressionCacheKey computeMethodCacheKey(final Class<?> targetClass, final String propertyName) {
  return new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_OGNL_SHORTCUT, targetClass.getName(), propertyName);
}
origin: thymeleaf/thymeleaf

public int put(final K key, final CacheEntry<V> value) {
  if (this.traceExecution) {
    return putWithTracing(key, value);
  }
  return putWithoutTracing(key, value);
}
origin: thymeleaf/thymeleaf

public int remove(final K key) {
  if (this.traceExecution) {
    return removeWithTracing(key);
  }
  return removeWithoutTracing(key);
}
origin: thymeleaf/thymeleaf

/**
 * <p>
 *   Clears the template cache.
 * </p>
 */
public void clearCaches() {
  if (this.templateCache != null) {
    this.templateCache.clear();
  }
}
origin: thymeleaf/thymeleaf

public final ICache<TemplateCacheKey, TemplateModel> getTemplateCache() {
  if (!this.templateCacheInitialized) {
    synchronized(this) {
      if (!this.templateCacheInitialized) {
        this.templateCache = initializeTemplateCache();
        this.templateCacheInitialized = true;
      }
    }
  }
  return this.templateCache;
}
origin: thymeleaf/thymeleaf

public final ICache<ExpressionCacheKey, Object> getExpressionCache() {
  if (!this.expressionCacheInitialized) {
    synchronized(this) {
      if (!this.expressionCacheInitialized) {
        this.expressionCache = initializeExpressionCache();
        this.expressionCacheInitialized = true;
      }
    }
  }
  return this.expressionCache;
}
origin: thymeleaf/thymeleaf

public V get(final K key) {
  return get(key, this.entryValidityChecker);
}
origin: thymeleaf/thymeleaf

public int size() {
  return this.dataContainer.size();
}
origin: thymeleaf/thymeleaf

/**
 * <p>
 *   Returns all the keys contained in this cache. Note this method might return keys for entries
 *   that are already invalid, so the result of calling {@link #get(Object)} for these keys might
 *   be {@code null}.
 * </p>
 *
 * @return the complete set of cache keys. Might include keys for already-invalid (non-cleaned) entries.
 * @since 2.1.4
 */
public Set<K> keySet() {
  return this.dataContainer.keySet();
}
origin: thymeleaf/thymeleaf

public double getMissRatio() {
  return 1 - getHitRatio();
}
origin: thymeleaf/thymeleaf

@Override
protected ICacheEntryValidity computeValidity(final IEngineConfiguration configuration, final String ownerTemplate, final String template, final Map<String, Object> templateResolutionAttributes) {
  if (isCacheable()) {
    if (this.cacheTTLMs != null) {
      return new TTLCacheEntryValidity(this.cacheTTLMs.longValue());
    }
    return AlwaysValidCacheEntryValidity.INSTANCE;
  }
  return NonCacheableCacheEntryValidity.INSTANCE;
}
origin: thymeleaf/thymeleaf

public ExpressionCacheKey(final String type, final String expression0, final String expression1) {
  super();
  Validate.notNull(type, "Type cannot be null");
  Validate.notNull(expression0, "Expression cannot be null");
  this.type = type;
  this.expression0 = expression0;
  this.expression1 = expression1;
  // This being a cache key, its equals and hashCode methods will potentially execute many
  // times, so this could help performance
  this.h = computeHashCode();
}
org.thymeleaf.cache

Most used classes

  • ICache
    Common interface for all the cache objects used by the template engine. This is the interface tha
  • ICacheManager
    Common interface for all cache manager implementations. This class is in charge of providing the
  • ExpressionCacheKey
  • StandardCacheManager
    Standard implementation of ICacheManager, returning configurable instances of StandardCache for eac
  • AbstractCacheManager
    Common abstract class for ICacheManager implementations, useful for taking care of the lazy initial
  • StandardCache$CacheDataContainer,
  • StandardCache$CacheEntry,
  • StandardCache,
  • TemplateCacheKey,
  • ICacheEntryValidity,
  • NonCacheableCacheEntryValidity,
  • TTLCacheEntryValidity
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now