Skip to content

Commit d1ae147

Browse files
committed
update demo with interestedKeyPrefixes
1 parent 6a6f50b commit d1ae147

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/springBootDemo/refresh/SpringBootApolloRefreshConfig.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,9 @@ public SpringBootApolloRefreshConfig(
2828
this.refreshScope = refreshScope;
2929
}
3030

31-
@ApolloConfigChangeListener({ConfigConsts.NAMESPACE_APPLICATION, "TEST1.apollo", "application.yaml"})
31+
@ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, "TEST1.apollo", "application.yaml"},
32+
interestedKeyPrefixes = {"redis.cache."})
3233
public void onChange(ConfigChangeEvent changeEvent) {
33-
boolean redisCacheKeysChanged = false;
34-
for (String changedKey : changeEvent.changedKeys()) {
35-
if (changedKey.startsWith("redis.cache")) {
36-
redisCacheKeysChanged = true;
37-
break;
38-
}
39-
}
40-
if (!redisCacheKeysChanged) {
41-
return;
42-
}
43-
4434
logger.info("before refresh {}", sampleRedisConfig.toString());
4535
refreshScope.refresh("sampleRedisConfig");
4636
logger.info("after refresh {}", sampleRedisConfig.toString());

0 commit comments

Comments
 (0)