1
0
mirror of https://github.com/google/nomulus synced 2026-02-09 06:20:29 +00:00

Finish conversion from Guava Cache to Caffeine (#1616)

* Finish conversion from Guava Cache to Caffeine
This commit is contained in:
Ben McIlwain
2022-05-04 17:43:47 -04:00
committed by GitHub
parent 205b16fe8a
commit 08a9e2b64e
15 changed files with 90 additions and 169 deletions

View File

@@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableList;
import google.registry.model.contact.ContactResource;
import google.registry.model.host.HostResource;
import google.registry.testing.TestCacheExtension;
import org.joda.time.Duration;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -34,7 +34,7 @@ public class EppResourceTest extends EntityTestCase {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withEppResourceCache(Duration.standardDays(1)).build();
new TestCacheExtension.Builder().withEppResourceCache(Duration.ofDays(1)).build();
@Test
void test_loadCached_ignoresContactChange() {

View File

@@ -38,7 +38,7 @@ import google.registry.testing.TestCacheExtension;
import google.registry.testing.TestOfyAndSql;
import google.registry.testing.TestOfyOnly;
import google.registry.testing.TestSqlOnly;
import org.joda.time.Duration;
import java.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -48,7 +48,7 @@ class ForeignKeyIndexTest extends EntityTestCase {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withForeignIndexKeyCache(Duration.standardDays(1)).build();
new TestCacheExtension.Builder().withForeignIndexKeyCache(Duration.ofDays(1)).build();
@BeforeEach
void setUp() {

View File

@@ -22,7 +22,6 @@ import static google.registry.testing.DatabaseHelper.newRegistry;
import static google.registry.testing.DatabaseHelper.persistResource;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.Duration.standardDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.base.Stopwatch;
@@ -34,6 +33,7 @@ import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock;
import google.registry.testing.TestCacheExtension;
import java.math.BigDecimal;
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
@@ -61,9 +61,7 @@ public class PremiumListDaoTest {
// Set long persist times on caches so they can be tested (cache times default to 0 in tests).
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder()
.withPremiumListsCache(standardDays(1))
.build();
new TestCacheExtension.Builder().withPremiumListsCache(Duration.ofDays(1)).build();
private static final ImmutableMap<String, BigDecimal> TEST_PRICES =
ImmutableMap.of(

View File

@@ -19,9 +19,9 @@ import com.google.common.collect.Maps;
import google.registry.model.EppResource;
import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.tld.label.PremiumListDao;
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import org.joda.time.Duration;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

View File

@@ -66,8 +66,8 @@ import google.registry.whois.WhoisMetrics.WhoisMetric;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.time.Duration;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -87,8 +87,8 @@ public class WhoisActionTest {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder()
.withEppResourceCache(Duration.standardDays(1))
.withForeignIndexKeyCache(Duration.standardDays(1))
.withEppResourceCache(Duration.ofDays(1))
.withForeignIndexKeyCache(Duration.ofDays(1))
.build();
private final FakeResponse response = new FakeResponse();

View File

@@ -34,7 +34,7 @@ import google.registry.testing.FakeClock;
import google.registry.testing.TestCacheExtension;
import google.registry.testing.TestOfyAndSql;
import java.net.InetAddress;
import org.joda.time.Duration;
import java.time.Duration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -50,7 +50,7 @@ class WhoisCommandFactoryTest {
@RegisterExtension
final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withEppResourceCache(Duration.millis(1000000000)).build();
new TestCacheExtension.Builder().withEppResourceCache(Duration.ofSeconds(1000000)).build();
WhoisCommandFactory noncachedFactory = WhoisCommandFactory.createNonCached();
WhoisCommandFactory cachedFactory = WhoisCommandFactory.createCached();