mirror of
https://github.com/google/nomulus
synced 2026-05-22 15:51:49 +00:00
Cache domains, contacts, and hosts in WHOIS queries
This should prevent having issues with hot key paths on entities that experience a heavy WHOIS volume (e.g. contacts that registrars reuse on many domains). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=191506124
This commit is contained in:
@@ -22,6 +22,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.TypeUtils.instantiate;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -218,13 +219,18 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||
* given IDs (blah) don't exist."
|
||||
*/
|
||||
@NonFinalForTesting
|
||||
static LoadingCache<Key<ForeignKeyIndex<?>>, Optional<ForeignKeyIndex<?>>>
|
||||
private static LoadingCache<Key<ForeignKeyIndex<?>>, Optional<ForeignKeyIndex<?>>>
|
||||
cacheForeignKeyIndexes =
|
||||
CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(getEppResourceCachingDuration().getMillis(), MILLISECONDS)
|
||||
.maximumSize(getEppResourceMaxCachedEntries())
|
||||
.build(CACHE_LOADER);
|
||||
|
||||
@VisibleForTesting
|
||||
public static void setCacheForTest(CacheBuilder<Object, Object> cacheBuilder) {
|
||||
cacheForeignKeyIndexes = cacheBuilder.build(CACHE_LOADER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a list of {@link ForeignKeyIndex} instances by class and id strings that are active at or
|
||||
* after the specified moment in time, using the cache if enabled.
|
||||
|
||||
Reference in New Issue
Block a user