CacheProvider { public <K, V> Cache<K, V> createCache(CacheType cacheType, String carbonStorePath) { if (!dictionaryCacheAlreadyExists(cacheType)) { synchronized (lock) { if (!dictionaryCacheAlreadyExists(cacheType)) { if (null == cacheTypeToLRUCacheMap.get(cacheType)) { createLRULevelCacheInstance(cacheType); } createDictionaryCacheForGivenType(cacheType, carbonStorePath); } } } return cacheTypeToCacheMap.get(cacheType); } private  CacheProvider(); static CacheProvider getInstance(); Cache<K, V> createCache(CacheType cacheType, String carbonStorePath); void dropAllCache();  }
@Test public void createCache() throws Exception { CacheProvider cacheProvider = CacheProvider.getInstance(); Cache<DictionaryColumnUniqueIdentifier, Dictionary> dictionaryCache = cacheProvider.createCache(CacheType.FORWARD_DICTIONARY, "carbonStore"); assertTrue(dictionaryCache instanceof ForwardDictionaryCache); assertFalse(dictionaryCache instanceof ReverseDictionaryCache); Cache<DictionaryColumnUniqueIdentifier, Dictionary> reverseDictionaryCache = cacheProvider.createCache(CacheType.REVERSE_DICTIONARY, "carbonStore"); assertTrue(reverseDictionaryCache instanceof ReverseDictionaryCache); assertFalse(reverseDictionaryCache instanceof ForwardDictionaryCache); }