mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
improve configuration for guava cache
This commit is contained in:
@@ -34,6 +34,7 @@ package sonia.scm.cache;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -48,6 +49,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class GuavaCacheManager implements CacheManager
|
||||
{
|
||||
|
||||
@@ -57,6 +59,25 @@ public class GuavaCacheManager implements CacheManager
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(GuavaCacheManager.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public GuavaCacheManager()
|
||||
{
|
||||
CacheConfigurationReader reader = new CacheConfigurationReader();
|
||||
CacheManagerConfiguration config = reader.read();
|
||||
|
||||
defaultConfiguration = config.getDefaultCache();
|
||||
|
||||
for (NamedCacheConfiguration ncc : config.getCaches())
|
||||
{
|
||||
cacheMap.put(ncc.getName(), new GuavaCache(ncc));
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -105,7 +126,7 @@ public class GuavaCacheManager implements CacheManager
|
||||
logger.debug(
|
||||
"cache {} does not exists, creating a new instance from default configuration: {}",
|
||||
name, defaultConfiguration);
|
||||
cache = new GuavaCache<K, V>(defaultConfiguration);
|
||||
cache = new GuavaCache<K, V>(defaultConfiguration, name);
|
||||
cacheMap.put(name, cache);
|
||||
}
|
||||
|
||||
@@ -118,5 +139,5 @@ public class GuavaCacheManager implements CacheManager
|
||||
private Map<String, GuavaCache> cacheMap = Maps.newConcurrentMap();
|
||||
|
||||
/** Field description */
|
||||
private NamedCacheConfiguration defaultConfiguration;
|
||||
private CacheConfiguration defaultConfiguration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user