All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pebbletemplates.pebble.cache.template.ConcurrentMapTemplateCache Maven / Gradle / Ivy

There is a newer version: 3.2.2
Show newest version
package io.pebbletemplates.pebble.cache.template;

import io.pebbletemplates.pebble.cache.PebbleCache;
import io.pebbletemplates.pebble.template.PebbleTemplate;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;

public class ConcurrentMapTemplateCache implements PebbleCache {

  private final ConcurrentMap templateCache;

  public ConcurrentMapTemplateCache() {
    this.templateCache = new ConcurrentHashMap<>(200);
  }

  public ConcurrentMapTemplateCache(ConcurrentMap templateCache) {
    this.templateCache = templateCache;
  }

  @Override
  public PebbleTemplate computeIfAbsent(Object key,
      Function mappingFunction) {
    return this.templateCache.computeIfAbsent(key, mappingFunction);
  }

  @Override
  public void invalidateAll() {
    this.templateCache.clear();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy