use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.
the class FifoCacheTest method shouldRemoveFirstItemInBeyondFiveEntries.
@Test
public void shouldRemoveFirstItemInBeyondFiveEntries() {
FifoCache cache = new FifoCache(new PerpetualCache("default"));
cache.setSize(5);
for (int i = 0; i < 5; i++) {
cache.putObject(i, i);
}
assertEquals(0, cache.getObject(0));
cache.putObject(5, 5);
assertNull(cache.getObject(0));
assertEquals(5, cache.getSize());
}
use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.
the class LruCacheTest method shouldRemoveItemOnDemand.
@Test
public void shouldRemoveItemOnDemand() {
Cache cache = new LruCache(new PerpetualCache("default"));
cache.putObject(0, 0);
assertNotNull(cache.getObject(0));
cache.removeObject(0);
assertNull(cache.getObject(0));
}
use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.
the class LruCacheTest method shouldRemoveLeastRecentlyUsedItemInBeyondFiveEntries.
@Test
public void shouldRemoveLeastRecentlyUsedItemInBeyondFiveEntries() {
LruCache cache = new LruCache(new PerpetualCache("default"));
cache.setSize(5);
for (int i = 0; i < 5; i++) {
cache.putObject(i, i);
}
assertEquals(0, cache.getObject(0));
cache.putObject(5, 5);
assertNull(cache.getObject(1));
assertEquals(5, cache.getSize());
}
use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.
the class PerpetualCacheTest method shouldDemonstrateHowAllObjectsAreKept.
@Test
public void shouldDemonstrateHowAllObjectsAreKept() {
Cache cache = new PerpetualCache("default");
cache = new SynchronizedCache(cache);
for (int i = 0; i < 100000; i++) {
cache.putObject(i, i);
assertEquals(i, cache.getObject(i));
}
assertEquals(100000, cache.getSize());
}
use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.
the class PerpetualCacheTest method shouldDemonstrateCopiesAreEqual.
@Test
public void shouldDemonstrateCopiesAreEqual() {
Cache cache = new PerpetualCache("default");
cache = new SerializedCache(cache);
for (int i = 0; i < 1000; i++) {
cache.putObject(i, i);
assertEquals(i, cache.getObject(i));
}
}
Aggregations