Merge "Merge branch 'stable-2.13'"

This commit is contained in:
David Pursehouse
2016-09-23 12:12:32 +00:00
committed by Gerrit Code Review
2 changed files with 25 additions and 9 deletions

View File

@@ -357,7 +357,7 @@ public class Daemon extends SiteProgram {
modules.add(new DiffExecutorModule()); modules.add(new DiffExecutorModule());
modules.add(new MimeUtil2Module()); modules.add(new MimeUtil2Module());
modules.add(cfgInjector.getInstance(GerritGlobalModule.class)); modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
modules.add(new SearchingChangeCacheImpl.Module()); modules.add(new SearchingChangeCacheImpl.Module(slave));
modules.add(new InternalAccountDirectory.Module()); modules.add(new InternalAccountDirectory.Module());
modules.add(new DefaultCacheFactory.Module()); modules.add(new DefaultCacheFactory.Module());
if (emailModule != null) { if (emailModule != null) {

View File

@@ -36,6 +36,7 @@ import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import com.google.inject.name.Named; import com.google.inject.name.Named;
import com.google.inject.util.Providers;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -52,17 +53,32 @@ public class SearchingChangeCacheImpl implements GitReferenceUpdatedListener {
static final String ID_CACHE = "changes"; static final String ID_CACHE = "changes";
public static class Module extends CacheModule { public static class Module extends CacheModule {
private final boolean slave;
public Module() {
this(false);
}
public Module(boolean slave) {
this.slave = slave;
}
@Override @Override
protected void configure() { protected void configure() {
cache(ID_CACHE, if (slave) {
Project.NameKey.class, bind(SearchingChangeCacheImpl.class)
new TypeLiteral<List<CachedChange>>() {}) .toProvider(Providers.<SearchingChangeCacheImpl> of(null));
.maximumWeight(0) } else {
.loader(Loader.class); cache(ID_CACHE,
Project.NameKey.class,
new TypeLiteral<List<CachedChange>>() {})
.maximumWeight(0)
.loader(Loader.class);
bind(SearchingChangeCacheImpl.class); bind(SearchingChangeCacheImpl.class);
DynamicSet.bind(binder(), GitReferenceUpdatedListener.class) DynamicSet.bind(binder(), GitReferenceUpdatedListener.class)
.to(SearchingChangeCacheImpl.class); .to(SearchingChangeCacheImpl.class);
}
} }
} }