redissonConfig = new Config(); String host = (StringUtils.isNotEmpty(cache.getHost())) ? cache.getHost() : CacheConfiguration.DEFAULT_HOST; redissonConfig.useSingleServer().setAddress(host); String codec = (StringUtils.isNotEmpty(cache.getSerialization())) ? cache.getSerialization() : CacheConfiguration.DEFAULT_SERIALIZATION; this.allowedTypesSet = new HashSet<>(Arrays.asList(cache.getAllowedTypes().split(","))); if (StringUtils.isNotEmpty(cache.getPassword())) { redissonConfig.useSingleServer().setPassword(cache.getPassword());
public boolean isActive() { return storageConfiguration.getCache().isActive() && redisState; }
public void set(String key, Query query, QueryResult queryResult) { if (isActive()) { if (queryResult.getDbTime() >= storageConfiguration.getCache().getSlowThreshold() && queryResult.getResult().size() >= storageConfiguration.getCache().getMaxResultSize()) { RMap<Integer, Map<String, Object>> map = getRedissonClient().getMap(key); Map<String, Object> record = new HashMap<>(); record.put("query", query); record.put("result", queryResult); try { map.fastPut(0, record); } catch (RedisConnectionException e) { redisState = false; queryResult.setWarningMsg("Unable to connect to Redis Cache, Please query WITHOUT Cache (Falling back to Database)"); } } } }
public StorageConfiguration(String defaultStorageEngineId, List<StorageEngineConfiguration> storageEngines) { this.defaultStorageEngineId = defaultStorageEngineId; this.storageEngines = storageEngines; this.cellbase = new CellBaseConfiguration(); this.server = new ServerConfiguration(); this.cache = new CacheConfiguration(); this.search = new SearchConfiguration(); this.clinical = new SearchConfiguration(); }