update to use TimeValue in CacheBuilder
Original commit: elastic/x-pack-elasticsearch@7f5a59bd73
This commit is contained in:
parent
0deb38a95d
commit
219c42d7ce
|
@ -36,9 +36,9 @@ public abstract class CachingUsernamePasswordRealm extends UsernamePasswordRealm
|
||||||
super(type, config);
|
super(type, config);
|
||||||
hasher = Hasher.resolve(config.settings().get(CACHE_HASH_ALGO_SETTING, null), Hasher.SSHA256);
|
hasher = Hasher.resolve(config.settings().get(CACHE_HASH_ALGO_SETTING, null), Hasher.SSHA256);
|
||||||
TimeValue ttl = config.settings().getAsTime(CACHE_TTL_SETTING, DEFAULT_TTL);
|
TimeValue ttl = config.settings().getAsTime(CACHE_TTL_SETTING, DEFAULT_TTL);
|
||||||
if (ttl.millis() > 0) {
|
if (ttl.getNanos() > 0) {
|
||||||
cache = CacheBuilder.<String, UserWithHash>builder()
|
cache = CacheBuilder.<String, UserWithHash>builder()
|
||||||
.setExpireAfterAccess(TimeUnit.MILLISECONDS.toNanos(ttl.getMillis()))
|
.setExpireAfterAccess(ttl)
|
||||||
.setMaximumWeight(config.settings().getAsInt(CACHE_MAX_USERS_SETTING, DEFAULT_MAX_USERS))
|
.setMaximumWeight(config.settings().getAsInt(CACHE_MAX_USERS_SETTING, DEFAULT_MAX_USERS))
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.roleCache = CacheBuilder.<String, RoleAndVersion>builder()
|
this.roleCache = CacheBuilder.<String, RoleAndVersion>builder()
|
||||||
.setMaximumWeight(CACHE_SIZE_SETTING.get(settings))
|
.setMaximumWeight(CACHE_SIZE_SETTING.get(settings))
|
||||||
.setExpireAfterWrite(CACHE_TTL_SETTING.get(settings).getNanos())
|
.setExpireAfterWrite(CACHE_TTL_SETTING.get(settings))
|
||||||
.build();
|
.build();
|
||||||
this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false;
|
this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue