update to use TimeValue in CacheBuilder

Original commit: elastic/x-pack-elasticsearch@7f5a59bd73
This commit is contained in:
Jay Modi 2016-10-13 09:27:51 -04:00 committed by GitHub
parent 0deb38a95d
commit 219c42d7ce
2 changed files with 3 additions and 3 deletions

View File

@ -36,9 +36,9 @@ public abstract class CachingUsernamePasswordRealm extends UsernamePasswordRealm
super(type, config);
hasher = Hasher.resolve(config.settings().get(CACHE_HASH_ALGO_SETTING, null), Hasher.SSHA256);
TimeValue ttl = config.settings().getAsTime(CACHE_TTL_SETTING, DEFAULT_TTL);
if (ttl.millis() > 0) {
if (ttl.getNanos() > 0) {
cache = CacheBuilder.<String, UserWithHash>builder()
.setExpireAfterAccess(TimeUnit.MILLISECONDS.toNanos(ttl.getMillis()))
.setExpireAfterAccess(ttl)
.setMaximumWeight(config.settings().getAsInt(CACHE_MAX_USERS_SETTING, DEFAULT_MAX_USERS))
.build();
} else {

View File

@ -135,7 +135,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
this.client = client;
this.roleCache = CacheBuilder.<String, RoleAndVersion>builder()
.setMaximumWeight(CACHE_SIZE_SETTING.get(settings))
.setExpireAfterWrite(CACHE_TTL_SETTING.get(settings).getNanos())
.setExpireAfterWrite(CACHE_TTL_SETTING.get(settings))
.build();
this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false;
}