@Override
  protected Optional<String> get(String key) {
    // search for the first value available in
    // 1. system properties
    // 2. core property from environment variable
    // 3. thread local cache (if enabled)
    // 4. db

    String value = systemProps.getProperty(key);
    if (value != null) {
      return Optional.of(value);
    }

    Optional<String> envVal = getDefinitions().getValueFromEnv(key);
    if (envVal.isPresent()) {
      return envVal;
    }

    Map<String, String> dbProps = CACHE.get();
    // caching is disabled
    if (dbProps == null) {
      return Optional.ofNullable(load(key));
    }

    String loadedValue;
    if (dbProps.containsKey(key)) {
      // property may not exist in db. In this case key is present
      // in cache but value is null
      loadedValue = dbProps.get(key);
    } else {
      // cache the effective value (null if the property
      // is not persisted)
      loadedValue = load(key);
      dbProps.put(key, loadedValue);
    }
    return Optional.ofNullable(loadedValue);
  }
@Test
  public void database_properties_are_not_cached_by_default() {
    insertPropertyIntoDb("foo", "from db");
    underTest = create(system, Collections.emptyMap());

    assertThat(underTest.get("foo")).hasValue("from db");

    deletePropertyFromDb("foo");
    // no cache, change is visible immediately
    assertThat(underTest.get("foo")).isNotPresent();
  }