FINERACT-1022: Fixing ehcache 3

This commit is contained in:
Petri Tuomola
2020-06-30 03:10:11 +01:00
committed by Yemdjih Kaze Nasser
parent da978a37aa
commit 7d2c3ec417
7 changed files with 41 additions and 35 deletions
@@ -27,6 +27,8 @@ import org.apache.fineract.infrastructure.cache.CacheEnumerations;
import org.apache.fineract.infrastructure.cache.data.CacheData;
import org.apache.fineract.infrastructure.cache.domain.CacheType;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
@@ -43,6 +45,8 @@ import org.springframework.stereotype.Component;
@Component(value = "runtimeDelegatingCacheManager")
public class RuntimeDelegatingCacheManager implements CacheManager {
private static final Logger LOG = LoggerFactory.getLogger(RuntimeDelegatingCacheManager.class);
private final JCacheCacheManager jcacheCacheManager;
private final CacheManager noOpCacheManager = new NoOpCacheManager();
private CacheManager currentCacheManager;
@@ -106,6 +110,10 @@ public class RuntimeDelegatingCacheManager implements CacheManager {
clearEhCache();
}
this.currentCacheManager = this.jcacheCacheManager;
if (this.currentCacheManager.getCacheNames().size() == 0) {
LOG.error("No caches configured for activated CacheManager {}", this.currentCacheManager);
}
break;
case MULTI_NODE:
if (!distributedCacheEnabled) {
@@ -27,8 +27,8 @@ import org.springframework.data.repository.query.Param;
public interface ClientAddressRepository extends JpaRepository<ClientAddress, Long>, JpaSpecificationExecutor<ClientAddress> {
@Query("SELECT clientAddress FROM ClientAddress clientAddress WHERE clientAddress.client.id = :clientId AND clientAddress.addressType = :addressType AND clientAddress.isActive = :isActive ")
ClientAddress findByClientIdAndAddressTypeAndIsActive(@Param("clientId") final long clientId, final CodeValue addressType,
@Param("isActive") final boolean isActive);
ClientAddress findByClientIdAndAddressTypeAndIsActive(@Param("clientId") final long clientId,
@Param("addressType") final CodeValue addressType, @Param("isActive") final boolean isActive);
@Query("SELECT clientAddress FROM ClientAddress clientAddress WHERE clientAddress.client.id = :clientId AND clientAddress.address.id = :addressId ")
ClientAddress findByClientIdAndAddressId(@Param("clientId") final long clientId, @Param("addressId") final long addressId);
@@ -34,6 +34,6 @@
p:cacheManager-ref="ehcacheInstance" />
<bean id="ehcacheInstance"
class="org.springframework.cache.jcache.JCacheManagerFactoryBean"/>
class="org.springframework.cache.jcache.JCacheManagerFactoryBean" p:cacheManagerUri="classpath:/META-INF/spring/ehcache.xml"/>
</beans>
@@ -24,33 +24,30 @@
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.7.xsd">
<defaultCache eternal="true" maxEntriesLocalHeap="100"
overflowToDisk="false" />
<cache-template name="defaultTemplate">
<expiry>
<none/>
</expiry>
<heap unit="entries">
10000
</heap>
</cache-template>
<cache name="users" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="usersByUsername" maxEntriesLocalHeap="10000"
eternal="true" overflowToDisk="false" />
<cache name="tenantsById" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="offices" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="officesForDropdown" maxEntriesLocalHeap="10000"
eternal="true" overflowToDisk="false" />
<cache name="officesById" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="charges" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="funds" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="code_values" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="codes" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="hooks" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache name="userTFAccessToken" maxEntriesLocalHeap="10000"
overflowToDisk="false" timeToIdleSeconds="7200" />
<cache name="tfConfig" maxEntriesLocalHeap="10000" eternal="true"
overflowToDisk="false" />
<cache alias="users" uses-template="defaultTemplate"/>
<cache alias="usersByUsername" uses-template="defaultTemplate"/>
<cache alias="tenantsById" uses-template="defaultTemplate"/>
<cache alias="offices" uses-template="defaultTemplate"/>
<cache alias="officesForDropdown" uses-template="defaultTemplate"/>
<cache alias="officesById" uses-template="defaultTemplate"/>
<cache alias="charges" uses-template="defaultTemplate"/>
<cache alias="funds" uses-template="defaultTemplate"/>
<cache alias="code_values" uses-template="defaultTemplate"/>
<cache alias="codes" uses-template="defaultTemplate"/>
<cache alias="hooks" uses-template="defaultTemplate"/>
<cache alias="tfConfig" uses-template="defaultTemplate"/>
<cache alias="userTFAccessToken" uses-template="defaultTemplate">
<expiry>
<tti unit="seconds">7200</tti>
</expiry>
</cache>
</config>