mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2348 - Rename Database.getServerCacheManager() to cacheManager() with deprecation
This commit is contained in:
1 parent
fe67abce83
commit
0ed6ccf499
23 files changed
+39
-32
No files matched your search
@@ -1246,7 +1246,7 @@ public final class DB {
|
|||||||
* Return the manager of the level 2 cache ("L2" cache).
|
* Return the manager of the level 2 cache ("L2" cache).
|
||||||
*/
|
*/
|
||||||
public static ServerCacheManager getServerCacheManager() {
|
public static ServerCacheManager getServerCacheManager() {
|
||||||
return getDefault().getServerCacheManager();
|
return getDefault().cacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1495,7 +1495,15 @@ public interface Database {
|
|||||||
/**
|
/**
|
||||||
* Return the manager of the server cache ("L2" cache).
|
* Return the manager of the server cache ("L2" cache).
|
||||||
*/
|
*/
|
||||||
ServerCacheManager getServerCacheManager();
|
ServerCacheManager cacheManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to cacheManager().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default ServerCacheManager getServerCacheManager() {
|
||||||
|
return cacheManager();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the BackgroundExecutor service for asynchronous processing of
|
* Return the BackgroundExecutor service for asynchronous processing of
|
||||||
|
|||||||
@@ -1208,7 +1208,7 @@ public final class Ebean {
|
|||||||
* Return the manager of the server cache ("L2" cache).
|
* Return the manager of the server cache ("L2" cache).
|
||||||
*/
|
*/
|
||||||
public static ServerCacheManager getServerCacheManager() {
|
public static ServerCacheManager getServerCacheManager() {
|
||||||
return getDefault().getServerCacheManager();
|
return getDefault().cacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCacheManager getServerCacheManager() {
|
public ServerCacheManager cacheManager() {
|
||||||
return serverCacheManager;
|
return serverCacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void clearAllL2Cache() {
|
protected void clearAllL2Cache() {
|
||||||
server().getServerCacheManager().clearAll();
|
server().cacheManager().clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetAllMetrics() {
|
protected void resetAllMetrics() {
|
||||||
@@ -242,7 +242,7 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected <T> ServerCacheStatistics getBeanCacheStats(Class<T> cls, boolean reset) {
|
protected <T> ServerCacheStatistics getBeanCacheStats(Class<T> cls, boolean reset) {
|
||||||
return server().getServerCacheManager().getBeanCache(cls).getStatistics(reset);
|
return server().cacheManager().getBeanCache(cls).getStatistics(reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Platform platform() {
|
protected Platform platform() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class ServerCacheManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
ServerCacheManager cacheManager = DB.getDefault().getServerCacheManager();
|
ServerCacheManager cacheManager = DB.getDefault().cacheManager();
|
||||||
|
|
||||||
for (ServerCacheRegion region : cacheManager.allRegions()) {
|
for (ServerCacheRegion region : cacheManager.allRegions()) {
|
||||||
assertTrue(region.isEnabled());
|
assertTrue(region.isEnabled());
|
||||||
|
|||||||
@@ -919,7 +919,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCacheManager getServerCacheManager() {
|
public ServerCacheManager cacheManager() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ public class JdbcTransactionTest {
|
|||||||
@Test
|
@Test
|
||||||
public void skipCacheAfterSave() {
|
public void skipCacheAfterSave() {
|
||||||
|
|
||||||
ServerCacheManager cacheManager = DB.getDefault().getServerCacheManager();
|
ServerCacheManager cacheManager = DB.getDefault().cacheManager();
|
||||||
ServerCache customerBeanCache = cacheManager.getBeanCache(Customer.class);
|
ServerCache customerBeanCache = cacheManager.getBeanCache(Customer.class);
|
||||||
ServerCache contactNatKeyCache = cacheManager.getNaturalKeyCache(Contact.class);
|
ServerCache contactNatKeyCache = cacheManager.getNaturalKeyCache(Contact.class);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class TestQueryWithCache extends BaseTestCase {
|
|||||||
assertTrue(cacheOptions.isReadOnly());
|
assertTrue(cacheOptions.isReadOnly());
|
||||||
assertTrue(beanDescriptor.isCacheSharableBeans());
|
assertTrue(beanDescriptor.isCacheSharableBeans());
|
||||||
|
|
||||||
ServerCacheManager serverCacheManager = server.getServerCacheManager();
|
ServerCacheManager serverCacheManager = server.cacheManager();
|
||||||
serverCacheManager.clear(Country.class);
|
serverCacheManager.clear(Country.class);
|
||||||
|
|
||||||
ServerCache beanCache = serverCacheManager.getBeanCache(Country.class);
|
ServerCache beanCache = serverCacheManager.getBeanCache(Country.class);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull;
|
|||||||
|
|
||||||
public class TestBatchLazyWithCacheHits extends BaseTestCase {
|
public class TestBatchLazyWithCacheHits extends BaseTestCase {
|
||||||
|
|
||||||
private final ServerCache beanCache = server().getServerCacheManager().getBeanCache(UUOne.class);
|
private final ServerCache beanCache = server().cacheManager().getBeanCache(UUOne.class);
|
||||||
|
|
||||||
private UUOne insert(String name) {
|
private UUOne insert(String name) {
|
||||||
UUOne one = new UUOne();
|
UUOne one = new UUOne();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class TestBeanCache extends BaseTestCase {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(TestBeanCache.class);
|
private static final Logger log = LoggerFactory.getLogger(TestBeanCache.class);
|
||||||
|
|
||||||
private final ServerCache beanCache = DB.getDefault().getServerCacheManager().getBeanCache(OCachedBean.class);
|
private final ServerCache beanCache = DB.getDefault().cacheManager().getBeanCache(OCachedBean.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findById_when_idTypeConverted() {
|
public void findById_when_idTypeConverted() {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
public class TestBeanFetchJoinCache extends BaseTestCase {
|
public class TestBeanFetchJoinCache extends BaseTestCase {
|
||||||
|
|
||||||
private final ServerCache customerBeanCache = server().getServerCacheManager().getBeanCache(Customer.class);
|
private final ServerCache customerBeanCache = server().cacheManager().getBeanCache(Customer.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fetchCache_when_allHits() {
|
public void fetchCache_when_allHits() {
|
||||||
@@ -181,6 +181,6 @@ public class TestBeanFetchJoinCache extends BaseTestCase {
|
|||||||
|
|
||||||
private void initDataClearCache() {
|
private void initDataClearCache() {
|
||||||
ResetBasicData.reset();
|
ResetBasicData.reset();
|
||||||
server().getServerCacheManager().clearAll();
|
server().cacheManager().clearAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ public class TestL2DirtyFlagOnLazyLoad extends BaseTestCase {
|
|||||||
|
|
||||||
// clearAll() caches via the ServerCacheManager ...
|
// clearAll() caches via the ServerCacheManager ...
|
||||||
// Clear all the caches on the default/primary EbeanServer
|
// Clear all the caches on the default/primary EbeanServer
|
||||||
server().getServerCacheManager().clearAll();
|
server().cacheManager().clearAll();
|
||||||
|
|
||||||
//TEST
|
//TEST
|
||||||
try (Transaction tx1 = Ebean.beginTransaction()) {
|
try (Transaction tx1 = Ebean.beginTransaction()) {
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ public class TestQueryCache extends BaseTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findCountDifferentQueriesBit() {
|
public void findCountDifferentQueriesBit() {
|
||||||
DB.getDefault().pluginApi().getServerCacheManager().clearAll();
|
DB.getDefault().pluginApi().cacheManager().clearAll();
|
||||||
differentFindCount(q->q.bitwiseAny("id",1), q->q.bitwiseAny("id",0));
|
differentFindCount(q->q.bitwiseAny("id",1), q->q.bitwiseAny("id",0));
|
||||||
differentFindCount(q->q.bitwiseAll("id",1), q->q.bitwiseAll("id",0));
|
differentFindCount(q->q.bitwiseAll("id",1), q->q.bitwiseAll("id",0));
|
||||||
// differentFindCount(q->q.bitwiseNot("id",1), q->q.bitwiseNot("id",0)); NOT 1 == AND 1 = 0
|
// differentFindCount(q->q.bitwiseNot("id",1), q->q.bitwiseNot("id",0)); NOT 1 == AND 1 = 0
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ public class PersonCacheTests {
|
|||||||
|
|
||||||
private final List<Object> ids = Arrays.asList("E001", "E002", "E003");
|
private final List<Object> ids = Arrays.asList("E001", "E002", "E003");
|
||||||
|
|
||||||
private ServerCache beanCacheInfo = DB.getDefault().getServerCacheManager().getBeanCache(PersonCacheInfo.class);
|
private ServerCache beanCacheInfo = DB.getDefault().cacheManager().getBeanCache(PersonCacheInfo.class);
|
||||||
private ServerCache beanCacheEmail = DB.getDefault().getServerCacheManager().getBeanCache(PersonCacheEmail.class);
|
private ServerCache beanCacheEmail = DB.getDefault().cacheManager().getBeanCache(PersonCacheEmail.class);
|
||||||
|
|
||||||
private ServerCacheRegion region = DB.getDefault().getServerCacheManager().getRegion("email");
|
private ServerCacheRegion region = DB.getDefault().cacheManager().getRegion("email");
|
||||||
|
|
||||||
private void insert(int id, String email) {
|
private void insert(int id, String email) {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ public class TestInheritCacheRefLoad {
|
|||||||
Class streetClassLazyLoaded = customerReloaded.getAddress().getStreet().getClass();
|
Class streetClassLazyLoaded = customerReloaded.getAddress().getStreet().getClass();
|
||||||
|
|
||||||
//Show Cache Hits
|
//Show Cache Hits
|
||||||
System.out.println("Class of Street (Cache on: " + l2Cache + "): " + streetClassLazyLoaded + " | Cache Hit: " + DB.getDefault().getServerCacheManager().getQueryCache(streetClassLazyLoaded).getStatistics(false).getHitCount());
|
System.out.println("Class of Street (Cache on: " + l2Cache + "): " + streetClassLazyLoaded + " | Cache Hit: " + DB.getDefault().cacheManager().getQueryCache(streetClassLazyLoaded).getStatistics(false).getHitCount());
|
||||||
return streetClassLazyLoaded;
|
return streetClassLazyLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ public class TestCacheViaComplexNaturalKey extends BaseTestCase {
|
|||||||
private static boolean loadOnce;
|
private static boolean loadOnce;
|
||||||
|
|
||||||
private ServerCacheManager cacheManager() {
|
private ServerCacheManager cacheManager() {
|
||||||
return server().getServerCacheManager();
|
return server().cacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void insertSome() {
|
private static void insertSome() {
|
||||||
|
|||||||
+1
-2
@@ -10,7 +10,6 @@ import io.ebean.cache.ServerCacheStatistics;
|
|||||||
import org.ebeantest.LoggedSqlCollector;
|
import org.ebeantest.LoggedSqlCollector;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
|||||||
private static boolean loadOnce;
|
private static boolean loadOnce;
|
||||||
|
|
||||||
private ServerCacheManager cacheManager() {
|
private ServerCacheManager cacheManager() {
|
||||||
return server().getServerCacheManager();
|
return server().cacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void insertSome() {
|
private static void insertSome() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class TestEmbeddedManyToOne extends BaseTestCase {
|
|||||||
|
|
||||||
BeanType<EAddr> embType = Ebean.getDefaultServer().pluginApi().getBeanType(EAddr.class);
|
BeanType<EAddr> embType = Ebean.getDefaultServer().pluginApi().getBeanType(EAddr.class);
|
||||||
|
|
||||||
Ebean.getDefaultServer().getServerCacheManager().clearAll();
|
Ebean.getDefaultServer().cacheManager().clearAll();
|
||||||
|
|
||||||
Country nz = Ebean.getReference(Country.class, "NZ");
|
Country nz = Ebean.getReference(Country.class, "NZ");
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase {
|
|||||||
assertEquals("3 Pineapple St", billAddress.getStreet());
|
assertEquals("3 Pineapple St", billAddress.getStreet());
|
||||||
|
|
||||||
EbeanServer server = Ebean.getServer(null);
|
EbeanServer server = Ebean.getServer(null);
|
||||||
ServerCacheManager serverCacheManager = server.getServerCacheManager();
|
ServerCacheManager serverCacheManager = server.cacheManager();
|
||||||
|
|
||||||
// get cache, clear the cache and statistics
|
// get cache, clear the cache and statistics
|
||||||
ServerCache beanCache = serverCacheManager.getBeanCache(EInvoice.class);
|
ServerCache beanCache = serverCacheManager.getBeanCache(EInvoice.class);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class TestReadAudit extends BaseTestCase {
|
|||||||
public void test_findById_usingL2Cache() {
|
public void test_findById_usingL2Cache() {
|
||||||
resetCounters();
|
resetCounters();
|
||||||
|
|
||||||
ServerCache beanCache = server.getServerCacheManager().getBeanCache(EBasicChangeLog.class);
|
ServerCache beanCache = server.cacheManager().getBeanCache(EBasicChangeLog.class);
|
||||||
beanCache.getStatistics(true);
|
beanCache.getStatistics(true);
|
||||||
|
|
||||||
EBasicChangeLog found = server.find(EBasicChangeLog.class, id1);
|
EBasicChangeLog found = server.find(EBasicChangeLog.class, id1);
|
||||||
@@ -111,7 +111,7 @@ public class TestReadAudit extends BaseTestCase {
|
|||||||
public void test_findById_usingL2Cache_sharedBean() {
|
public void test_findById_usingL2Cache_sharedBean() {
|
||||||
resetCounters();
|
resetCounters();
|
||||||
|
|
||||||
ServerCache beanCache = server.getServerCacheManager().getBeanCache(Country.class);
|
ServerCache beanCache = server.cacheManager().getBeanCache(Country.class);
|
||||||
beanCache.getStatistics(true);
|
beanCache.getStatistics(true);
|
||||||
|
|
||||||
Country found = server.find(Country.class, "AR");
|
Country found = server.find(Country.class, "AR");
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void clearAllL2Cache() {
|
protected void clearAllL2Cache() {
|
||||||
server().getServerCacheManager().clearAll();
|
server().cacheManager().clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetAllMetrics() {
|
protected void resetAllMetrics() {
|
||||||
@@ -238,7 +238,7 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected <T> ServerCacheStatistics getBeanCacheStats(Class<T> cls, boolean reset) {
|
protected <T> ServerCacheStatistics getBeanCacheStats(Class<T> cls, boolean reset) {
|
||||||
return server().getServerCacheManager().getBeanCache(cls).getStatistics(reset);
|
return server().cacheManager().getBeanCache(cls).getStatistics(reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Platform platform() {
|
protected Platform platform() {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class ClusterTest {
|
|||||||
fooA = DB.find(Person.class, foo.getId());
|
fooA = DB.find(Person.class, foo.getId());
|
||||||
assertCounts(dualCacheA, 2, 1, 0, 1);
|
assertCounts(dualCacheA, 2, 1, 0, 1);
|
||||||
fooB = other.find(Person.class, foo.getId());
|
fooB = other.find(Person.class, foo.getId());
|
||||||
DuelCache dualCacheB = (DuelCache) other.getServerCacheManager().getBeanCache(Person.class);
|
DuelCache dualCacheB = (DuelCache) other.cacheManager().getBeanCache(Person.class);
|
||||||
assertCounts(dualCacheB, 2, 1, 1, 0);
|
assertCounts(dualCacheB, 2, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,10 +69,10 @@ public class ClusterTest {
|
|||||||
foo.save();
|
foo.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
other.getServerCacheManager().clearAll();
|
other.cacheManager().clearAll();
|
||||||
other.metaInfo().resetAllMetrics();
|
other.metaInfo().resetAllMetrics();
|
||||||
|
|
||||||
DuelCache dualCache = (DuelCache) other.getServerCacheManager().getBeanCache(Person.class);
|
DuelCache dualCache = (DuelCache) other.cacheManager().getBeanCache(Person.class);
|
||||||
|
|
||||||
Person foo0 = other.find(Person.class, 1);
|
Person foo0 = other.find(Person.class, 1);
|
||||||
assertCounts(dualCache, 0, 1, 0, 1);
|
assertCounts(dualCache, 0, 1, 0, 1);
|
||||||
|
|||||||
Reference in new issue
Block a user