Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
@RunWith(EngroupClassRunner.class)
@ContextConfiguration(locations = { "/META-INF/spring/cache-context.xml" })
public class CacheTest {
@Autowired
protected CacheProviderFacade cacheProviderFacade;
@Test
public void testCacheConfiguration() {
Assert.assertNotNull(cacheProviderFacade);
EhCacheCachingModel model = new EhCacheCachingModel();
model.setCacheName("engroupCache");
cacheProviderFacade.putInCache("a", model, new Integer(1));
Integer fromCache = (Integer) cacheProviderFacade.getFromCache("a",
model);
Assert.assertEquals(new Integer(1), fromCache);
}
}
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation"> <value>classpath:ehcache.xml</value> </property> </bean>
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd"> <diskStore path="java.io.tmpdir" /> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> <cache name="engroupCache" maxElementsInMemory="10000" maxElementsOnDisk="10000000" eternal="false" overflowToDisk="true" diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600" memoryStoreEvictionPolicy="LFU" /> </ehcache>
Кэширование данных в приложениях с Spring 3, размещенных в AppEngine