Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Turn off ehcache overflow to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
schnapster committed Mar 11, 2018
1 parent 8c18534 commit b84bdb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
20 changes: 0 additions & 20 deletions Database/src/main/java/fredboat/db/DatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
8 changes: 4 additions & 4 deletions Database/src/main/resources/ehcache_cache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
statistics="true">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</defaultCache>

<cache name="search_results"
maxEntriesLocalHeap="1000"
maxEntriesLocalDisk="100000"
eternal="true">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="org.hibernate.cache.internal.StandardQueryCache"
maxEntriesLocalHeap="5"
eternal="false"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="org.hibernate.cache.spi.UpdateTimestampsCache"
maxEntriesLocalHeap="5000"
eternal="true">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>
</ehcache>
14 changes: 7 additions & 7 deletions Database/src/main/resources/ehcache_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,51 @@
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
statistics="true">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</defaultCache>

<cache name="guild_config"
maxEntriesLocalHeap="120000"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="guild_data"
maxEntriesLocalHeap="120000"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="guild_modules"
maxEntriesLocalHeap="120000"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="guild_permissions"
maxEntriesLocalHeap="120000"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="org.hibernate.cache.internal.StandardQueryCache"
maxEntriesLocalHeap="5"
eternal="false"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>

<cache name="org.hibernate.cache.spi.UpdateTimestampsCache"
maxEntriesLocalHeap="5000"
eternal="true">
<persistence strategy="localTempSwap"/>
<persistence strategy="none"/>
</cache>
</ehcache>

0 comments on commit b84bdb3

Please sign in to comment.