Challenge Overview
Recently, All internal system of TopCoder are using TC Cache which is using JBoss Cache as caching service, but this is outdated and keeps on causing problems in production.
What TopCoder would like to do is to move ahead with a more mature cache service, such as for example like Redis.
In order to support new implementation, without interfering the usage, we found there are several limitations in current tc_cache, like
1. the JBossCacheClient is hardcoded in CacheClientFactory class.
2. AddressFactory class can not support new Addresses.
For this challenge, we'd like you refactor the TC Cache module,
1. make it easy to support new implementation of cache client,
2. make it easy to switch from different cache client without change source code, make it easily controlled by cache.properties (sample in conf directory).
3. with current cache.properties file, we should make it default to use JBossCache, so if you want to add more configuration, make the default value to use jboss cache.
Sample External Usage Code
boolean hasCacheConnection = true; CacheAddress address = AddressFactory.create(request, maxAge); Map<String, ResultSetContainer> map = null; DataRetrieverInt dr = null; CacheClient cc = null; try { cc = CacheClientFactory.create(); map = (Map<String, ResultSetContainer>) (cc.get(address)); } catch (Exception e) { if (log.isDebugEnabled()) { log.error("UNABLE TO ESTABLISH A CONNECTION TO THE CACHE: ", e); } else { log.error("UNABLE TO ESTABLISH A CONNECTION TO THE CACHE: " + e.getMessage()); } hasCacheConnection = false; }
Final Submission Guidelines
- changed files
- New usage guide if there are changes in cache.properties.