adamsaghy commented on code in PR #3041:
URL: https://github.com/apache/fineract/pull/3041#discussion_r1135410533
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/cache/service/RuntimeDelegatingCacheManager.java:
##########
@@ -43,92 +43,82 @@
* database on startup and allow user to switch implementation through UI/API
*/
@Component(value = "runtimeDelegatingCacheManager")
-public class RuntimeDelegatingCacheManager implements CacheManager {
-
- private static final Logger LOG =
LoggerFactory.getLogger(RuntimeDelegatingCacheManager.class);
-
- private final CacheManager cacheManager;
- private final CacheManager noOpCacheManager = new NoOpCacheManager();
+@RequiredArgsConstructor
+@Slf4j
+public class RuntimeDelegatingCacheManager implements CacheManager,
InitializingBean {
+
+ @Qualifier("ehCacheManager")
+ private final CacheManager ehCacheManager;
+ @Qualifier("defaultCacheManager")
+ private final CacheManager defaultCacheManager;
private CacheManager currentCacheManager;
- @Autowired
- public RuntimeDelegatingCacheManager(final JCacheCacheManager
cacheManager) {
- this.cacheManager = cacheManager;
- this.currentCacheManager = this.noOpCacheManager;
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ currentCacheManager = defaultCacheManager;
}
@Override
public Cache getCache(final String name) {
- return this.currentCacheManager.getCache(name);
+ return currentCacheManager.getCache(name);
}
@Override
public Collection<String> getCacheNames() {
- return this.currentCacheManager.getCacheNames();
+ return currentCacheManager.getCacheNames();
}
public Collection<CacheData> retrieveAll() {
- final boolean noCacheEnabled = this.currentCacheManager instanceof
NoOpCacheManager;
- final boolean ehcacheEnabled = this.currentCacheManager instanceof
JCacheCacheManager;
-
- // final boolean distributedCacheEnabled = false;
+ final boolean noCacheEnabled = currentCacheManager ==
defaultCacheManager;
+ final boolean ehCacheEnabled = currentCacheManager == ehCacheManager;
final EnumOptionData noCacheType =
CacheEnumerations.cacheType(CacheType.NO_CACHE);
final EnumOptionData singleNodeCacheType =
CacheEnumerations.cacheType(CacheType.SINGLE_NODE);
- // final EnumOptionData multiNodeCacheType =
- // CacheEnumerations.cacheType(CacheType.MULTI_NODE);
final CacheData noCache = CacheData.instance(noCacheType,
noCacheEnabled);
- final CacheData singleNodeCache =
CacheData.instance(singleNodeCacheType, ehcacheEnabled);
- // final CacheData distributedCache =
- // CacheData.instance(multiNodeCacheType, distributedCacheEnabled);
+ final CacheData singleNodeCache =
CacheData.instance(singleNodeCacheType, ehCacheEnabled);
- final Collection<CacheData> caches = Arrays.asList(noCache,
singleNodeCache);
- return caches;
+ return Arrays.asList(noCache, singleNodeCache);
}
public Map<String, Object> switchToCache(final boolean ehcacheEnabled,
final CacheType toCacheType) {
Review Comment:
For multi node cache we should defo use Redis and we might need it in the
future
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]