使用ClientRegionShortcut.PROXY以编程方式控制Gemfire区域的入门时间

是否可以将ClientCacheClientRegionShortcut.PROXY一起使用以及对入口TTL设置(即服务器中存在的条目)的编程控制?

我看到条目到期ttl设置与ClientRegionShortcut.CACHING_PROXY_HEAP_LRU一起正常工作。 在这种情况下,我可以看到在配置的超时后服务器中的条目无效,以秒为单位,但ClientRegionShortcut.PROXY设置不是这种情况。

是否无法动态控制ClientCache的entry-ttl设置?

code / config下面使用ClientRegionShortcut.CACHING_PROXY_HEAP_LRU使用ClientRegionShortcut.PROXY

Gemfire version is : 9.0.x pom如下所示

   4.0.0 com.springboot.gemfire app 0.0.1-SNAPSHOT jar MyGemfireProject Test Concepts project for Spring Boot with Gemfire  org.springframework.boot spring-boot-starter-parent 1.5.3.RELEASE     UTF-8 UTF-8 1.8    org.springframework.boot spring-boot-starter-web   org.springframework.boot spring-boot-starter-actuator   org.springframework.boot spring-boot-starter-cache   org.springframework.data spring-data-gemfire   org.springframework.boot spring-boot-starter-test test   org.modelmapper modelmapper 0.7.4   com.gemstone.gemfire gemfire 8.2.6     org.springframework.maven.milestone Spring Maven Milestone Repository http://repo.springsource.org/libs-milestone false      org.springframework.boot spring-boot-maven-plugin    

Gemfire配置如下所示:

 import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; import org.springframework.data.gemfire.ExpirationActionType; import org.springframework.data.gemfire.support.GemfireCacheManager; import com.gemstone.gemfire.cache.AttributesMutator; import com.gemstone.gemfire.cache.ExpirationAttributes; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.ClientRegionFactory; import com.gemstone.gemfire.cache.client.ClientRegionShortcut; import com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer; /** * The Class NativeGemfireConfig. */ @Configuration @Profile("local") public class NativeGemfireConfig { /** The Constant log. */ private static final Logger log = LoggerFactory.getLogger(NativeGemfireConfig.class); protected static final String DEFAULT_MANAGER_PORT = "1099"; /** The region name. */ @Value("${spring.gemfire.region.name:test}") private String regionName; @Bean Properties gemfireProperties(@Value("${spring.gemfire.log-level}") String logLevel, @Value("${spring.gemfire.mcast-port}") String mcastPort, @Value("${spring.gemfire.jmx-manager}") String jmxManager, @Value("${spring.gemfire.jmx-manager-start}") String jmxManagerStart, @Value("${spring.gemfire.username}") String gemfireuser, @Value("${spring.gemfire.password}") String gemfirepassword) { Properties gemfireProperties = new Properties(); gemfireProperties.setProperty("name", NativeGemfireConfig.class.getSimpleName()); gemfireProperties.setProperty("mcast-port", mcastPort); gemfireProperties.setProperty("log-level", logLevel); gemfireProperties.setProperty("jmx-manager", jmxManager); gemfireProperties.setProperty("jmx-manager-port", DEFAULT_MANAGER_PORT); gemfireProperties.setProperty("jmx-manager-start", jmxManagerStart); gemfireProperties.setProperty("security-username", gemfireuser); gemfireProperties.setProperty("security-password", gemfirepassword); gemfireProperties.setProperty("security-client-auth-init", "com.springboot.gemfire.config.GemFireAuthInitializor.create"); return gemfireProperties; } @Bean @Primary ReflectionBasedAutoSerializer reflectionBasedAutoSerializer() { return new ReflectionBasedAutoSerializer("com.springboot.gemfire.model.*"); } @Bean @Primary ClientCacheFactory clientCacheFactory(@Value("${spring.gemfire.host}") String gemFirehost, @Value("${spring.gemfire.port}") int gemfirePort, Properties gemfireProperties, ReflectionBasedAutoSerializer reflectionBasedAutoSerializer) { ClientCacheFactory cachefactory = new ClientCacheFactory(gemfireProperties); cachefactory.addPoolLocator(gemFirehost, gemfirePort); cachefactory.setPdxSerializer(reflectionBasedAutoSerializer); cachefactory.setPdxReadSerialized(false); cachefactory.setPdxIgnoreUnreadFields(true); return cachefactory; } /** * Gemfire cache. * * @return the client cache */ @Bean @Primary ClientCache gemfireCache(@Qualifier("gemfireProperties")Properties gemfireProperties, ClientCacheFactory clientCacheFactory, @Value("${spring.gemfire.username}") String gemfireuser, @Value("${spring.gemfire.password}") String gemfirepassword) { return clientCacheFactory .set("security-username", gemfireuser) .set("security-password", gemfirepassword) .set("security-client-auth-init", "com.springboot.gemfire.config.GemFireAuthInitializor.create") .create(); } @Bean public ExpirationAttributes entryTtlExpirationAttributes( @Value("${spring.gemfire.region.expiration.entry.ttl.timeout}") int timeout) { return new ExpirationAttributes(timeout, ExpirationActionType.INVALIDATE.getExpirationAction()); } @Bean @Primary Region tokenRegionBean(ClientCache gemfireCache, @Qualifier("entryTtlExpirationAttributes") ExpirationAttributes expirationAttributes) { ClientRegionFactory tokenRegionFactory = gemfireCache .createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU); tokenRegionFactory.setStatisticsEnabled(true); Region region = tokenRegionFactory.create(regionName); AttributesMutator mutator = region.getAttributesMutator(); mutator.setEntryTimeToLive(expirationAttributes); return region; } @Bean GemfireCacheManager cacheManager(ClientCache gemfireCache) { GemfireCacheManager cacheManager = new GemfireCacheManager(); cacheManager.setCache(gemfireCache); return cacheManager; } /** * Gets the region name. * * @return the region name */ public String getRegionName() { return regionName; } /** * Sets the region name. * * @param regionName * the new region name */ public void setRegionName(final String regionName) { this.regionName = regionName; } } 

application-local.yml相关条目是

 spring: gemfire: log-level: config region: name: myRegion expiration: entry: ttl: timeout: 120 host: remote-server port: port-to-connect mcast-port: 0 jmx-manager: false jmx-manager-start: false username: uname password: passwd