Convert cache expireAfterWrite to nullable Duration
Use the same Duration type throughout the stack. In particular, this allows us to use the java.time API for doing expiry calculations in H2CacheImpl. Converting to Optional<Duration> is beyond the scope of this change, as it would properly imply changing the other nullable fields in CacheDef. Change-Id: I63a173ce1bef83fa84ccb8b8b6ea75ae198e5728
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
|
||||
package com.google.gerrit.httpd;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
@@ -30,6 +28,7 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import com.google.inject.name.Named;
|
||||
import com.google.inject.servlet.RequestScoped;
|
||||
import java.time.Duration;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -41,10 +40,8 @@ public class H2CacheBasedWebSession extends CacheBasedWebSession {
|
||||
protected void configure() {
|
||||
persist(WebSessionManager.CACHE_NAME, String.class, Val.class)
|
||||
.maximumWeight(1024) // reasonable default for many sites
|
||||
.expireAfterWrite(
|
||||
CacheBasedWebSession.MAX_AGE_MINUTES,
|
||||
MINUTES) // expire sessions if they are inactive
|
||||
;
|
||||
// expire sessions if they are inactive
|
||||
.expireAfterWrite(Duration.ofMinutes(CacheBasedWebSession.MAX_AGE_MINUTES));
|
||||
install(new FactoryModuleBuilder().build(WebSessionManagerFactory.class));
|
||||
DynamicItem.itemOf(binder(), WebSession.class);
|
||||
DynamicItem.bind(binder(), WebSession.class)
|
||||
|
||||
Reference in New Issue
Block a user