diff --git a/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java b/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java index f6ac72f6e..dfe4c846f 100644 --- a/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java +++ b/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java @@ -72,7 +72,6 @@ final class RedisCacheFactory implements ServerCacheFactory { private final BackgroundExecutor executor; private final JedisPool jedisPool; - private final DaemonTopicRunner daemonTopicRunner; private final NearCacheNotify nearCacheNotify; private final TimedMetric metricOutNearCache; private final TimedMetric metricOutTableMod; @@ -96,11 +95,9 @@ final class RedisCacheFactory implements ServerCacheFactory { this.metricInNearCache = factory.createTimedMetric("l2a.inNearKeys"); if (config.isDisableL2Cache()) { this.jedisPool = null; - this.daemonTopicRunner = null; } else { this.jedisPool = getJedisPool(config); - this.daemonTopicRunner = new DaemonTopicRunner(jedisPool, new CacheDaemonTopic()); - daemonTopicRunner.run(); + new DaemonTopicRunner(jedisPool, new CacheDaemonTopic()).run(); } } diff --git a/ebean-redis/src/test/java/org/integration/ClusterTest.java b/ebean-redis/src/test/java/org/integration/ClusterTest.java index a6d9515c8..68bf19135 100644 --- a/ebean-redis/src/test/java/org/integration/ClusterTest.java +++ b/ebean-redis/src/test/java/org/integration/ClusterTest.java @@ -15,9 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ClusterTest { - private Database createOther(DataSource dataSource) { - DatabaseConfig config = new DatabaseConfig(); config.setDataSource(dataSource); config.loadFromProperties(); @@ -25,7 +23,6 @@ public class ClusterTest { config.setName("other"); config.setDdlGenerate(false); config.setDdlRun(false); - return DatabaseFactory.create(config); } @@ -47,22 +44,23 @@ public class ClusterTest { Person fooA = DB.find(Person.class, foo.getId()); Person fooB = other.find(Person.class, foo.getId()); + + DuelCache dualCacheA = (DuelCache) DB.getServerCacheManager().getBeanCache(Person.class); + assertCounts(dualCacheA, 0, 1, 1, 0); fooA = DB.find(Person.class, foo.getId()); + assertCounts(dualCacheA, 1, 1, 1, 0); fooB = other.find(Person.class, foo.getId()); fooA = DB.find(Person.class, foo.getId()); + assertCounts(dualCacheA, 2, 1, 1, 0); fooB = other.find(Person.class, foo.getId()); - - DuelCache dualCache = (DuelCache) other.getServerCacheManager().getBeanCache(Person.class); - assertCounts(dualCache, 2, 1, 1, 0); - + DuelCache dualCacheB = (DuelCache) other.getServerCacheManager().getBeanCache(Person.class); + assertCounts(dualCacheB, 2, 1, 1, 0); } @Test public void test() throws InterruptedException { - // ensure the default server exists first final Database db = DB.getDefault(); - Database other = createOther(db.getPluginApi().getDataSource()); for (int i = 0; i < 10; i++) { @@ -90,7 +88,6 @@ public class ClusterTest { other.find(Person.class, 2); assertCounts(dualCache, 3, 2, 0, 2); - foo0.setName("name2"); foo0.save(); allowAsyncMessaging(); @@ -99,7 +96,6 @@ public class ClusterTest { assertThat(foo3.getName()).isEqualTo("name2"); assertCounts(dualCache, 3, 3, 1, 2); - foo0.setName("name3"); foo0.save(); allowAsyncMessaging(); @@ -110,7 +106,6 @@ public class ClusterTest { } private void assertCounts(DuelCache dualCache, int nearHits, int nearMiss, int remoteHit, int remoteMiss) { - assertThat(dualCache.getNearHitCount()).isEqualTo(nearHits); assertThat(dualCache.getNearMissCount()).isEqualTo(nearMiss); assertThat(dualCache.getRemoteHitCount()).isEqualTo(remoteHit); diff --git a/ebean-redis/src/test/java/org/integration/IntegrationTest.java b/ebean-redis/src/test/java/org/integration/IntegrationTest.java index 419b8d78c..5fb66aad6 100644 --- a/ebean-redis/src/test/java/org/integration/IntegrationTest.java +++ b/ebean-redis/src/test/java/org/integration/IntegrationTest.java @@ -68,15 +68,12 @@ public class IntegrationTest { System.out.println("done"); } - private List insertSomePeople() { - + private void insertSomePeople() { List people = new ArrayList<>(); for (String name : new String[]{"Jack", "John", "Rob", "Moby", "Fiona"}) { people.add(new Person(name)); } - DB.saveAll(people); - return people; } private Person findByName(String name) {