mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2352 - Rename ServerCache methods with deprecation
This commit is contained in:
@@ -242,7 +242,7 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
protected <T> ServerCacheStatistics getBeanCacheStats(Class<T> cls, boolean reset) {
|
||||
return server().cacheManager().getBeanCache(cls).getStatistics(reset);
|
||||
return server().cacheManager().beanCache(cls).statistics(reset);
|
||||
}
|
||||
|
||||
protected Platform platform() {
|
||||
|
||||
@@ -18,28 +18,28 @@ public class ServerCacheManagerTest {
|
||||
assertTrue(region.isEnabled());
|
||||
}
|
||||
|
||||
cacheManager.setEnabledRegions("r0,doesNotExist");
|
||||
assertThat(cacheManager.getRegion("email").isEnabled()).isFalse();
|
||||
assertThat(cacheManager.getRegion("r0").isEnabled()).isTrue();
|
||||
cacheManager.enabledRegions("r0,doesNotExist");
|
||||
assertThat(cacheManager.region("email").isEnabled()).isFalse();
|
||||
assertThat(cacheManager.region("r0").isEnabled()).isTrue();
|
||||
|
||||
cacheManager.setEnabledRegions("r0");
|
||||
assertThat(cacheManager.getRegion("email").isEnabled()).isFalse();
|
||||
assertThat(cacheManager.getRegion("r0").isEnabled()).isTrue();
|
||||
cacheManager.enabledRegions("r0");
|
||||
assertThat(cacheManager.region("email").isEnabled()).isFalse();
|
||||
assertThat(cacheManager.region("r0").isEnabled()).isTrue();
|
||||
|
||||
cacheManager.setEnabledRegions(null);
|
||||
assertThat(cacheManager.getRegion("email").isEnabled()).isFalse();
|
||||
assertThat(cacheManager.getRegion("r0").isEnabled()).isTrue();
|
||||
cacheManager.enabledRegions(null);
|
||||
assertThat(cacheManager.region("email").isEnabled()).isFalse();
|
||||
assertThat(cacheManager.region("r0").isEnabled()).isTrue();
|
||||
|
||||
cacheManager.setEnabledRegions("email");
|
||||
assertThat(cacheManager.getRegion("email").isEnabled()).isTrue();
|
||||
assertThat(cacheManager.getRegion("r0").isEnabled()).isFalse();
|
||||
cacheManager.enabledRegions("email");
|
||||
assertThat(cacheManager.region("email").isEnabled()).isTrue();
|
||||
assertThat(cacheManager.region("r0").isEnabled()).isFalse();
|
||||
|
||||
cacheManager.setAllRegionsEnabled(false);
|
||||
cacheManager.allRegionsEnabled(false);
|
||||
for (ServerCacheRegion region : cacheManager.allRegions()) {
|
||||
assertFalse(region.isEnabled());
|
||||
}
|
||||
|
||||
cacheManager.setAllRegionsEnabled(true);
|
||||
cacheManager.allRegionsEnabled(true);
|
||||
for (ServerCacheRegion region : cacheManager.allRegions()) {
|
||||
assertTrue(region.isEnabled());
|
||||
}
|
||||
|
||||
+4
-4
@@ -26,20 +26,20 @@ public class DefaultServerCacheTest {
|
||||
public void testGetHitRatio() {
|
||||
|
||||
DefaultServerCache cache = createCache();
|
||||
assertEquals(0, cache.getHitRatio());
|
||||
assertEquals(0, cache.hitRatio());
|
||||
assertEquals(0, cache.getHitCount());
|
||||
assertEquals(0, cache.getMissCount());
|
||||
cache.put("A", "A");
|
||||
cache.get("A");
|
||||
assertEquals(100, cache.getHitRatio());
|
||||
assertEquals(100, cache.hitRatio());
|
||||
assertEquals(1, cache.getHitCount());
|
||||
assertEquals(0, cache.getMissCount());
|
||||
cache.get("B");
|
||||
assertEquals(50, cache.getHitRatio());
|
||||
assertEquals(50, cache.hitRatio());
|
||||
assertEquals(1, cache.getMissCount());
|
||||
cache.get("B");
|
||||
cache.get("B");
|
||||
assertEquals(25, cache.getHitRatio());
|
||||
assertEquals(25, cache.hitRatio());
|
||||
assertEquals(3, cache.getMissCount());
|
||||
assertEquals(1, cache.getHitCount());
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -40,7 +40,7 @@ public class DefaultServerCache_RunEvictionTest {
|
||||
for (int i = 0; i < 15; i++) {
|
||||
doStuff();
|
||||
cache.runEviction();
|
||||
ServerCacheStatistics statistics = cache.getStatistics(true);
|
||||
ServerCacheStatistics statistics = cache.statistics(true);
|
||||
System.out.println(statistics);
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
+8
-8
@@ -44,18 +44,18 @@ public class JdbcTransactionTest {
|
||||
public void skipCacheAfterSave() {
|
||||
|
||||
ServerCacheManager cacheManager = DB.getDefault().cacheManager();
|
||||
ServerCache customerBeanCache = cacheManager.getBeanCache(Customer.class);
|
||||
ServerCache contactNatKeyCache = cacheManager.getNaturalKeyCache(Contact.class);
|
||||
ServerCache customerBeanCache = cacheManager.beanCache(Customer.class);
|
||||
ServerCache contactNatKeyCache = cacheManager.naturalKeyCache(Contact.class);
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
customerBeanCache.getStatistics(true);
|
||||
contactNatKeyCache.getStatistics(true);
|
||||
customerBeanCache.statistics(true);
|
||||
contactNatKeyCache.statistics(true);
|
||||
|
||||
Customer.find.byId(19898989);
|
||||
DB.find(Contact.class).where().eq("email", "junk@foo.com").findOne();
|
||||
|
||||
assertThat(customerBeanCache.getStatistics(true).getMissCount()).isEqualTo(1);
|
||||
assertThat(contactNatKeyCache.getStatistics(true).getMissCount()).isEqualTo(1);
|
||||
assertThat(customerBeanCache.statistics(true).getMissCount()).isEqualTo(1);
|
||||
assertThat(contactNatKeyCache.statistics(true).getMissCount()).isEqualTo(1);
|
||||
|
||||
EBasic basic = new EBasic("b1");
|
||||
DB.save(basic);
|
||||
@@ -64,8 +64,8 @@ public class JdbcTransactionTest {
|
||||
Customer.find.byId(29898989);
|
||||
DB.find(Contact.class).where().eq("email", "junk2@foo.com").findOne();
|
||||
|
||||
assertThat(customerBeanCache.getStatistics(true).getMissCount()).isEqualTo(0);
|
||||
assertThat(contactNatKeyCache.getStatistics(true).getMissCount()).isEqualTo(0);
|
||||
assertThat(customerBeanCache.statistics(true).getMissCount()).isEqualTo(0);
|
||||
assertThat(contactNatKeyCache.statistics(true).getMissCount()).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TestBeanReferenceRefresh extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
ServerCache beanCache = Ebean.getServerCacheManager().getBeanCache(Order.class);
|
||||
ServerCache beanCache = Ebean.getServerCacheManager().beanCache(Order.class);
|
||||
beanCache.clear();
|
||||
|
||||
Order order = Ebean.getReference(Order.class, 1);
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TestQueryWithCache extends BaseTestCase {
|
||||
ServerCacheManager serverCacheManager = server.cacheManager();
|
||||
serverCacheManager.clear(Country.class);
|
||||
|
||||
ServerCache beanCache = serverCacheManager.getBeanCache(Country.class);
|
||||
ServerCache beanCache = serverCacheManager.beanCache(Country.class);
|
||||
assertEquals(0, beanCache.size());
|
||||
|
||||
Country nz1 = Ebean.getReference(Country.class, "NZ");
|
||||
|
||||
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class TestBatchLazyWithCacheHits extends BaseTestCase {
|
||||
|
||||
private final ServerCache beanCache = server().cacheManager().getBeanCache(UUOne.class);
|
||||
private final ServerCache beanCache = server().cacheManager().beanCache(UUOne.class);
|
||||
|
||||
private UUOne insert(String name) {
|
||||
UUOne one = new UUOne();
|
||||
@@ -61,19 +61,19 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase {
|
||||
platformAssertIn(sql.get(1), "from uuone t0 where t0.id");
|
||||
|
||||
// not lazy loading into bean cache
|
||||
final ServerCacheStatistics stats = beanCache.getStatistics(true);
|
||||
final ServerCacheStatistics stats = beanCache.statistics(true);
|
||||
assertThat(stats.getHitCount()).isEqualTo(10);
|
||||
assertThat(stats.getSize()).isEqualTo(10);
|
||||
}
|
||||
|
||||
private void assertBeanCacheHits(int hits) {
|
||||
ServerCacheStatistics statistics = beanCache.getStatistics(true);
|
||||
ServerCacheStatistics statistics = beanCache.statistics(true);
|
||||
assertEquals(statistics.getHitCount(), hits);
|
||||
}
|
||||
|
||||
private void clearCacheAndStatistics() {
|
||||
beanCache.clear();
|
||||
beanCache.getStatistics(true);
|
||||
beanCache.statistics(true);
|
||||
}
|
||||
|
||||
private List<UUOne> insertData() {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class TestQueryJoin extends BaseTestCase {
|
||||
|
||||
// Need to make sure the customer cache is cleared for the later
|
||||
// asserts on the lazy loading
|
||||
ServerCache custCache = Ebean.getServerCacheManager().getBeanCache(Customer.class);
|
||||
ServerCache custCache = Ebean.getServerCacheManager().beanCache(Customer.class);
|
||||
custCache.clear();
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class).select("status")
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TestBeanCache.class);
|
||||
|
||||
private final ServerCache beanCache = DB.getDefault().cacheManager().getBeanCache(OCachedBean.class);
|
||||
private final ServerCache beanCache = DB.getDefault().cacheManager().beanCache(OCachedBean.class);
|
||||
|
||||
@Test
|
||||
public void findById_when_idTypeConverted() {
|
||||
@@ -61,7 +61,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
List<Long> ids = beans.stream().map(OCachedBean::getId).collect(Collectors.toList());
|
||||
|
||||
beanCache.clear();
|
||||
beanCache.getStatistics(true);
|
||||
beanCache.statistics(true);
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
|
||||
// skipCacheAfterWrite set after this write ...
|
||||
@@ -77,7 +77,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
ServerCacheStatistics statistics = beanCache.getStatistics(true);
|
||||
ServerCacheStatistics statistics = beanCache.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(0);
|
||||
assertThat(statistics.getMissCount()).isEqualTo(2);
|
||||
assertThat(statistics.getPutCount()).isEqualTo(2);
|
||||
@@ -90,7 +90,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
List<Long> ids = beans.stream().map(OCachedBean::getId).collect(Collectors.toList());
|
||||
|
||||
beanCache.clear();
|
||||
beanCache.getStatistics(true);
|
||||
beanCache.statistics(true);
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -158,7 +158,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
}
|
||||
|
||||
private void assertBeanCacheHitMiss(int hitCount, int missCount) {
|
||||
ServerCacheStatistics statistics = beanCache.getStatistics(true);
|
||||
ServerCacheStatistics statistics = beanCache.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(hitCount);
|
||||
assertThat(statistics.getMissCount()).isEqualTo(missCount);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
|
||||
private final ServerCache customerBeanCache = server().cacheManager().getBeanCache(Customer.class);
|
||||
private final ServerCache customerBeanCache = server().cacheManager().beanCache(Customer.class);
|
||||
|
||||
@Test
|
||||
public void fetchCache_when_allHits() {
|
||||
initDataClearCache();
|
||||
loadCustomerBeanCache();
|
||||
customerBeanCache.getStatistics(true);
|
||||
customerBeanCache.statistics(true);
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
final List<String> sql0 = LoggedSqlCollector.current();
|
||||
assertThat(sql0).hasSize(1);
|
||||
|
||||
final ServerCacheStatistics statistics = customerBeanCache.getStatistics(true);
|
||||
final ServerCacheStatistics statistics = customerBeanCache.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(2);
|
||||
|
||||
assertThat(trimSql(sql0.get(0))).doesNotContain("t1.status");
|
||||
@@ -64,7 +64,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
.where().lt("id", 2)
|
||||
.findList();
|
||||
|
||||
customerBeanCache.getStatistics(true);
|
||||
customerBeanCache.statistics(true);
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
assertThat(sql0.get(0)).contains(" from o_order ");
|
||||
assertThat(sql0.get(1)).contains(" from o_customer t0 where t0.id ");
|
||||
|
||||
final ServerCacheStatistics statistics = customerBeanCache.getStatistics(true);
|
||||
final ServerCacheStatistics statistics = customerBeanCache.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(1);
|
||||
|
||||
for (Order order : orders) {
|
||||
@@ -98,7 +98,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
.select("name") // not included status in bean cache
|
||||
.findList();
|
||||
|
||||
customerBeanCache.getStatistics(true);
|
||||
customerBeanCache.statistics(true);
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -112,7 +112,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
final List<String> sql0 = LoggedSqlCollector.current();
|
||||
assertThat(sql0).hasSize(1);
|
||||
|
||||
final ServerCacheStatistics statistics = customerBeanCache.getStatistics(true);
|
||||
final ServerCacheStatistics statistics = customerBeanCache.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(2);
|
||||
|
||||
assertThat(trimSql(sql0.get(0))).doesNotContain("t1.status");
|
||||
@@ -129,7 +129,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
assertThat(sql1.get(0)).contains(" from o_customer t0 ");
|
||||
|
||||
// assert we didn't hit the L2 bean cache the second time around
|
||||
final ServerCacheStatistics statistics1 = customerBeanCache.getStatistics(true);
|
||||
final ServerCacheStatistics statistics1 = customerBeanCache.statistics(true);
|
||||
assertThat(statistics1.getHitCount()).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
public void fetchGroup_fetchCache() {
|
||||
initDataClearCache();
|
||||
loadCustomerBeanCache();
|
||||
customerBeanCache.getStatistics(true);
|
||||
customerBeanCache.statistics(true);
|
||||
|
||||
List<Order> orders = DB.find(Order.class)
|
||||
.select(fgBasic)
|
||||
@@ -149,7 +149,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
|
||||
assertThat(orders).isNotEmpty();
|
||||
|
||||
final ServerCacheStatistics statistics1 = customerBeanCache.getStatistics(true);
|
||||
final ServerCacheStatistics statistics1 = customerBeanCache.statistics(true);
|
||||
assertThat(statistics1.getHitCount()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
@Test
|
||||
public void fetchGroup_fetchCache_partial() {
|
||||
initDataClearCache();
|
||||
customerBeanCache.getStatistics(true);
|
||||
customerBeanCache.statistics(true);
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -170,7 +170,7 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||
|
||||
assertThat(orders).isNotEmpty();
|
||||
|
||||
final ServerCacheStatistics statistics1 = customerBeanCache.getStatistics(true);
|
||||
final ServerCacheStatistics statistics1 = customerBeanCache.statistics(true);
|
||||
assertThat(statistics1.getMissCount()).isEqualTo(2);
|
||||
|
||||
final List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
@@ -17,16 +17,16 @@ public class TestCacheBasic extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Ebean.getServerCacheManager().clear(Country.class);
|
||||
ServerCache countryCache = Ebean.getServerCacheManager().getBeanCache(Country.class);
|
||||
ServerCache countryCache = Ebean.getServerCacheManager().beanCache(Country.class);
|
||||
|
||||
loadCountryCache();
|
||||
Assert.assertTrue(countryCache.size() > 0);
|
||||
|
||||
// reset the statistics
|
||||
countryCache.getStatistics(true);
|
||||
countryCache.statistics(true);
|
||||
|
||||
Country c0 = Ebean.getReference(Country.class, "NZ");
|
||||
ServerCacheStatistics statistics = countryCache.getStatistics(false);
|
||||
ServerCacheStatistics statistics = countryCache.statistics(false);
|
||||
long hc = statistics.getHitCount();
|
||||
Assert.assertEquals(1, hc);
|
||||
Assert.assertNotNull(c0);
|
||||
|
||||
@@ -39,8 +39,8 @@ public class TestCacheCollectionIds extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
awaitL2Cache();
|
||||
|
||||
ServerCache custCache = cacheManager.getBeanCache(Customer.class);
|
||||
ServerCache custManyIdsCache = cacheManager.getCollectionIdsCache(Customer.class, "contacts");
|
||||
ServerCache custCache = cacheManager.beanCache(Customer.class);
|
||||
ServerCache custManyIdsCache = cacheManager.collectionIdsCache(Customer.class, "contacts");
|
||||
|
||||
// cacheManager.setCaching(Customer.class, true);
|
||||
// cacheManager.setCaching(Contact.class, true);
|
||||
@@ -121,7 +121,7 @@ public class TestCacheCollectionIds extends BaseTestCase {
|
||||
OCachedBean dummyToLoad = Ebean.find(OCachedBean.class, cachedBean.getId());
|
||||
dummyToLoad.getCountries().size();
|
||||
|
||||
ServerCache cachedBeanCountriesCache = cacheManager.getCollectionIdsCache(OCachedBean.class, "countries");
|
||||
ServerCache cachedBeanCountriesCache = cacheManager.collectionIdsCache(OCachedBean.class, "countries");
|
||||
CachedManyIds cachedManyIds = (CachedManyIds) cachedBeanCountriesCache.get(cachedBean.getId());
|
||||
|
||||
// confirm the starting data and cache entry
|
||||
@@ -249,7 +249,7 @@ public class TestCacheCollectionIds extends BaseTestCase {
|
||||
OCachedBean dummyToLoad = Ebean.find(OCachedBean.class, cachedBean.getId());
|
||||
dummyToLoad.getCountries().size();
|
||||
|
||||
ServerCache cachedBeanCountriesCache = cacheManager.getCollectionIdsCache(OCachedBean.class, "countries");
|
||||
ServerCache cachedBeanCountriesCache = cacheManager.collectionIdsCache(OCachedBean.class, "countries");
|
||||
CachedManyIds cachedManyIds = (CachedManyIds) cachedBeanCountriesCache.get(cachedBean.getId());
|
||||
|
||||
// confirm the starting data and cache entry
|
||||
@@ -293,7 +293,7 @@ public class TestCacheCollectionIds extends BaseTestCase {
|
||||
Ebean.save(cachedBean);
|
||||
|
||||
// clear the cache
|
||||
ServerCache cachedBeanCountriesCache = cacheManager.getCollectionIdsCache(OCachedBean.class, "countries");
|
||||
ServerCache cachedBeanCountriesCache = cacheManager.collectionIdsCache(OCachedBean.class, "countries");
|
||||
cachedBeanCountriesCache.clear();
|
||||
assertEquals(0, cachedBeanCountriesCache.size());
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TestCacheNaturalId extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
ServerCache contactCache = Ebean.getServerCacheManager().getBeanCache(Contact.class);
|
||||
ServerCache contactCache = Ebean.getServerCacheManager().beanCache(Contact.class);
|
||||
|
||||
List<Contact> list = Ebean.find(Contact.class).setBeanCacheMode(CacheMode.PUT).findList();
|
||||
|
||||
@@ -36,15 +36,15 @@ public class TestCacheNaturalId extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
contactCache.getStatistics(true);
|
||||
contactCache.statistics(true);
|
||||
|
||||
Contact c0 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findOne();
|
||||
|
||||
ServerCacheStatistics stats0 = contactCache.getStatistics(false);
|
||||
ServerCacheStatistics stats0 = contactCache.statistics(false);
|
||||
|
||||
Contact c1 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findOne();
|
||||
|
||||
ServerCacheStatistics stats1 = contactCache.getStatistics(false);
|
||||
ServerCacheStatistics stats1 = contactCache.statistics(false);
|
||||
|
||||
assertNotNull(c0);
|
||||
assertNotNull(c1);
|
||||
@@ -59,7 +59,7 @@ public class TestCacheNaturalId extends BaseTestCase {
|
||||
Contact c2 = Ebean.find(Contact.class).where().eq("email", "mychangedemail@what.com")
|
||||
.findOne();
|
||||
|
||||
ServerCacheStatistics stats2 = contactCache.getStatistics(false);
|
||||
ServerCacheStatistics stats2 = contactCache.statistics(false);
|
||||
|
||||
assertNotNull(c2);
|
||||
assertEquals(c2.getId(), c1.getId());
|
||||
|
||||
@@ -21,7 +21,7 @@ public class TestExternalNotification extends BaseTestCase {
|
||||
|
||||
loadCountryCache();
|
||||
|
||||
ServerCache countryCache = Ebean.getServerCacheManager().getBeanCache(Country.class);
|
||||
ServerCache countryCache = Ebean.getServerCacheManager().beanCache(Country.class);
|
||||
|
||||
assertTrue(countryCache.size() > 0);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ public class TestL2CacheWithSharedBean extends BaseTestCase {
|
||||
|
||||
Ebean.save(f1);
|
||||
|
||||
ServerCache beanCache = Ebean.getServerCacheManager().getBeanCache(FeatureDescription.class);
|
||||
beanCache.getStatistics(true);
|
||||
ServerCache beanCache = Ebean.getServerCacheManager().beanCache(FeatureDescription.class);
|
||||
beanCache.statistics(true);
|
||||
|
||||
OrmQueryDetail tunedDetail = new OrmQueryDetail();
|
||||
tunedDetail.select("name");
|
||||
@@ -49,7 +49,7 @@ public class TestL2CacheWithSharedBean extends BaseTestCase {
|
||||
// load the cache
|
||||
FeatureDescription fetchOne = Ebean.find(FeatureDescription.class, f1.getId());
|
||||
Assert.assertNotNull(fetchOne);
|
||||
assertEquals(1, beanCache.getStatistics(false).getSize());
|
||||
assertEquals(1, beanCache.statistics(false).getSize());
|
||||
|
||||
FeatureDescription fetchTwo = Ebean.find(FeatureDescription.class, f1.getId());
|
||||
FeatureDescription fetchThree = Ebean.find(FeatureDescription.class, f1.getId());
|
||||
|
||||
@@ -217,7 +217,7 @@ public class TestQueryCache extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
ServerCache customerCache = DB.getServerCacheManager().getQueryCache(Customer.class);
|
||||
ServerCache customerCache = DB.getServerCacheManager().queryCache(Customer.class);
|
||||
customerCache.clear();
|
||||
|
||||
List<Customer> list = DB.find(Customer.class).setUseQueryCache(true).setReadOnly(true).where()
|
||||
|
||||
@@ -20,13 +20,13 @@ import static org.junit.Assert.assertTrue;
|
||||
public class TestQueryCacheCountry extends BaseTestCase {
|
||||
|
||||
private ServerCacheManager cacheManager = Ebean.getServerCacheManager();
|
||||
private ServerCache queryCache = cacheManager.getQueryCache(Country.class);
|
||||
private ServerCache beanCache = cacheManager.getBeanCache(Country.class);
|
||||
private ServerCache queryCache = cacheManager.queryCache(Country.class);
|
||||
private ServerCache beanCache = cacheManager.beanCache(Country.class);
|
||||
|
||||
private void clearCache() {
|
||||
queryCache.clear();
|
||||
beanCache.clear();
|
||||
queryCache.getStatistics(true);
|
||||
queryCache.statistics(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
|
||||
assertThat(countryList0).isEmpty();
|
||||
|
||||
ServerCacheStatistics queryStats = queryCache.getStatistics(false);
|
||||
ServerCacheStatistics queryStats = queryCache.statistics(false);
|
||||
assertEquals(1, queryStats.getMissCount());
|
||||
assertEquals(1, queryStats.getSize());
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
|
||||
assertThat(countryList1).isEmpty();
|
||||
|
||||
ServerCacheStatistics queryStats1 = queryCache.getStatistics(false);
|
||||
ServerCacheStatistics queryStats1 = queryCache.statistics(false);
|
||||
assertEquals(1, queryStats1.getMissCount());
|
||||
assertEquals(1, queryStats1.getSize());
|
||||
assertEquals(1, queryStats1.getHitCount());
|
||||
@@ -83,7 +83,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
|
||||
assertThat(countryList1.get(0).getName()).isEqualTo("Australia");
|
||||
|
||||
ServerCacheStatistics queryStats1 = queryCache.getStatistics(false);
|
||||
ServerCacheStatistics queryStats1 = queryCache.statistics(false);
|
||||
assertEquals(2, queryStats1.getMissCount());
|
||||
assertEquals(2, queryStats1.getSize());
|
||||
assertEquals(0, queryStats1.getHitCount()); // no hits yet
|
||||
@@ -97,7 +97,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
|
||||
assertThat(countryList2.get(0).getName()).isEqualTo("New Zealand");
|
||||
|
||||
ServerCacheStatistics queryStats2 = queryCache.getStatistics(false);
|
||||
ServerCacheStatistics queryStats2 = queryCache.statistics(false);
|
||||
assertEquals(2, queryStats2.getMissCount());
|
||||
assertEquals(2, queryStats2.getSize());
|
||||
assertEquals(1, queryStats2.getHitCount()); // got a hit
|
||||
@@ -110,7 +110,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
|
||||
assertThat(countryList3.get(0).getName()).isEqualTo("Australia");
|
||||
|
||||
ServerCacheStatistics queryStats3 = queryCache.getStatistics(false);
|
||||
ServerCacheStatistics queryStats3 = queryCache.statistics(false);
|
||||
assertEquals(2, queryStats3.getMissCount());
|
||||
assertEquals(2, queryStats3.getSize());
|
||||
assertEquals(2, queryStats3.getHitCount()); // got another hit
|
||||
@@ -124,14 +124,14 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
awaitL2Cache();
|
||||
clearCache();
|
||||
|
||||
assertEquals(0, queryCache.getStatistics(false).getSize());
|
||||
assertEquals(0, queryCache.statistics(false).getSize());
|
||||
|
||||
List<Country> countryList0 = Ebean.find(Country.class)
|
||||
.setUseQueryCache(true)
|
||||
.order().asc("name")
|
||||
.findList();
|
||||
|
||||
assertEquals(1, queryCache.getStatistics(false).getSize());
|
||||
assertEquals(1, queryCache.statistics(false).getSize());
|
||||
assertTrue(!countryList0.isEmpty());
|
||||
|
||||
List<Country> countryList1 = Ebean.find(Country.class)
|
||||
@@ -139,7 +139,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
.order().asc("name")
|
||||
.findList();
|
||||
|
||||
ServerCacheStatistics statistics = queryCache.getStatistics(false);
|
||||
ServerCacheStatistics statistics = queryCache.statistics(false);
|
||||
assertEquals(1, statistics.getSize());
|
||||
assertEquals(1, statistics.getHitCount());
|
||||
Assert.assertSame(countryList1, countryList0);
|
||||
@@ -149,7 +149,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
Ebean.save(nz);
|
||||
awaitL2Cache();
|
||||
|
||||
statistics = queryCache.getStatistics(false);
|
||||
statistics = queryCache.statistics(false);
|
||||
assertEquals(0, statistics.getSize());
|
||||
|
||||
List<Country> countryList2 = Ebean.find(Country.class)
|
||||
|
||||
@@ -44,8 +44,8 @@ public class TestQueryCacheInsert extends BaseTestCase {
|
||||
|
||||
Ebean.save(doda);
|
||||
|
||||
ServerCache queryCache = Ebean.getServerCacheManager().getQueryCache(EBasicVer.class);
|
||||
queryCache.getStatistics(true);
|
||||
ServerCache queryCache = Ebean.getServerCacheManager().queryCache(EBasicVer.class);
|
||||
queryCache.statistics(true);
|
||||
|
||||
Optional<EBasicVer> found0 = Ebean.find(EBasicVer.class)
|
||||
.where().eq("description", "OddButUniqueSillyExample")
|
||||
@@ -65,7 +65,7 @@ public class TestQueryCacheInsert extends BaseTestCase {
|
||||
}
|
||||
|
||||
private void assertHitMiss(int hits, int miss, ServerCache queryCache) {
|
||||
ServerCacheStatistics stats = queryCache.getStatistics(true);
|
||||
ServerCacheStatistics stats = queryCache.statistics(true);
|
||||
assertEquals(hits, stats.getHitCount());
|
||||
assertEquals(miss, stats.getMissCount());
|
||||
}
|
||||
|
||||
+5
-5
@@ -25,7 +25,7 @@ public class TestQueryCacheTableDependency extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
ServerCache customerCache = Ebean.getServerCacheManager().getQueryCache(Customer.class);
|
||||
ServerCache customerCache = Ebean.getServerCacheManager().queryCache(Customer.class);
|
||||
customerCache.clear();
|
||||
|
||||
List<Address> addrs = Ebean.find(Address.class)
|
||||
@@ -138,8 +138,8 @@ public class TestQueryCacheTableDependency extends BaseTestCase {
|
||||
child.setName("bobby");
|
||||
child.setBillingAddress(root);
|
||||
DB.save(child);
|
||||
DB.getServerCacheManager().getQueryCache(Address.class).clear();
|
||||
DB.getServerCacheManager().getQueryCache(Customer.class).clear();
|
||||
DB.getServerCacheManager().queryCache(Address.class).clear();
|
||||
DB.getServerCacheManager().queryCache(Customer.class).clear();
|
||||
// Test preparation finished, start the test
|
||||
Thread.sleep(10);
|
||||
|
||||
@@ -169,8 +169,8 @@ public class TestQueryCacheTableDependency extends BaseTestCase {
|
||||
child.setName("testChild");
|
||||
child.setRoot(root);
|
||||
DB.save(child);
|
||||
DB.getServerCacheManager().getQueryCache(ECacheChild.class).clear();
|
||||
DB.getServerCacheManager().getQueryCache(ECacheRoot.class).clear();
|
||||
DB.getServerCacheManager().queryCache(ECacheChild.class).clear();
|
||||
DB.getServerCacheManager().queryCache(ECacheRoot.class).clear();
|
||||
// Test preparation finished, start the test
|
||||
Thread.sleep(10);
|
||||
// we need this thread.sleep here, because on a fast machine, DB.save(child) and computing the
|
||||
|
||||
@@ -21,10 +21,10 @@ public class PersonCacheTests {
|
||||
|
||||
private final List<Object> ids = Arrays.asList("E001", "E002", "E003");
|
||||
|
||||
private ServerCache beanCacheInfo = DB.getDefault().cacheManager().getBeanCache(PersonCacheInfo.class);
|
||||
private ServerCache beanCacheEmail = DB.getDefault().cacheManager().getBeanCache(PersonCacheEmail.class);
|
||||
private ServerCache beanCacheInfo = DB.getDefault().cacheManager().beanCache(PersonCacheInfo.class);
|
||||
private ServerCache beanCacheEmail = DB.getDefault().cacheManager().beanCache(PersonCacheEmail.class);
|
||||
|
||||
private ServerCacheRegion region = DB.getDefault().cacheManager().getRegion("email");
|
||||
private ServerCacheRegion region = DB.getDefault().cacheManager().region("email");
|
||||
|
||||
private void insert(int id, String email) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PersonCacheTests {
|
||||
.setUseCache(true)
|
||||
.findList();
|
||||
|
||||
beanCacheInfo.getStatistics(true);
|
||||
beanCacheInfo.statistics(true);
|
||||
|
||||
List<PersonCacheEmail> emailList =
|
||||
DB.find(PersonCacheEmail.class)
|
||||
@@ -73,7 +73,7 @@ public class PersonCacheTests {
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
|
||||
assertThat(beanCacheInfo.getStatistics(true).getHitCount()).isEqualTo(3);
|
||||
assertThat(beanCacheInfo.statistics(true).getHitCount()).isEqualTo(3);
|
||||
|
||||
// force cache misses on PersonCacheEmail
|
||||
beanCacheEmail.clear();
|
||||
@@ -94,7 +94,7 @@ public class PersonCacheTests {
|
||||
sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
|
||||
assertThat(beanCacheInfo.getStatistics(true).getHitCount()).isEqualTo(3);
|
||||
assertThat(beanCacheInfo.statistics(true).getHitCount()).isEqualTo(3);
|
||||
|
||||
turnOffRegion_expect_noCacheUse();
|
||||
|
||||
@@ -103,7 +103,7 @@ public class PersonCacheTests {
|
||||
private void turnOffRegion_expect_noCacheUse() {
|
||||
|
||||
assertTrue(region.isEnabled());
|
||||
beanCacheEmail.getStatistics(true);
|
||||
beanCacheEmail.statistics(true);
|
||||
|
||||
log.info("Disabled region ...");
|
||||
region.setEnabled(false);
|
||||
@@ -116,7 +116,7 @@ public class PersonCacheTests {
|
||||
}
|
||||
|
||||
// assert that we didn't hit the cache
|
||||
ServerCacheStatistics statistics = beanCacheEmail.getStatistics(true);
|
||||
ServerCacheStatistics statistics = beanCacheEmail.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(0);
|
||||
assertThat(statistics.getMissCount()).isEqualTo(0);
|
||||
|
||||
@@ -131,7 +131,7 @@ public class PersonCacheTests {
|
||||
}
|
||||
|
||||
// assert that we DID hit the cache
|
||||
statistics = beanCacheEmail.getStatistics(true);
|
||||
statistics = beanCacheEmail.statistics(true);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(3);
|
||||
assertThat(statistics.getMissCount()).isEqualTo(0);
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class TestInheritCacheRefLoad {
|
||||
Class streetClassLazyLoaded = customerReloaded.getAddress().getStreet().getClass();
|
||||
|
||||
//Show Cache Hits
|
||||
System.out.println("Class of Street (Cache on: " + l2Cache + "): " + streetClassLazyLoaded + " | Cache Hit: " + DB.getDefault().cacheManager().getQueryCache(streetClassLazyLoaded).getStatistics(false).getHitCount());
|
||||
System.out.println("Class of Street (Cache on: " + l2Cache + "): " + streetClassLazyLoaded + " | Cache Hit: " + DB.getDefault().cacheManager().queryCache(streetClassLazyLoaded).statistics(false).getHitCount());
|
||||
return streetClassLazyLoaded;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -21,8 +21,8 @@ public class TestCacheViaComplexNaturalKey extends BaseTestCase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TestCacheViaComplexNaturalKey.class);
|
||||
|
||||
private ServerCache beanCache = cacheManager().getBeanCache(OCachedNatKeyBean.class);
|
||||
private ServerCache natKeyCache = cacheManager().getNaturalKeyCache(OCachedNatKeyBean.class);
|
||||
private ServerCache beanCache = cacheManager().beanCache(OCachedNatKeyBean.class);
|
||||
private ServerCache natKeyCache = cacheManager().naturalKeyCache(OCachedNatKeyBean.class);
|
||||
|
||||
private static boolean loadOnce;
|
||||
|
||||
@@ -52,17 +52,17 @@ public class TestCacheViaComplexNaturalKey extends BaseTestCase {
|
||||
}
|
||||
|
||||
private void clearStatistics() {
|
||||
beanCache.getStatistics(true);
|
||||
natKeyCache.getStatistics(true);
|
||||
beanCache.statistics(true);
|
||||
natKeyCache.statistics(true);
|
||||
}
|
||||
|
||||
private void assertNaturalKeyHitMiss(int expectedHit, int expectedMiss) {
|
||||
ServerCacheStatistics stats = natKeyCache.getStatistics(true);
|
||||
ServerCacheStatistics stats = natKeyCache.statistics(true);
|
||||
assertHitMiss(expectedHit, expectedMiss, stats);
|
||||
}
|
||||
|
||||
private void assertBeanCacheHitMiss(int expectedHit, int expectedMiss) {
|
||||
ServerCacheStatistics stats = beanCache.getStatistics(true);
|
||||
ServerCacheStatistics stats = beanCache.statistics(true);
|
||||
assertHitMiss(expectedHit, expectedMiss, stats);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
|
||||
private ServerCache beanCache = cacheManager().getBeanCache(OCachedNatKeyBean3.class);
|
||||
private ServerCache natKeyCache = cacheManager().getNaturalKeyCache(OCachedNatKeyBean3.class);
|
||||
private ServerCache beanCache = cacheManager().beanCache(OCachedNatKeyBean3.class);
|
||||
private ServerCache natKeyCache = cacheManager().naturalKeyCache(OCachedNatKeyBean3.class);
|
||||
|
||||
private static boolean loadOnce;
|
||||
|
||||
@@ -55,17 +55,17 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
}
|
||||
|
||||
private void clearStatistics() {
|
||||
beanCache.getStatistics(true);
|
||||
natKeyCache.getStatistics(true);
|
||||
beanCache.statistics(true);
|
||||
natKeyCache.statistics(true);
|
||||
}
|
||||
|
||||
private void assertNaturalKeyHitMiss(int expectedHit, int expectedMiss) {
|
||||
ServerCacheStatistics stats = natKeyCache.getStatistics(true);
|
||||
ServerCacheStatistics stats = natKeyCache.statistics(true);
|
||||
assertHitMiss(expectedHit, expectedMiss, stats);
|
||||
}
|
||||
|
||||
private void assertBeanCacheHitMiss(int expectedHit, int expectedMiss) {
|
||||
ServerCacheStatistics stats = beanCache.getStatistics(true);
|
||||
ServerCacheStatistics stats = beanCache.statistics(true);
|
||||
assertHitMiss(expectedHit, expectedMiss, stats);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestCacheWithSoftDelete extends BaseTestCase {
|
||||
|
||||
private final ServerCache beanCache = DB.getServerCacheManager().getBeanCache(ESoftWithCache.class);
|
||||
private final ServerCache beanCache = DB.getServerCacheManager().beanCache(ESoftWithCache.class);
|
||||
|
||||
@Test
|
||||
public void idIn_expect_hitCache() {
|
||||
@@ -41,6 +41,6 @@ public class TestCacheWithSoftDelete extends BaseTestCase {
|
||||
}
|
||||
|
||||
private ServerCacheStatistics stats() {
|
||||
return beanCache.getStatistics(true);
|
||||
return beanCache.statistics(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,15 +80,15 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase {
|
||||
ServerCacheManager serverCacheManager = server.cacheManager();
|
||||
|
||||
// get cache, clear the cache and statistics
|
||||
ServerCache beanCache = serverCacheManager.getBeanCache(EInvoice.class);
|
||||
ServerCache beanCache = serverCacheManager.beanCache(EInvoice.class);
|
||||
beanCache.clear();
|
||||
beanCache.getStatistics(true);
|
||||
beanCache.statistics(true);
|
||||
|
||||
// fetch and load the cache
|
||||
EInvoice invoice4 = Ebean.find(EInvoice.class, invoice.getId());
|
||||
assertNotNull(invoice4);
|
||||
|
||||
ServerCacheStatistics statistics = beanCache.getStatistics(false);
|
||||
ServerCacheStatistics statistics = beanCache.statistics(false);
|
||||
|
||||
assertEquals(1, statistics.getSize());
|
||||
assertEquals(0, statistics.getHitCount());
|
||||
@@ -97,7 +97,7 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase {
|
||||
EInvoice invoice5 = Ebean.find(EInvoice.class, invoice.getId());
|
||||
assertNotNull(invoice5);
|
||||
|
||||
statistics = beanCache.getStatistics(false);
|
||||
statistics = beanCache.statistics(false);
|
||||
assertEquals(1, statistics.getSize());
|
||||
assertEquals(1, statistics.getHitCount());
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ public class TestReadAudit extends BaseTestCase {
|
||||
public void test_findById_usingL2Cache() {
|
||||
resetCounters();
|
||||
|
||||
ServerCache beanCache = server.cacheManager().getBeanCache(EBasicChangeLog.class);
|
||||
beanCache.getStatistics(true);
|
||||
ServerCache beanCache = server.cacheManager().beanCache(EBasicChangeLog.class);
|
||||
beanCache.statistics(true);
|
||||
|
||||
EBasicChangeLog found = server.find(EBasicChangeLog.class, id1);
|
||||
assertThat(found).isNotNull();
|
||||
@@ -94,13 +94,13 @@ public class TestReadAudit extends BaseTestCase {
|
||||
assertThat(readAuditLogger.beans.get(0).getBeanType()).isEqualTo(EBasicChangeLog.class.getName());
|
||||
assertThat(readAuditLogger.beans.get(0).getId()).isEqualTo(id1);
|
||||
|
||||
ServerCacheStatistics statistics = beanCache.getStatistics(false);
|
||||
ServerCacheStatistics statistics = beanCache.statistics(false);
|
||||
assertThat(statistics.getSize()).isEqualTo(1);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(0);
|
||||
|
||||
EBasicChangeLog found2 = server.find(EBasicChangeLog.class, id1);
|
||||
assertThat(found2).isNotNull();
|
||||
statistics = beanCache.getStatistics(false);
|
||||
statistics = beanCache.statistics(false);
|
||||
assertThat(statistics.getSize()).isEqualTo(1);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(1);
|
||||
|
||||
@@ -111,8 +111,8 @@ public class TestReadAudit extends BaseTestCase {
|
||||
public void test_findById_usingL2Cache_sharedBean() {
|
||||
resetCounters();
|
||||
|
||||
ServerCache beanCache = server.cacheManager().getBeanCache(Country.class);
|
||||
beanCache.getStatistics(true);
|
||||
ServerCache beanCache = server.cacheManager().beanCache(Country.class);
|
||||
beanCache.statistics(true);
|
||||
|
||||
Country found = server.find(Country.class, "AR");
|
||||
assertThat(found).isNotNull();
|
||||
@@ -122,13 +122,13 @@ public class TestReadAudit extends BaseTestCase {
|
||||
assertThat(readAuditLogger.beans.get(0).getBeanType()).isEqualTo(Country.class.getName());
|
||||
assertThat(readAuditLogger.beans.get(0).getId()).isEqualTo("AR");
|
||||
|
||||
ServerCacheStatistics statistics = beanCache.getStatistics(false);
|
||||
ServerCacheStatistics statistics = beanCache.statistics(false);
|
||||
assertThat(statistics.getSize()).isEqualTo(1);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(0);
|
||||
|
||||
Country found2 = server.find(Country.class, "AR");
|
||||
assertThat(found2).isNotNull();
|
||||
statistics = beanCache.getStatistics(false);
|
||||
statistics = beanCache.statistics(false);
|
||||
assertThat(statistics.getSize()).isEqualTo(1);
|
||||
assertThat(statistics.getHitCount()).isEqualTo(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user