/** * Builds and returns an instance of local signature cache. * * @return the instance of local signature cache */ private DataCache<?> buildLocalSignatureCache() { if (BardFeatureFlag.DRUID_CACHE_V2.isSet()) { LOG.warn("Cache V2 feature flag is deprecated, " + "use the new configuration parameter to set desired caching strategy" ); } try { MemTupleDataCache<Long, String> cache = new MemTupleDataCache<>(); LOG.info("MemcachedClient Version 2 started {}", cache); return cache; } catch (IOException e) { LOG.error("MemcachedClient Version 2 failed to start {}", e); throw new IllegalStateException(e); } }
/** * Builds and returns an instance of TTL cache. * * @return the instance of TTL cache */ private DataCache<?> buildTtlCache() { if (BardFeatureFlag.DRUID_CACHE.isSet()) { LOG.warn("Cache V1 feature flag is deprecated, " + "use the new configuration parameter to set desired caching strategy" ); } try { DataCache<String> cache = new HashDataCache<>(new MemDataCache<HashDataCache.Pair<String, String>>()); LOG.info("MemcachedClient started {}", cache); return cache; } catch (IOException e) { LOG.error("MemcachedClient failed to start {}", e); throw new IllegalStateException(e); } }
@Override public boolean isOn() { if (on == null) { // TODO: Remove this if conditional after cache V1 & V2 configuration flags are removed if (BardFeatureFlag.DRUID_CACHE.isSet() || BardFeatureFlag.DRUID_CACHE_V2.isSet()) { // no cache if (this.value.equals("NoCache")) { return ! BardFeatureFlag.DRUID_CACHE.isOn(); } return (this.value.equals("Ttl") && !BardFeatureFlag.DRUID_CACHE_V2.isOn() && BardFeatureFlag.DRUID_CACHE.isOn() ) || (this.value.equals("LocalSignature") && BardFeatureFlag.DRUID_CACHE.isOn() && BardFeatureFlag.DRUID_CACHE_V2.isOn()); } on = value.equalsIgnoreCase(SYSTEM_CONFIG.getStringProperty( SYSTEM_CONFIG.getPackageVariableName("query_response_caching_strategy"), "NoCache") ); } return on; }