From b84bdb3baa377d665474ffcf6456f0c1c9dd6909 Mon Sep 17 00:00:00 2001 From: Napster Date: Sun, 11 Mar 2018 08:30:03 +0100 Subject: [PATCH] Turn off ehcache overflow to disk --- .../java/fredboat/db/DatabaseManager.java | 20 ------------------- Database/src/main/resources/ehcache_cache.xml | 8 ++++---- Database/src/main/resources/ehcache_main.xml | 14 ++++++------- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/Database/src/main/java/fredboat/db/DatabaseManager.java b/Database/src/main/java/fredboat/db/DatabaseManager.java index 00bfc7c4b..4de057864 100644 --- a/Database/src/main/java/fredboat/db/DatabaseManager.java +++ b/Database/src/main/java/fredboat/db/DatabaseManager.java @@ -29,8 +29,6 @@ import com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory; import io.prometheus.client.hibernate.HibernateStatisticsCollector; import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.PersistenceConfiguration; import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.flywaydb.core.Flyway; @@ -203,11 +201,6 @@ private DatabaseConnection initMainDbConn() throws DatabaseException { .setFlyway(flyway) .build(); - //adjusting the ehcache config - if (mainTunnel == null && cacheTunnel == null) { - //local database: turn off overflow to disk of the cache - turnOffLocalStorageForEhcacheManager("MAIN_CACHEMANAGER"); - } log.debug(CacheManager.getCacheManager("MAIN_CACHEMANAGER").getActiveConfigurationText()); return databaseConnection; @@ -228,11 +221,6 @@ public DatabaseConnection initCacheConn(String jdbc) throws DatabaseException { .setFlyway(flyway) .build(); - //adjusting the ehcache config - if (mainTunnel == null && cacheTunnel == null) { - //local database: turn off overflow to disk of the cache - turnOffLocalStorageForEhcacheManager("CACHE_CACHEMANAGER"); - } log.debug(CacheManager.getCacheManager("CACHE_CACHEMANAGER").getActiveConfigurationText()); return databaseConnection; @@ -290,12 +278,4 @@ private Properties buildHibernateProps(String ehcacheXmlFile) { return hibernateProps; } - - private void turnOffLocalStorageForEhcacheManager(String cacheManagerName) { - CacheManager cacheManager = CacheManager.getCacheManager(cacheManagerName); - for (String cacheName : cacheManager.getCacheNames()) { - CacheConfiguration cacheConfig = cacheManager.getCache(cacheName).getCacheConfiguration(); - cacheConfig.getPersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE); - } - } } diff --git a/Database/src/main/resources/ehcache_cache.xml b/Database/src/main/resources/ehcache_cache.xml index 8620366f0..635983ef0 100644 --- a/Database/src/main/resources/ehcache_cache.xml +++ b/Database/src/main/resources/ehcache_cache.xml @@ -38,26 +38,26 @@ diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" statistics="true"> - + - + - + - + diff --git a/Database/src/main/resources/ehcache_main.xml b/Database/src/main/resources/ehcache_main.xml index 7bb142074..ad0a69d5b 100644 --- a/Database/src/main/resources/ehcache_main.xml +++ b/Database/src/main/resources/ehcache_main.xml @@ -38,7 +38,7 @@ diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" statistics="true"> - + - + - + - + - + - + - +