我试图在我的应用中使用gemfire进行缓存。这是我的财产:
<context:component-scan base-package="my-base-package"/>
<context:annotation-config/>
<!-- Gemfire transation manager -->
<gfe:transaction-manager id="transactionManager" cache-ref="propertyGemfireCache"/>
<!-- Gemfire properties -->
<util:properties id="gemfire-props"
location="classpath:conf/environments/gemfire.properties"/>
<!-- Gemfire Client cache -->
<gfe:client-cache id="propertyGemfireCache" properties-ref="gemfire-props"
pool-name="gemfire-pool" pdx-serializer-ref="pdxSerializer" pdx-persistent="true"/>
<!-- Gemfire PDX serializer -->
<bean id="pdxSerializer" class="com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer">
<property name="serializableClasses">
<list>
<value>com\.acmecorp\.enterprise\.property\..*,java\.util\..*</value>
</list>
</property>
</bean>
<!-- Gemfire connection pool -->
<bean id="gemfire-pool" class="org.springframework.data.gemfire.client.PoolFactoryBean">
<property name="subscriptionEnabled" value="true"/>
<property name="freeConnectionTimeout" value="60000"/>
<property name="prSingleHopEnabled" value="true"/>
<property name="locators" ref="gemfireLocators"/>
</bean>
<bean id="gemfireCacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager"
p:cache-ref="propertyGemfireCache"/>
<gfe:client-region id="myRegion" name="${cache.region.name}" statistics="true"
cache-ref="propertyGemfireCache" shortcut="LOCAL">
<gfe:region-ttl timeout="86400"/>
</gfe:client-region>
<bean id="myTemplate" class="org.springframework.data.gemfire.GemfireTemplate">
<property name="region" ref="myRegion"/>
</bean>
<cache:advice id="myAdvice" cache-manager="gemfireCacheManager">
<cache:caching>
<cache:cacheable cache="myRegion" method="getSomeData"
key="''+#data"/>
</cache:caching>
</cache:advice>
<aop:config>
<aop:advisor advice-ref="myAdvice"
pointcut="execution( * *..ServiceImpl.getData(..)) and within(another-my-package.service.impl..*)"/>
</aop:config>
属性cache.region.name
等于correct_region_name
。
如果我运行我的应用程序,我将收到如下错误:
找不到名为&#39; myRegion&#39;的缓存for CacheableOperation [] caches = [myRegion]
但是,如果我取代&#34; myRegion&#34;使用正确的区域correct_region_name
。所以它看起来像这样:
<cache:cacheable cache="correct_region_name" method="getSomeData"
key="''+#data"/>
一切都会完美运作,但我并不需要。任何帮助?
答案 0 :(得分:1)
我认为在client-cache配置中使用属性占位符$ {cache.region.name}以及Spring解决这些问题的顺序可能存在问题。如果你在那里硬编码区域名称,它会起作用吗?
答案 1 :(得分:1)
Spring(Data GemFire) looks up Cache
&#34; name&#34;在Spring's Cache Abstraction中的Cache
not necessarily the bean ID,set here,implements,RegionLookupFactoryBean
BeanNameAware {{ 3}})。
你可以试试......
<cache:cacheable cache="${gemfire.region.name}" method="getSomeData" key="''+#data"/>