public static boolean updateCache(Map<String, ?> cache, LoadbalancerRule rule) {
        if (!(rule instanceof ChangedLoadbalancerRule)) {
            return false;
        }
        ChangedLoadbalancerRule changedLoadbalancerRule = (ChangedLoadbalancerRule) rule;
        final String oldServiceName = changedLoadbalancerRule.getOldRule().getServiceName();
        final String newServiceName = changedLoadbalancerRule.getNewRule().getServiceName();
        if (Objects.isNull(oldServiceName) || Objects.isNull(newServiceName)) {
            cache.clear();
            return true;
        }
        cache.remove(oldServiceName);
        cache.remove(newServiceName);
        return true;
    }
@Test
    public void testCache() {
        // judgment type test
        final LoadbalancerRule newRule = new LoadbalancerRule(NEW_SERVICE_NAME, RULE);
        final Map<String, Object> cache = buildCache();
        Assert.assertFalse(CacheUtils.updateCache(cache, newRule));
        // test cleanup data
        final Map<String, Object> changeCache = buildCache();
        final ChangedLoadbalancerRule changedLoadbalancerRule = new ChangedLoadbalancerRule(
                new LoadbalancerRule(null, RULE), new LoadbalancerRule(OLD_SERVICE_NAME, RULE));
        Assert.assertTrue(CacheUtils.updateCache(changeCache, changedLoadbalancerRule));
        Assert.assertTrue(changeCache.isEmpty());
        // There are other service names, not just the old and the new
        final Map<String, Object> cacheMore = buildCache();
        cacheMore.put("otherService", new Object());
        final ChangedLoadbalancerRule moreChangeRule = new ChangedLoadbalancerRule(
                new LoadbalancerRule(NEW_SERVICE_NAME, RULE), new LoadbalancerRule(OLD_SERVICE_NAME, RULE));
        Assert.assertTrue(CacheUtils.updateCache(cacheMore, moreChangeRule));
        Assert.assertEquals(1, cacheMore.size());
    }