本文整理汇总了Java中org.apache.ibatis.cache.decorators.ScheduledCache类的典型用法代码示例。如果您正苦于以下问题:Java ScheduledCache类的具体用法?Java ScheduledCache怎么用?Java ScheduledCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScheduledCache类属于org.apache.ibatis.cache.decorators包,在下文中一共展示了ScheduledCache类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldDemonstrateEqualsAndHashCodeForVariousCacheTypes
import org.apache.ibatis.cache.decorators.ScheduledCache; //导入依赖的package包/类
@Test
public void shouldDemonstrateEqualsAndHashCodeForVariousCacheTypes() {
PerpetualCache cache = new PerpetualCache("test_cache");
assertTrue(cache.equals(cache));
assertTrue(cache.equals(new SynchronizedCache(cache)));
assertTrue(cache.equals(new SerializedCache(cache)));
assertTrue(cache.equals(new LoggingCache(cache)));
assertTrue(cache.equals(new ScheduledCache(cache)));
assertEquals(cache.hashCode(), new SynchronizedCache(cache).hashCode());
assertEquals(cache.hashCode(), new SerializedCache(cache).hashCode());
assertEquals(cache.hashCode(), new LoggingCache(cache).hashCode());
assertEquals(cache.hashCode(), new ScheduledCache(cache).hashCode());
Set<Cache> caches = new HashSet<Cache>();
caches.add(cache);
caches.add(new SynchronizedCache(cache));
caches.add(new SerializedCache(cache));
caches.add(new LoggingCache(cache));
caches.add(new ScheduledCache(cache));
assertEquals(1, caches.size());
}
示例2: test_ScheduledCache
import org.apache.ibatis.cache.decorators.ScheduledCache; //导入依赖的package包/类
@Test
public void test_ScheduledCache() throws Throwable {
ScheduledCache scheduledCache = new ScheduledCache(new PerpetualCache("test_ScheduledCache"));
scheduledCache.setClearInterval(3000);
assertThat(scheduledCache.getSize(), equalTo(0));
scheduledCache.putObject("name", "doctor");
scheduledCache.putObject("age", 6000);
assertThat(scheduledCache.getSize(), equalTo(2));
TimeUnit.SECONDS.sleep(4);
assertThat(scheduledCache.getSize(), equalTo(0));
}